Notice: Array to string conversion in token_replace() (line 102 of /.../includes/token.inc)

When I have the module enabled I am receiving a notice, suggestions, tips, etc?

Comments

swati.karande’s picture

Hi,
I am not getting these error messages on my local instance.
Is it occouring on php5.4 version?

Christopher Riley’s picture

I am running on php 5.3.10 on a dev box of mine.

markhalliwell’s picture

Title: Notice: Array to string conversion in token_replace() (line 102 of /.../includes/token.inc) » Human readable tokens fires notice for objects

I can tell by the error that you're actually using the 7.x-1.x branch, not the 7.x-2.x branch. I strongly recommend upgrading regardless of any solution that comes out of this. 7.x-1.x receives security fixes only and any fixes applied to Menu Views will happen on the 7.x-2.x branch.

http://drupalcode.org/project/menu_views.git/blob/refs/heads/7.x-1.x:/includes/tokens.inc#l102

101 elseif (is_object($value)) {
102   $value = t('Object');
103 }

Despite the version difference, you'll see that the notice only fires on line 102, which means that the $value variable is initially an object instead of a string. It could be that PHP has some issues with reassigning the variable. I'll keep this issue open and see about putting some stopgap measures for the 7.x-2.x branch in the future.

Also keep in mind that this only happens because it's trying to convert data values into a human readable value, which means this would have to be on the admin menu overview form, which also means you have a menu view item in your menu. It might be better to simply pass the object's (i'm guess a node here) ID rather than the node itself ([node:nid] rather than [node]?) and let the view load the object as necessary.

markhalliwell’s picture

Status: Active » Fixed

Fixed with release of 7.x-2.1 (http://drupal.org/node/1909888)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.