Hi,

after I installed the piwik module (http://drupal.org/project/piwik), I get this error :

Fatal error: Unsupported operand types in /var/www/drupal/includes/common.inc on line 1416

When piwik is activated, I can't access my website due this error. If I deactivate piwik, I can access to the website.

The problem comes from this code:

function url($path = NULL, $options = array()) {
  // Merge in defaults.
  $options += array(
    'fragment' => '',
    'query' => '',
    'absolute' => FALSE,
    'alias' => FALSE,
    'prefix' => ''
  );

When url() is called like this :

  url($path, NULL);

Then $option is null and php can't do $options += array() cause it's like NULL+= array()

I search on the web and find here a possible solution : http://www.bekirdag.com/en/drupal/commoninc_fatal_error_problem_on_line_...

The solution was to change

$options += array(
     'fragment' => '',
     'query' => '',
     'absolute' => FALSE,
     'alias' => FALSE,
     'prefix' => ''
   );

in

    $options['fragment'] = "";
    $options['query'] = "";
    $options['absolute'] = FALSE;
    $options['alias'] = FALSE;
    $options['prefix'] = "";

but that's not the same cause with the concatenation when for example $option['fragment'] has already a value the value will be keep, and with the new code the value will change.

That produces bugs, for example, I can't run completely the script update.php. With this solution after the step "Select updates" I click on update and it goes to the first step, it make no update...

Maybe I have a solution but I'm sure if it's correct. I just suggest to add this code

if (!isset($options)) $options = array();

With the code there is no Fatal error anymore and I can make an update.

Maybe can someone tell me if my solution is ok or not.

Comments

nicks’s picture

subcribing

(I have the same problem, possibly related to the flag module, and also decided that your approach is nicer than bekirdag's)

nicks’s picture

Project: Piwik Web Analytics » Drupal core
Version: 6.x-1.1 » 6.15
Component: Code » base system
Assigned: Unassigned » charles.bourasseau
Status: Active » Closed (works as designed)
Issue tags: +fatal error, +common.inc, +Unsupported operand types

I believe this is a problem with modules, rather than with drupal core. There is a handbook page on this subject:


This error happens because the parameters to url() changed in Drupal 6. The most common problem is an enabled module hasn't fully converted it's code from Drupal 5 and is causing the error.

The page also describes how to debug the problem. The thread on fixing the flag module for this purpose may also be of use to people.

heine’s picture

Project: Drupal core » Piwik Web Analytics
Version: 6.15 » 6.x-1.1
Component: base system » Code
Assigned: charles.bourasseau » Unassigned
Priority: Critical » Normal
Issue tags: -fatal error, -common.inc, -Unsupported operand types

Moving to the likely culprit.

hass’s picture

Project: Drupal core » Piwik Web Analytics
Version: 6.15 » 6.x-1.1
Component: base system » Code
Assigned: charles.bourasseau » Unassigned
Status: Closed (works as designed) » Postponed (maintainer needs more info)
Issue tags: -fatal error, -common.inc, -Unsupported operand types

There is no line in piwik that add's a NULL as second parameter to url(). Please point me to the line you are talking about. I cannot repro.

charles.bourasseau’s picture

I can't say that this error comes from Piwik, I didn't look at the code.

I just explained how this error was in my Drupal. How I got it.

Now I saw this error in many other website, and they not always spoke about Piwik, for me it's not just a module error but a code problem too.

Just with one line you can avoid that ... When a module can affect the core, for me it's a core fault.

heine’s picture

If you install piwik and the error occurs, then uninstall piwik and the error stops, the error might very well be in piwik.

What exact module version are you using and which (sub)modules did you enable?

charles.bourasseau’s picture

I didn't remember, it was during an update from D5 to D6. It was so bad, Menu was in double, Piwik caused problem, and other problems. So we decided to restart a D6 from null, it's very better...

Now when I just see the core of D6:

function url($path = NULL, $options = array()) {
// Merge in defaults.
$options += array(

if url is called like that :

url($path, NULL);

Yes the problem comes from the module, but the problem can be avoid by the core...

heine’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Okay, if it's not reproducible we cannot fix. As hass wrote, there's nothing on quick inspection that would cause this. Just like #225211: warning: preg_match() expects parameter 2 to be string - SRSLY, WON'T FIX, EVER., it won't be fixed in core either.

For those googling this error message: See Fatal error: Unsupported operand types in common.inc to find out how to debug this error.

hass’s picture

Status: Closed (won't fix) » Postponed (maintainer needs more info)

This code is not inside the piwik D6 module! Won't fix for cannot repro.

Feel free to move the case somewhere else.

hass’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)