Hello folks,

My site was working just fine and suddenly i get the following error when trying to open a story/article

Fatal error: Unsupported operand types in /home/club509/public_html/articlebots/includes/common.inc on line 1265

Comments

Nari-1’s picture

I get the same error, except it happens whenever I try to edit a comment. The comment still saves, however, even though the error shows up. Does anyone have any idea what the problem is or how to fix it?

Nari-1’s picture

I looked through the code, and found this:

/**
 * Generate a URL from a Drupal menu path. Will also pass-through existing URLs.
 *
 * @param $path
 *   The Drupal path being linked to, such as "admin/content/node", or an
 *   existing URL like "http://drupal.org/".  The special path
 *   '<front>' may also be given and will generate the site's base URL.
 * @param $options
 *   An associative array of additional options, with the following keys:
 *   - 'query'
 *       A query string to append to the link, or an array of query key/value
 *       properties.
 *   - 'fragment'
 *       A fragment identifier (or named anchor) to append to the link.
 *       Do not include the '#' character.
 *   - 'absolute' (default FALSE)
 *       Whether to force the output to be an absolute link (beginning with
 *       http:). Useful for links that will be displayed outside the site, such
 *       as in an RSS feed.
 *   - 'alias' (default FALSE)
 *       Whether the given path is an alias already.
 *   - 'external'
 *       Whether the given path is an external URL.
 *   - 'language'
 *       An optional language object. Used to build the URL to link to and
 *       look up the proper alias for the link.
 *   - 'base_url'
 *       Only used internally, to modify the base URL when a language dependent
 *       URL requires so.
 *   - 'prefix'
 *       Only used internally, to modify the path when a language dependent URL
 *       requires so.
 * @return
 *   A string containing a URL to the given path.
 *
 * When creating links in modules, consider whether l() could be a better
 * alternative than url().
 */
function url($path = NULL, $options = array()) {
  // Merge in defaults.
  $options += array(
    'fragment' => '',
    'query' => '',
    'absolute' => FALSE,
    'alias' => FALSE,
    'prefix' => ''
  );
  if (!isset($options['external'])) {
    // Return an external link if $path contains an allowed absolute URL.
    // Only call the slow filter_xss_bad_protocol if $path contains a ':' before
    // any / ? or #.
    $colonpos = strpos($path, ':');
    $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path));
  }

Line 1265 is the ); right under 'prefix' => '' in the array. So, I'm guessing it's a problem with the url generation when it takes you back to the main thread? I've been reading other threads about "unsupported operand types" and most of them have to do with syntax errors, but I see nothing.

davedelong’s picture

Hint: The problem is not in core.

You'll notice that the $options variable must be an array. Most likely, whatever's calling the url() function isn't passing an array in for the $options parameter. Since you can't += an array to a scalar, that's probably why it's erroring.

HTH,

Dave

Get great Drupal hosting at MM Hosting. (I don't work for them; I'm just a very satisfied customer)

mmmweb’s picture

Thanks for the hint....so we should be looking into additional modules for the problem? Why would this all of a sudden begin to occur on otherwise fully functional production sites? Seems strange!

If you know more, can you please share? Pretty plleeeeassse?? :-)
Thanks!
Melanie

When you know all you understand, have compassion and love all. Truth brings love, love brings joy.

davedelong’s picture

You need to figure out what's calling that url() function and verify that the right types of parameters are getting sent. Maybe you could *temporarily* modify the url() function to print out some debug_backtrace information, or better yet, put in a line at the beginning of the url() function like this:

drupal_set_message(gettype($options));

If that ever prints something that's not "Array", then you know that's the problem. Then you can figure out what's causing it. Maybe something like:

if (gettype($options) != 'array') {
  //this will print out who's calling this function so you can track down the problem:
  debug_print_backtrace();
  die();
}

edit: if you don't want to use gettype, you can just as easily do:

if (!is_array($options)) {
...

Dave

Get great Drupal hosting at MM Hosting. (I don't work for them; I'm just a very satisfied customer)

mmmweb’s picture

Just wanted to thank you for taking the time to explain this to me Dave....MUCH appreciated. I am a bit of a noob with Drupal though...and even though you're pretty clear...I was scratching my head a little. ;-) But thank you regardless! The error is now gone with Community Tags disabled. YAY!

Best Regards,
Melanie

www.book-of-light.com

When you know all you understand, have compassion and love all. Truth brings love, love brings joy.

davedelong’s picture

No problem. I'm glad you got it figured out. =)

Dave

Get great Drupal hosting at MM Hosting. (I don't work for them; I'm just a very satisfied customer)

mmmweb’s picture

I am getting this exact error, but only when I'm logged out of my site and click on content titles from the front page...any ideas on how to fix this? Is it a url alias issue maybe?

HELP! I don't even know where to start with this one...but I am a relative noob to Drupal (6 months).

My site is live at www.book-of-light.com and clicking on content generates the error...

Thanks for help anyone can provide on this...it's likely a big turn off to anonymous users wanting to view my content. Ah well...cest la vie! I'll have to do what I can and hope some amazing Drupal-God will step up with some assistance. ;-)

Melanie

When you know all you understand, have compassion and love all. Truth brings love, love brings joy.

MiaMia’s picture

I also came across this hair-splitting bug and traced it down to a buggy build of Community Tags - http://drupal.org/project/community_tags

I turned this module off and everything is working again.

Hope this helps,

MiaMia

mmmweb’s picture

This solved my problem...just disabling the module did it.

THANK YOU, as I was not looking forward to attempting to troubleshoot using the above method...as much as I appreciate the help...it was a bit over my new Drupal head (7 months :-) )

THanks to you both for your help! I'll be posting this as an Issue on Community Tags for others to benefit from.

Peace!
Melanie

When you know all you understand, have compassion and love all. Truth brings love, love brings joy.