Hello, I just wanted to report that I am getting this error message on a fresh install of Drupal.

Notice: Undefined variable: type in spaces_init() (line 810 of /home/quickstart/websites/cmf.dev/profiles/cmfspaces/modules/contrib/spaces/spaces.module).

I think it can be easily fixed by changing line 810

// If the space is incorrect, reroute.
  if ($type && !spaces_is_spaces_object($type, $object)) {
    spaces_router($type, $object);
  }

to

// If the space is incorrect, reroute.
  if (isset($type) && !spaces_is_spaces_object($type, $object)) {
    spaces_router($type, $object);
  }

Comments

markwk’s picture

Similar issue popping up for me. Spaces is an awfully complicated beast so love to hear a maintainer comment on this one before add...

fuzzy76’s picture

I'm seeing this too, both on page loads and on drush invocations.

fuzzy76’s picture

By looking at the code (this happens right before $type is references), I am wondering if both if's fails to trigger. In that case, $type will not be defined at all. Unfortunately, I don't understand the code good enough to propose a solution. The other alternative is that the foreach doesn't get anything to iterate through.

  if ($object = menu_get_object()) {
    $type = 'node';
  }
  // user has various load functions
  elseif (($item = menu_get_item()) && isset($item['map'])) {
    foreach (array_filter($item['map'], 'is_object') as $object) {
      $type = isset($object->nid) ? 'node' : (isset($object->uid) ? 'user' : NULL);;
      break;
    }
  }
Grayside’s picture

Status: Active » Needs work

I think #0 in the form of a patch is the right way to go.

dellintosh’s picture

StatusFileSize
new406 bytes

Patch attached.

Have a great day!
-dellintosh

Grayside’s picture

Status: Needs work » Needs review
dellintosh’s picture

similar to the above, we should probably be checking for the existence of the 'buttons' key in the $form array too.

Patch for that is attached below.

Grayside’s picture

If it's the same issue, there is one patch. Otherwise, two issues please.

patricksettle’s picture

Status: Needs review » Closed (fixed)

Reviewed #5 checks out and has been committed

Commit 9472223 on 6.x-3.x