Hello Rik,

After installing the latest dev version of Revisioning, I get this fatal error for all of my moderators roles.

Fatal error: Unsupported operand types in /Applications/MAMP/htdocs/guilderlanddemocrats-com-d6v12/includes/common.inc on line 1542

If I switch back to the older version of the module this error goes away.

Doesn't matter whether I have the permission to unpublish current revision checked or unchecked.

I haven't yet started to explore the code for the error. That's next.

Steve

Comments

wickwood’s picture

I forgot to mention, this only occurs when the moderator creates new content. Pure author roles create content just fine. And actually the node gets created, but you get a white screen of death if you don't have error reporting turned on for moderator roles after saving the new content.

Also, I now know that this error from includes/common.inc on line 1542 is for the l() function.

Steve

wickwood’s picture

I've narrowed the problem down to line 866 in the revisions.module file. When I comment it out and replace it with the l() function you were using, then I don't get the error.

Line 866 // $themed_links[] = theme('menu_item_link', $link);
Added        $themed_links[] = l($link['title'], $link['href']);

I'm not familiar with how the theme function works (yet), but I think the error must be generated by how the data is being passed to it.

rdeboer’s picture

Hi Steve,

By default theme('menu_item_link', $links) calls /includes/menu.inc/theme_menu_item_link($link) which in turn executes l($link['title'], $link['href'], array()) just like the line you replaced.

The exception is when a theme has been installed that overrides theme_menu_item_link().

I suggest you do a search for ..._menu_item_link(... across your entire drupal source code folder to find the offending code and we'll take it from there.

Rik

wickwood’s picture

Hello Rik,

Glad you showed up tonight!

I had just traced down what you just told me, and I do use the hook_menu_item_link in my theme's template.php file.

Here is the code that I picked up here on the forum somewhere:

/**
 * Change Log In and Log Out links to return user to the page they were on
 * when they logged in or out.
 **/
function gdems4v2b_menu_item_link($link) {
  if ($link['title']=='Log In') {
    if (empty($link['localized_options'])) {
      $link['localized_options'] = array();
    }
 
    //set the destination, for different destinations for different users, work it out here
    $destination = drupal_get_destination();

    // Merge in the query with current localized options
    $link['localized_options'] += array(
      'query' => $destination,
    );
  }
	if ($link['title']=='Log Out') {
    if (empty($link['localized_options'])) {
      $link['localized_options'] = array();
    }
 
    //set the destination, for different destinations for different users, work it out here
    $destination = drupal_get_destination();

    // Merge in the query with current localized options
    $link['localized_options'] += array(
      'query' => $destination,
    );
  }
	
  return l($link['title'], $link['href'], $link['localized_options']);
}  

Also, from your code and what I'm reading about theme_menu_item_link() and l(), I can't figure out how $link['type'] is being used. The value is 0, and that doesn't match any of the options for l(). So what does $link['type'] do?

Thanks for your help in advance!
Steve

wickwood’s picture

Status: Active » Fixed

Hey Rik,

Fixed. I should have paid more attention to theme overriding code I used. Here is what I changed it to, and now things seem to be working correctly with the latest Revisioning module.

Here is the revised code:

/**
 * Change Log In and Log Out links to return user to the page they were on
 * when they logged in or out.
 **/
function gdems4v2b_menu_item_link($link) {
  if (empty($link['localized_options'])) {
      $link['localized_options'] = array();
    }
	
	if ($link['title']=='Log In' || $link['title']=='Log Out') {
    $destination = drupal_get_destination();

    // Merge in the query with current localized options
    $link['localized_options'] += array(
      'query' => $destination,
    );
  }
	
  return l($link['title'], $link['href'], $link['localized_options']);
}  

I hope you don't mind me posting my "stream of thought" as I find things that cause me problems even if they in the end are not the fault of your module, but are the result of bad code elsewhere like this.

Thanks for your help and all your work these modules. There a lifesaver for me!

Steve

rdeboer’s picture

Hi Steve,
Yes that $link['localized_options'] needs to have a value, even if it's empty.
Glad you were able to figure it out yourself.
Thanks for the feedback -- it's always great to hear that someone finds a good use for the modules.
After all, I got a lot out of drupal and its community, so it's only fair to put some time into giving something back.
Rik

wickwood’s picture

Hello Rik,

Your little tip sent me in the right direction to solve the problem, and I appreciate your prompt replies. I know you are just as busy as the rest of us.

I have one last question for you on this topic:

Does $link['localized_options'] needs to have a value for the l() function and is this why you pass $link['type'] with a value of '0'?

From reading the API documention, I guess an $options parameter does not mean an optional parameter. It would seem that if you can send any value, then you should be able to send no value at all.

Am I understanding this correctly?

Thanks again for your help,
Steve

rdeboer’s picture

Hi Steve,

First of all, yes, when you pass NULL as the third argument to the l function it crashes in the way you have experienced. But if you pass array() it's ok.

Regarding $link['type']....
Certain themes, like Zen and its derivatives, e.g. Zen Classic, use the $link['type'] to do something special, like putting a "span" and style class on the a hrefit upon rendering, when the link is of a particular type, like $link['type'] == MENU_IS_LOCAL_TASK, which is a link that is a rendered as a tab.
If you download Zen (without actually installing it), you can find this behaviour coded in the function zen_menu_item_link()

So in order to play nicely with these themes, i.e. letting them override theme_menu_item_link(), generate_revision_links_according_to_permissions($node, $link_type) allows you to pass in the $link_type, which it then passes on the the theme in question.

See #489146: Output Links in the $tabs variable, comments #8, #9.
This thread contains a piece of template code you can use to render the Revisioning links as tabs.
Check out the screenshots in that thread.
And thanks attheshow for the idea!

Rik

rdeboer’s picture

Status: Fixed » Closed (fixed)