Problem/Motivation

Attempting to generate features for a bundle for which the configuration option "Include install profile" is selected triggers the following error:

Failed to package %package_name. Package not found.

Steps to reproduce:

  • From a fresh Drupal standard install with the Features module installed, navigate to admin/config/development/configuration/features/bundle and create a new bundle, checking the box "Include install profile".
  • Click the Features tab to navigate to admin/config/development/configuration/features. The error appears.

Cause of error: Previously, the profile was a structured array property of the FeaturesManager object. Refactoring moved profile handling to the FeaturesBundle object. However, the code section in FeaturesManager::assignConfigPackage() that conditionally assigns config to a profile has not been updated and still references the now removed FeaturesManager::profile property:

    // Determine whether the profile is requested.
    $profile =& $this->profile;
    if ($package_name == $profile['machine_name']) {
      $package =& $profile;
    }

Proposed resolution

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpotter’s picture

Here is a patch that removes the old profile code you mentioned. Also does a simple refactoring in the AssignmentProfile plugin that will ensure the package exists.

However, I need real help here in testing how this is supposed to work. I haven't used the Profile creation stuff myself.

When the Bundles were added, I moved the Profile options into the Bundle settings. I think this makes sense, but I'm not sure having a package named for the profile itself still makes sense. I think something else is still confusing here.

mpotter’s picture

Status: Active » Needs review
mpotter’s picture

Status: Needs review » Needs work
mpotter’s picture

Status: Needs work » Needs review

Hrm, is something wrong with the testbot?

nedjo’s picture

Some quick background here.

Previously (in config_packager), the profile wasn't itself a package (that is, it wasn't part of the packages array), but was modelled similarly to packages, in a structured array that included the same keys. So, for example, files could be added to the profile, including configuration files, and the profile could be regenerated like a package.

This seems to have been lost in the conversion of profile handling to bundles.

mpotter’s picture

Right. The old code for handling profiles was pretty patchy (similar to packages, but not quite). Moving it into bundles makes sense, but I think we just need to check the file generation. When exporting a feature that belongs to a profile bundle it should be adding the profile files if they don't yet exist. I think I understand the background...just need help getting the new bundle system to work for exporting features as profiles from somebody that understands that use-case. It's not something I ever expected to use Features for since a profile is a lot more than just a set of files and packages. Even Drupal is a bit confusing with profiles being treated as a kind of module/extension.

Can config be added to themes? If so, maybe we need a higher-level handling of "Extensions" rather than modules to handle all the types of things config can be added to.

I've committed the patch in #1 just to remove the old code that isn't used, but keeping this open to figure out how to better handle profiles.

  • mpotter committed 31ca478 on 8.x-3.x
    Issue #2494763 by mpotter: Error on generating features when "Include...
nedjo’s picture

Assigned: Unassigned » nedjo
Status: Needs review » Active

I'll have a look at what's left to do here.

nedjo’s picture

Status: Active » Needs review
FileSize
14.05 KB
nedjo’s picture

FileSize
14.05 KB

These changes are fairly extensive.

Background: in Configuration Packager, before it was merged into Features, I modelled the install profile separately from packages. Earlier in this issue, @mpotter began the work of refactoring so that the install profile is a special-cased package. This patch aims to compete that work.

The intended functionality is: when generating features, a site admin can choose whether to package them in an install profile. If this option is selected, generated features will be nested in 'profiles/[profilename]/modules'. If in addition the 'Profile' assignment plugin is enabled, a package will be generated for the install profile. If the install profile didn't already exist, it will be created drawing on code from core's standard install profile, including:

  • Adapted code from standard.profile and standard.install, providing, ideally, a working install profile.
  • Any configuration required by the code in standard.profile or standard.install. If this code has already been assigned to a feature, a dependency is created instead on that feature.
  • Configuration from standard.info.yml including module and theme dependencies.

Currently, a number of issues are presenting, which this patch attempts to address:

  • Two versions of the install profile are generated, in distinct directories (neither the correct one).
  • The install profile is created with type: module in its info file rather than type: profile.
  • The adapted versions of standard.profile and standard.install are not generated.

Minor updates to the previous patch (better reuse of new method FeaturesBundle::isProfilePackage()).

nedjo’s picture

Explanation of some of the changes:

  1. +++ b/modules/features_ui/src/Form/FeaturesExportForm.php
    @@ -420,7 +420,7 @@ class FeaturesExportForm extends FormBase {
    +      '#title' => array('#markup' => Xss::filterAdmin($package['description'])),
    

    Unrelated filtering fix.

  2. +++ b/modules/features_ui/src/Form/FeaturesExportForm.php
    @@ -469,20 +469,6 @@ class FeaturesExportForm extends FormBase {
    -    if (!$current_bundle->isDefault()) {
    -      // Assign the selected bundle to the exports.
    -      $packages = $this->featuresManager->getPackages();
    -      foreach ($package_names as $index => $package_name) {
    -        // Rename package to use bundle prefix.
    -        $package = $packages[$package_name];
    -        unset($packages[$package_name]);
    -        $package['machine_name'] = $current_bundle->getFullName($package['machine_name']);
    -        $package['bundle'] = $current_bundle->getMachineName();
    -        $this->featuresManager->savePackage($package);
    -        $package_names[$index] = $package['machine_name'];
    -      }
    -    }
    -
    

    Since the renaming needs to happen via Drush as well as via the UI, moved this segment from the form to FeaturesGenerator::setPackageBundleNames().

  3. +++ b/src/FeaturesGenerator.php
    @@ -126,10 +126,41 @@ class FeaturesGenerator implements FeaturesGeneratorInterface {
    +      $this->featuresManager->setPackages($packages);
    

    Need to reset the full packages array so that deletions are registered.

  4. +++ b/src/FeaturesManager.php
    @@ -249,7 +249,6 @@ class FeaturesManager implements FeaturesManagerInterface {
    -      $this->addPackageFiles($package);
    

    We don't need to add files until just before generating.

  5. +++ b/src/FeaturesManager.php
    @@ -751,15 +750,12 @@ class FeaturesManager implements FeaturesManagerInterface {
    -    unset($package['files']);
    

    An assignment plugin should be able to add files. Unsetting the files here removed files added by the profile assignment plugin.

  6. +++ b/src/Plugin/FeaturesGeneration/FeaturesGenerationArchive.php
    @@ -102,14 +102,6 @@ class FeaturesGenerationArchive extends FeaturesGenerationMethodBase {
    -    // Add the Profile.
    -    if (isset($bundle) && $bundle->isProfile()) {
    -      $profile_package = $this->featuresManager->getPackage($bundle->getProfileName());
    -      if (!empty($profile_package)) {
    -        $this->generatePackage($return, $profile_package, $archiver);
    -      }
    -    }
    

    This was the source of duplicate profiles being generated. We no longer need to handle the profile separately since it's handled as one of the packages.

  • nedjo committed fe5989b on 8.x-3.x
    Issue #2494763 by nedjo, mpotter: Error on generating features when "...
nedjo’s picture

Status: Needs review » Fixed

This completes the bulk of the refactoring. If and as further bugs show up we can open new issues.

The last submitted patch, 9: features-profile-2494763-9.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 10: features-profile-2494763-10.patch, failed testing.

nedjo’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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