<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div>Hi, I have had a problem with the comments module (administer->comments) and I have a couple of questions on it.<br><div id="message"><div class="messages error">
<br>
I'm currently using Drupal 4.7.4 with PHP 4.4.3 and MySQL 4.1.21<br>
<br>
When entering the configure tab I was getting this warnings.<br>
<ul><li>warning: array_keys() [<a href="http://www.asespat.es/function.array-keys">function.array-keys</a>]: The first argument should be an array in /home/server/public_html/modules/user.module on line 352.</li><li>warning: implode() [<a href="http://www.asespat.es/function.implode">function.implode</a>]: Bad arguments. in /home/server/public_html/modules/user.module on line 352.</li><li>user
warning: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ')' at line 1
query: SELECT DISTINCT(p.perm) FROM role r INNER JOIN permission p ON
p.rid = r.rid WHERE r.rid IN () in
/home/server/public_html/includes/database.mysql.inc on line 121.</li></ul>After
debugging it a bit I found that when looking for the 'post comments'
permissions it was hard sending a user with uid = 0. I have recently
had to recover my database and row with uid = 0 on users table was
missing.<br>
<br>
As my Administrator user has uid = 1 I tried to replace the hardcoded value to 1:<br>
<br>
</div>
<span style="font-family: courier new,monospace;">--- a/comment.module 2006-10-18 15:14:42.000000000 -0500</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+++ b/comment.module 2007-01-03 03:17:09.000000000 -0600</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">@@ -402,7 +402,7 @@</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> '#description'
=> t('This option is enabled when anonymous users have permission to
post comments on the <a href="%url">permissions page</a>.',
array('%url' => url('admin/access'))),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">- if (!user_access('post comments', user_load(array('uid' => 0)))) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+ if (!user_access('post comments', user_load(array('uid' => 1)))) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $form['posting_settings']['comment_anonymous']['#attributes'] = array('disabled' => 'disabled');</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br>
<br>
It seemed to work ok.<br>
<br>
I have performed a grep over all module sources and it seems that is
the only place where the seccond parameter is hardcoded when calling
user_access function:<br>
<br>
<span style="font-family: courier new,monospace;">user@server [~/public_html/modules]$ grep "user_access([^,)]*," *</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">blog.module: if ($type == 'view' && user_access('edit own blog', $user)) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">blogapi.module: if (user_access('edit own blog', $user)) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">comment.module: if (!user_access('post comments', user_load(array('uid' => 0)))) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">user.module:function user_access($string, $account = NULL) {</span><br style="font-family: courier new,monospace;">
<br>
I then decided to undo the change in the comment.module and go on with
an insert into the users table with uid = 0 and the rest of the columns
with their default values and it seems to work ok.<br>
<br>
What I don't understand is why do you pass the second argument instead
of having the default value (NULL) to be assigned to the $account
parameter in the user_access functiont of the user.module:<br>
<br>
<span style="font-family: courier new,monospace;">function user_access($string, $account = NULL) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> global $user;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> static $perm = array();</span><br>...<br><br>
Regards.<br>
<br>
Ignacio.<br>
<br>
</div>
</div></div><br>__________________________________________________<br>Correo Yahoo!<br>Espacio para todos tus mensajes, antivirus y antispam ¡gratis! <br>Regístrate ya - http://correo.yahoo.es </body></html>