admin/config/development/configuration/features

PHP error

8.x-3.0-alpha5

Recoverable fatal error: Argument 1 passed to Drupal\features\FeaturesAssigner::setCurrent() must implement interface Drupal\features\FeaturesBundleInterface, null given, called in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 414 and defined in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 242 request_id="v-36e6b364-acc3-11e5-a506-22000a880cb5"

8.x-3.x

Recoverable fatal error: Argument 1 passed to Drupal\features\FeaturesAssigner::setCurrent() must implement interface Drupal\features\FeaturesBundleInterface, null given, called in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 404 and defined in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 232 request_id="v-29b09202-acc1-11e5-9cb0-22000a880cb5"

white screen of death, wsod

The website encountered an unexpected error. Please try again later.

Cannot access the Features tab in Configuration Synchronization tab.

Comments

jacov created an issue. See original summary.

jacov’s picture

and it looks like it is broken in drush8 as well...

user@server:/$SITEROOT/docroot/modules$ drush8 fd myfeature

Fatal error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 126
Drush command terminated abnormally due to an unrecoverable error.                                                                                                   [error]
Error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php,
line 126
jacov’s picture

errors on the following commands as well...

user@server:/$SITEROOT/modules/modules$ drush8 fs

Fatal error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 126
Drush command terminated abnormally due to an unrecoverable error.                                                                                                   [error]
Error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php,
line 126
user@server:/$SITEROOT/modules$ drush8 features-components

Fatal error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php on line 126
Drush command terminated abnormally due to an unrecoverable error.                                                                                                   [error]
Error: Call to a member function getEnabledAssignments() on a non-object in /$SITEROOT/modules/features/src/FeaturesAssigner.php,
line 126
jacov’s picture

looks like this is the code that is failing...

  /**
   * Gets enabled assignment methods.
   *
   * @return array
   *   An array of enabled assignment methods, sorted by weight.
   */
  public function getEnabledAssigners() {
    $enabled = $this->currentBundle->getEnabledAssignments();
    $weights = $this->currentBundle->getAssignmentWeights();
    foreach ($enabled as $key => $value) {
      $enabled[$key] = $weights[$key];
    }
    asort($enabled);
    return $enabled;
  }

$enabled is a non-object and getEnabledAssignments() is struggling

...diving deeper...

jacov’s picture

Version: 8.x-3.0-alpha5 » 8.x-3.x-dev
Assigned: Unassigned » jacov
StatusFileSize
new15.15 KB

uploading patch to fix the multiple fatal php errors caused by bundle variables not being set properly. fixes white screen of death and fixed drush8

jacov’s picture

StatusFileSize
new16.53 KB
jacov’s picture

Assigned: jacov » Unassigned
Status: Active » Needs review

@nedjo && @dawehner && @mpotter please review patch #6 attached.

fixes multiple fatal errors including drush.

main issue was that variable $bundle was being initiated based on null objects and not being checked. i added conditional statements to check and set null where applicable.

Status: Needs review » Needs work

The last submitted patch, 6: features-fix-multiple-php-fatal-errors-bundle-2641146-5.patch, failed testing.

nedjo’s picture

Status: Needs work » Postponed (maintainer needs more info)

@jacov: Thanks for posting. I can't reproduce the issue. Can you please provide steps to reproduce this error from a clean install?

jacov’s picture

@nedjo sure...

create a Feature bundle, in my case i created a Feature that exports my custom content type & its related views.

then download this feature through the web interface, and put the extracted archive in your /modules folder.

this should put you in the state to reproduce the errors.

(in a few versions back, before converting to objects?, i was able to see the new module / feature the features gui and use the Write button, now that doesn't work, but at least the patch gets me passed the wsod errors)

also, once you have your feature in your /modules dir, you can run the drush8 commands to see the error too.

user@server:/$SITEROOT/docroot/modules$ drush8 fd myfeaturizedmodule

drush8 features-components

drush8 fs

nedjo’s picture

I followed those steps starting with a clean install of core 8.0.1 and of the current Features dev but couldn't reproduce the issue. Please ensure you're starting with a fresh install of core and Features (in particular, that you have not updated from any previous version of Features) and list exactly the steps you've taken to reproduce the error. Thanks.

nedjo’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing due to lack of response, but please feel free to reopen with new information. Thanks.

arh1’s picture

For posterity, I saw this error when I'd enabled Features, created a Bundle and Feature and deployed them, but failed to deploy related core config (in my case, features.settings.yml and features.bundle.mybundle.yml).

sandboxpl’s picture

Status: Closed (cannot reproduce) » Active
StatusFileSize
new640 bytes

I was struggling with the same problem for a long time on project where features module was used since very long and updated continously.
For some reason I did get stucked with 8.x-3.x versions, I was unable to revert my features with drush, and to visit features admin page.

PHP Fatal error:  Call to a member function getEnabledAssignments() on a non-object in modules/contrib/features/src/FeaturesAssigner.php on line 127
Error: Call to a member function getEnabledAssignments() on a non-object in modules/contrib/features/src/FeaturesAssigner.php, line 127

After debugging the code I've found that FeaturesAssigner is trying to use FeaturesBundleInterface::DEFAULT_BUNDLE constant and set default bundle, for features which are not assigned to any other bundle.
Then I've started to look for corresponding config object for features.bundle.default and for some reason it was missing, even in config table.

To restore that config object I had to reimport contents config/install/features.bundle.default.yml file, module reinstallation would wor kas well, but I was unable to go this way,
so I've used following code to consume single config file and write it into config storage again:

$config_path = drupal_get_path('module', 'features') . '/config/install';
$source = new \Drupal\Core\Config\FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$config_storage->write('features.bundle.default', $source->read('features.bundle.default'));

After restoring default bundle, everything works well and I can find this bundle in config table again

mysql> select collection,name from config where name like 'features.bundle%';
+------------+-------------------------+
| collection | name                    |
+------------+-------------------------+
|            | features.bundle.default |
+------------+-------------------------+
1 row in set (0.00 sec)

I've went through the repository, and I've found that this config wile was added with tag 8.x-3.0-alpha6
http://cgit.drupalcode.org/features/commit/?h=8.x-3.x&id=731b97fddf1ee04d836dc1d1b131881b39494b2f

The question is - is it possible that this config file is not getting installed for project with features module used since old version like 8.x.2-x ?
Maybe we should have some update hook in v 8.x-3.x to make sure default bundle exists? Example patch attached

nedjo’s picture

Category: Bug report » Support request
Priority: Critical » Normal
Status: Active » Fixed

This looks like a support request that was answered. Please feel free to reopen if otherwise.

Status: Fixed » Closed (fixed)

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