Fatal error: Unsupported operand types in /home/hsphere/local/home/eapprais/dast2dast.org/modules/category/category.module on line 562

This happens when I try to edit a container.

Comments

kappaluppa’s picture

is was lines 555 - 562

          if (!isset($form['categories'][$containers[$curr]->cid]['#ahah'])) {
            $form['categories'][$containers[$curr]->cid] += array(
              '#ahah' => array(
                'path' => 'category/js/distant/'. $containers[$curr]->cid .'/'. $containers[$cand]->cid,
                'wrapper' => 'edit-category-'. $containers[$cand]->cid .'-wrapper',
                'effect' => 'slide',
              ),
            );

Based on a thread with same error for the messaging module, http://drupal.org/node/451638, I tried removing the + at
$form['categories'][$containers[$curr]->cid] += array(

The problem went away in such I don't get the error anymore. In the other issue for messaging it was determined that the + was not a typo, but necessary. I've yet to find out what happens as a result of removing the +

Still need an answer on this...

JirkaRybka’s picture

What happens after the '+' removal on php-level is, that you're replacing the $form['categories'][cnid] data instead of adding to it, i.e. you have the #ahah part added just fine and working, but you're now removing anything what's already in there, so something else may be missing now *in other cases*. Reading the linked other issue, I see that this may be caused by the array element being previously empty/unset, which in turn might be some sort of a misconfiguration somewhere. I don't know more details for now (no time to examine, sorry) - the question is why the element would be empty, or what's possibly already there (if anything), or whether this was just some unnecessary copy-paste/best-practice thing, and also why it fails in your setup while it worked fine on many others (including mine). The answer to the last question is most probably a different config, the rest needs a bit of research.

A dirty fix might be something like (untested):
$form['categories'][$containers[$curr]->cid] = (array) $form['categories'][$containers[$curr]->cid] + array( ....
It casts the pre-existing data to an array type explicitly prior to the addition, hopefully removing the problem at hand (but not its source).