The line 555 of theme.inc causes the problem in php 5.2 sometimes.
The problem has been resolved when I changed the line
$link['attributes']['class'] = $key;
into
$link['attributes'] = array('class' => $key);

Comments

zeta ζ’s picture

Assigned: Unassigned » zeta ζ
Status: Active » Needs review

What are the symptoms? ie. what goes wrong? error message? Is this bad enough to be critical?

Does it happen with Garland? How can I reproduce this?

You say sometimes: What is different when it happens and when it doesn’t?

What about?

       // Automatically add a class to each link and also to each LI
      if (isset($link['attributes'])) {
        if (isset($link['attributes']['class'])) {
          $link['attributes']['class'] .= ' ' . $key;
        }
        else {
          $link['attributes']['class'] = $key;
        }
      }
      else {
        $link['attributes'] = array('class' => $key);
      }
      $class = $key;
 

I’ll role a patch if this is good.

itman’s picture

Seems like it affects all themes, but I will double check it today. Then, I will give you more details.

itman’s picture

Sorry, I cannot reproduce this error anymore. :-( I will let you know, if the problem persists.

zeta ζ’s picture

Version: 5.6 » 5.x-dev
Assigned: zeta ζ » Unassigned
Priority: Critical » Normal
Status: Needs review » Needs work

This code is still in 5.x-dev but not in 6.x.

If I set $link = array('attributes'=>'a string'); this causes an error, but this occurs on line 551 ( (isset($link['attributes']['class']) is TRUE! actually, it is the string 'a'), so can’t be the problem.

If I set $link = 'a string'; this does cause an error on line 555. Is this a possible scenario (one element of $links is a string rather than an array)? Should we check for this? if (is_array($link) && is_array($link['attributes']) Resolution by itman doesn’t give an error in this situation, but doesn’t give a sensible result either ($link is the string 'A' !). Seems obscure and itman cannot reproduce the error, so down-grading to normal.

itman’s picture

Hi, yes, very likely the problem was with the wrong link.... If the suggested bugfix does not make sense in terms of producing a valid link, is it worth triggering an error (so a user will see it in logs and/or on the screen) and producing an empty string for this particular link?

zeta ζ’s picture

Status: Needs work » Postponed (maintainer needs more info)

I would like to know more about what might cause a member of $links[] to be a string rather than the assumed array.

Is it possible, but rare that a user would encounter this on a default install, due to an unusual configuration? Or is it the result of a new theme sending the wrong data?

What did you do that might have caused this? Or what did you change that solved it?

Would be helpful when writing an appropriate error message.

PHP is not a strongly typed language, and it wouldn’t be efficient to catch every possibility. But if this scenario is possible, it would be good to catch it, and give the user a chance to correct it as you suggest.

If this is really the cause then there wouldn’t be the attributes etc. to produce a valid link.

itman’s picture

Thank you for taking this report very seriously (I wish a part of your enthusiasm were transfered to the openid developer :-).
When you suggested that the error was caused by an invalid link I recalled that I mistakingly wrote a function with the name user_link. This function was "hooked" by the main drupal module and feeded this error. It was my own module that caused a disruption, naturally even with a standard theme like Garland. Later I changed the function name. That is why I could not reproduce the error. Now I can and do.
Sorry for the distraction. I think this bug report can be closed.

zeta ζ’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

So long as you use cp and not mv ;D

Thanks for following up with the info. to clarify this.

I agree that this is exceptional and doesn’t need catching ∴ => closing.

permutations’s picture

There's still a problem here. I have a very simple PHP theme that is triggering this error in Drupal 5.7. My server is running PHP 5.2.

zeta ζ’s picture

Do you have a user function like user_link() which might be a ‘hook’?

What is the name of your theme? Can you attach your template.php?

permutations’s picture

I have no functions like user_link that might be a hook.

My theme doesn't use an engine of any kind. It's a very simple CSS-based theme like Cameleon, written in straight PHP.

I fixed the problem by going through my theme and Cameleon, line-by-line, and copying the new syntax for Drupal 5 (my theme was for 4.7). Links were specified differently in some places. This isn't explained in the theme update guide.

Thank you for following up on this.