[development] Drupal 4.7 - Question regarding Comments module.

Ignacio G. Dupont igdtl at yahoo.com
Wed Jan 3 10:00:30 UTC 2007

Hi, I have had a problem with the comments module (administer->comments) and I have a couple of questions on it.

I'm currently using Drupal 4.7.4 with PHP 4.4.3 and MySQL 4.1.21

When entering the configure tab I was getting this warnings.

 warning: array_keys() [function.array-keys]: The first argument should be an array in /home/server/public_html/modules/user.module on line 352.warning: implode() [function.implode]: Bad arguments. in /home/server/public_html/modules/user.module on line 352.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.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

As my Administrator user has uid = 1 I tried to replace the hardcoded value to 1:

--- a/comment.module  2006-10-18 15:14:42.000000000 -0500

+++ b/comment.module  2007-01-03 03:17:09.000000000 -0600

@@ -402,7 +402,7 @@

       COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),

=> 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'))),


-  if (!user_access('post comments', user_load(array('uid' => 0)))) {

+  if (!user_access('post comments', user_load(array('uid' => 1)))) {

     $form['posting_settings']['comment_anonymous']['#attributes'] = array('disabled' => 'disabled');


It seemed to work ok.

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:

user at server [~/public_html/modules]$ grep "user_access([^,)]*," *

blog.module:  if ($type == 'view' && user_access('edit own blog', $user)) {

blogapi.module:    if (user_access('edit own blog', $user)) {

comment.module:  if (!user_access('post comments', user_load(array('uid' => 0)))) {

user.module:function user_access($string, $account = NULL) {

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.

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:

function user_access($string, $account = NULL) {

  global $user;

  static $perm = array();



Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.es 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070103/048f1062/attachment.htm 

More information about the development mailing list