Hello all,

This is possibly a quirk of the site I'm working on, but I'm suffering the following 2 fatal PHP errors when trying to configure the Boxes block at admin/build/block/configure/boxes/boxes_add__simple:

Fatal error: Call to a member function get() on a non-object in boxes.module on line 513

On save, I also get this:

Fatal error: Call to a member function save() on a non-object in boxes.module on line 94

The following two adjustments seem to fix the errors to at least make things appear to work, but I'm guessing this might be symptomatic of a deeper issue with the site I'm working on. However, the block configuration is saving fine. While I appreciate I'm an edge case, could these patches be considered for inclusion as they're so simple and shouldn't compromise the module at all?

Many thanks,

Alex

(These patches are for 6.x-1.x-beta9):

boxes.module, line 91

Old:

    case 'save':
      $edit['delta'] = $delta;
      $box = boxes_factory($edit['plugin_key'], $edit);
      $box->save();
      break;

New:

    case 'save':
      $edit['delta'] = $delta;
      $box = boxes_factory($edit['plugin_key'], $edit);
      if (is_object($box)) {
        $box->save();
      }
      break;

boxes.module, line 513:

Old:

function boxes_boxes_load_alter(&$box, $delta) {
  if (module_exists('spaces') && $space = spaces_get_space()) {
    if ($space_box = $space->controllers->boxes->get($delta)) {

New:

function boxes_boxes_load_alter(&$box, $delta) {
  if (module_exists('spaces') && ($space = spaces_get_space()) && is_object($delta)) {
    if ($space_box = $space->controllers->boxes->get($delta)) {

Comments

alexgreyhead’s picture

This is also happening at line 315. Old code:

  if (module_exists('spaces') && $space = spaces_get_space()) {
    $space->controllers->boxes->set($box->delta, $box);
  }
  else {
    $box->save();
  }

New code:

  if (module_exists('spaces') && ($space = spaces_get_space()) && is_object($box)) {
    $space->controllers->boxes->set($box->delta, $box);
  }
  else {
    if (is_object($box)) {
      $box->save();
    }
  }
henrijs.seso’s picture

Status: Needs work » Needs review

more in boxes_context_block_info_alter if spaces module is used. And then some when box is dropped in region after JS saves box content. What would be underlying problem?

henrijs.seso’s picture

Status: Needs review » Needs work

so, accordingly

cmcintosh’s picture

Status: Needs review » Needs work

I am seeing this issue on various spaces when I enable Boxes and go to a page that previous was working is now broken. In order to correct this I edited the block.module and added a check to it for the foreach loop. However if you then go to the overrides control for a space you also get this error.

ttaylor797’s picture

I am getting the same thing with Drupal 6.20, Boxes 6.x-1.0, Chaos tools 6.x-1.8, and Spaces 6.x-3.0.

Here is the dtools output on the WSOD error:

    array(4) {
        ["type"]=>
        int(1)
        ["message"]=>
        string(48) "Call to a member function save() on a non-object"
        ["file"]=>
        string(75) "/home/svn-working/drupal/branches/sites/all/modules/boxes/boxes.module"
        ["line"]=>
        int(94)
    }
    n/a

I will try the above to see if it works.