With "anonymous user" "access comments" permission checked, instead of getting the expected "Login or register to post comments" links, i'm getting the word "Array". Not sure when this started happening but I've disabled all contrib modules with the exception of core-required and comment, switched to the default Garland theme and the only change is that it no longer outputs the word "Array"; it outputs nothing. Adding the code <?php print_r($node->links); ?> to Garlands node.tpl file reveals the following output:

       	Array
(
    [comment_forbidden] => Array
        (
            [title] => 
            [html] => 1
        )

)

Adding the same code to my vanilla drupal 6.16 Garland node.tpl file outputs:

       	Array
(
    [comment_forbidden] => Array
        (
            [title] => Login or register to post comments
            [html] => 1
        )

)

Anyone have any ideas as to what might be causing this?
Thank you,
Scott

PS. happening in Drupal 6.15 and now 6.16
I'm using:
MySQL v5.0.77mm0.1
PHP v5.2.9
Apache v1.3.41 (Unix)

Comments

weseze’s picture

I've got the same problem, no idea what caused this...
(subscribe)

Sc0tt’s picture

If "authenticated users" permission is unchecked so they can't post comments, Pete (http://drupal.org/user/61645) figured out that..."The problem was that authenticated users can't post comments. I eventually tracked the problem down to theme_comment_post_forbidden; if the authenticated user can't post comments, the function returns nothing!"

He added the following code to my theme's template.php file to override the word "Array" with "Subscribe to post comments":

>
function gazette_comment_post_forbidden($node) {
  global $user;
  static $authenticated_post_comments;

  if (!$user->uid) {
    if (!isset($authenticated_post_comments)) {
      // We only output any link if we are certain, that users get permission
      // to post comments by logging in. We also locally cache this information.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
    }

    if ($authenticated_post_comments) {
      // We cannot use drupal_get_destination() because these links
      // sometimes appear on /node and taxonomy listing pages.
      if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
        $destination = 'destination='. rawurlencode("comment/reply/$node->nid#comment-form");
      }
      else {
        $destination = 'destination='. rawurlencode("node/$node->nid#comment-form");
      }

      if (variable_get('user_register', 1)) {
        // Users can register themselves.
        //return 'User can register';
        return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
      }
      else {
        // Only admins can add new users, no public registration.
        //return 'Only admin can add users';
        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
      }
    }
    else { // This bit added for debugging - PJB
      //return '<em>Auth. users can\'t post comments!</em>';
      return t('<a href="@subscribe">Subscribe</a> to post comments', array('@subscribe' => url('catalog/subscriptions', array('query' => $destination))));
    }
  }
}
</... 

Thanks Pete!
Scott

venusrising’s picture

@Sc0tt Been wondering where the heck the login or register to post comments went. Thanks for saving my sanity. Yes it is the lack of authenticated user being ticked. Been searching for hours.
BIG THANKS

venusrising