Fatal error: Cannot use object of type stdClass as array in C:\...\...\modules\nodewords\nodewords.module on line 144

Error above occurs when I am deleting a taxonomy term. Similar error occurs when I delete nodes. The address in the error above is due to the fact I'm working on localhost - but it also happens when uploded onto a server.

Comments

alonpeer’s picture

The same thing happens to me.

Drupal 4.6.5, Apache 2, PHP 5

Any fix available for this?

alonpeer’s picture

Status: Active » Needs review

I found the problem!
The problem is that the function nodewords_taxonomy() is referring to $object as if it was an array.
Here's my nodewords_taxonomy() patch (I commented the things I changed):

  if ($type == 'term') {
    //$id = $object['tid'];
    $id = $object->tid;
  }
  elseif ($type == 'vocabulary') {
    //$id = $object['vid'];
    $id = $object->vid;
  }
  else {
    return;
  }

  switch ($op) {
    case 'delete':
      _nodewords_delete($type, $id);
      break;

    case 'insert':
    case 'update':
//      if (user_access('administer meta tags') && isset($object['nodewords'])) {
//        _nodewords_set($type, $id, $object['nodewords']);
//      }
      if (user_access('administer meta tags') && isset($object->nodewords)) {
        _nodewords_set($type, $id, $object->nodewords);
      }
      break;

    case 'form post':
      if (user_access('administer meta tags')) {
        $tags = _nodewords_load($type, $id);
        $output = _nodewords_form($type, $tags);
        return $output;
      }
      break;
  }
}
Robrecht Jacques’s picture

Status: Needs review » Fixed

I have removed "nodewords_taxonomy" for the 4.6 version as drupal 4.6 doesn't support the "form" operation of hook_taxonomy anyway so nothing useful is ever provided to this hook.

Robrecht Jacques’s picture

Status: Fixed » Closed (fixed)