If any of a site's component machine names are "options" or "selected", there will be a collision with the reserved Features arrays (with the same names) used in the component export data.

The problem is in FeaturesEditForm.php:

$component_export['options'][$section] = array();
$component_export['selected'][$section] = array();

If there already is a component with one of these names, PHP issues:

Warning: Illegal string offset 'sources' in Drupal\features_ui\Form\FeaturesEditForm->getComponentList() (line 613 of /path/to/drupal/modules/contrib/features/modules/features_ui/src/Form/FeaturesEditForm.php

...and then:

Fatal error: Cannot use string offset as an array in /path/to/drupal/modules/contrib/features/modules/features_ui/src/Form/FeaturesEditForm.php on line 752

...when clicking on the Create new feature button.

I ran into this because we've got a custom entity with "options" as bundle/machine name.

I'll have a patch for this in a minute.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colan created an issue. See original summary.

colan’s picture

I replaced "options" and "selected" with "_features_options" and "_features_selected" respectively so that they're less likely to clash with anything.

Thanks to dawehner for help in coming up with the plan.

There are some other instances of 'selected' in that file, but I think that they're for a different purpose. In my case, the button now works, and I can't see any related issues on the feature-create form.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect for me! Writing test coverage for that specific bug might be a little hard.

  • nedjo committed 05e3330 on 8.x-3.x authored by colan
    Issue #2639960 by colan, dawehner: Component 'options'...
nedjo’s picture

Thanks, committed.

nedjo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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