I have updated from from 7.x-2.0-beta13 to 7.x-2.0-beta19 and got this error:

PHP Fatal error: Call to a member function isMultiPlugin() on a non-object in /home/user/www/***/sites/all/modules/crumbs/lib/PluginSystem/PluginEngine.php on line 138

Downgrading to beta18 and beta17 didn't helped, so i have to go back to the beta13.
Core - 7.31

Comments

donquixote’s picture

Which PHP version?

proxima8’s picture

5.3.8-2

proxima8’s picture

Yet beta16, 15 and 14 make the same error to

donquixote’s picture

Hi!
Sorry, I was quite busy today with client work.
The place to debug this is the class crumbs_PluginSystem_PluginMethodIterator.
As a typical iterator, this class has a current() method and a valid() method.
The current() method returns the value of the foreach(). If the valid() method returns FALSE, the loop stops.

Looking at the code, it seems as if the current() method should always return an object, if the valid() method previously returned TRUE.

Btw one of the docblock comments in PluginEngine is wrong, it should be

    /**
     * @var string $plugin_key
     * @var crumbs_PluginSystem_PluginMethodIteratorPosition $position
     */
    foreach ($iterator as $plugin_key => $position) {

So the $position is not a PluginMethodIterator, but a PluginMethodIteratorPosition.
But this docblock is not the cause of the error, obviously.

donquixote’s picture

Of course we could make the valid() method more solid, like this:

  public function valid() {
    return isset($this->pluginKey) && isset($this->iteratorPosition);
  }

But it would be weird if $this->pluginKey is not NULL, while $this->iteratorPosition is NULL.

lpedretti’s picture

I just prepended if (!is_object($position)) continue;
The error appeared to me after i disabled the '*' plugin.

donquixote’s picture

Status: Active » Fixed

Fixed with http://cgit.drupalcode.org/crumbs/commit/?id=c1fcedb84f2a000e30dc62d0370...

This should really fix the issue, but it does not really explain what goes wrong in the iterator.
I thought for a moment that it is the confusion of FALSE vs NULL in crumbs_PluginSystem_PluginMethodIterator::setFirstValidIteratorPosition(). But this really can't be it. Whenever the pluginKey is something other than NULL, the iteratorPosition will be an object.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.