When running drush features-export [feature-name] the existing bundle information is lost and the whole features array in the updated module gets something like features => TRUE (don't know whether that makes any sense).

I think existing bundles should be preserved. A patch will follow.

CommentFileSizeAuthor
#2 2593671.01.patch905 bytesJose Reyero
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jose Reyero created an issue. See original summary.

Jose Reyero’s picture

Status: Active » Needs review
FileSize
905 bytes

Possibly this should be fixed somewhere else in the features generation stack.

This is a quick drush patch that will work unless we are missing features from different bundles.

nedjo’s picture

Thanks for the patch. This is indeed a bug. The basic issue seems to be: the "current" bundle may vary depending on which feature is being exported. This isn't an issue when using the module's UI, because there you first select the bundle and then select one or more features.

We have some relevant methods in FeaturesAssigner, so we could use something along the lines of:

// If any packages exist, determine their bundle.
if ($existing_packages = $manager->listPackageDirectories($packages, $current_bundle)) {
  foreach (array_keys($existing_packages) as $name) {
    $package = $manager->getPackage($name);
    if ($bundle = $assigner->findBundle($package['info'])) {
      $assigner->setBundle($bundle, TRUE);
      break;
    }
  }
}

It looks like that should go earlier in the function, before the line:

  $current_bundle = $assigner->getBundle();

But what if someone tries to export multiple features from distinct bundles? Do we need to determine and set the bundle per feature?

Maybe instead we:

  • Add a --bundle=[bundlename] option.
  • For each feature to be exported, determine the bundle as above and bail with an error message if we find any feature that has a bundle other than the one that's been determined (either a bundle fed in as an option or the default bundle).
Jose Reyero’s picture

Status: Needs review » Needs work

Right, this patch is not really a solution, what I meant in the previous post was "that will work unless we are mixing features from different bundles", it was a typo.

I think this should be fixed better when building the new info file, maybe in FeaturesGenerationMethodBase, by not overriding the 'features' part of the info if a bundle is not specified. Unlike this patch, that would work for mixed bundles too.

I'll post some new patch when I find the time, I just needed a quick solution for drush in the meanwhile.

Jose Reyero’s picture

Status: Needs work » Closed (outdated)

I think this doesn't make too much sense anymore. Testing with latest version, it seems:

- If you don't specify a bundle, it will default to 'default' bundle, the feature just won't be found. Message "The package ignore does not exist."

- If adding the --bundle=bundle_name option, it works, the bundle name is not lost anymore.