$variables = array_diff($variables, array_keys(strongarm_vars_load()));

added in http://drupalcode.org/project/panelizer.git/commit/930e774d12599a3f01787...

strongarm_vars_load "Load all variables (DB and Strongarmed)." which is well, all variables. http://drupalcode.org/project/strongarm.git/blob/refs/heads/7.x-2.x:/str... so that removes all variables, other than one's that don't exist which were already removed by earleir variable_get === null, unset

Features is suppose to not be double exporting, unless set to, so this seems like it can just.. go away

Comments

hefox’s picture

Title: panelizer_features_export_alter isn't suggesting variables » panelizer_features_export_alter wrong hook to use for this/doesn't suggest all variables
StatusFileSize
new2.08 KB

Actually, it's needed because it's the wrong hook to use. The hook to use is one of hook_features_pipe_COMPONENT_alter ones, in this case hook_features_pipe_panelizer_defaults_alter. Export alter isn't reprocessed, which resolves the duplicates, etc.

I really don't get the module_exists strongarm, is there another module defining the 'variables' component that is being swapped out?

mpotter’s picture

Status: Needs review » Reviewed & tested by the community

Yes, this looks like the correct way to handle this with Features.

damienmckenna’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.56 KB

@hefox: Like you said, given that Strongarm is the only (?) module that exports variables, shouldn't the entire logic be based upon whether Strongarm exists?

function panelizer_features_pipe_panelizer_defaults_alter(&$more, $data, $export) {
  foreach ($data as $machine_name) {
    if (module_exists('strongarm')) {
      list ($entity_type, $bundle) = explode(':', $machine_name);

      $variables = array(
        'panelizer_defaults_' . $entity_type . '_' . $bundle,
        'panelizer_' . $entity_type . ':' . $bundle . '_allowed_layouts',
        'panelizer_' . $entity_type . ':' . $bundle . '_allowed_types',
        'panelizer_' . $entity_type . ':' . $bundle . '_default'
      );

      foreach ($variables as $key => $variable) {
        if (variable_get($variable) === NULL) {
          unset($variables[$key]);
        }
      }

      foreach ($variables as $variable) {
        $more['variable'][$variable] = $variable;
      }
    }
  }

  return array();
}
hefox’s picture

Variable isn't name space so it's possible someone has implemented a seperate variable processing thing

However I'm pretty damn certain:
1) Options that do not have a corresponding build are thrown out, so don't need any checking if strongarm exists
2) Variables that are not set are thrown out, so don't need === nulll

So likely all that is needed is something like:

function panelizer_features_pipe_panelizer_defaults_alter(&$more, $data, $export) {
  foreach ($data as $machine_name) {
      list ($entity_type, $bundle) = explode(':', $machine_name);
     $more['variable'][] = 'panelizer_defaults_' . $entity_type . '_' . $bundle,;
     ...
  }
  return  $more
}
damienmckenna’s picture

StatusFileSize
new2.18 KB

So you mean something like this?

damienmckenna’s picture

Status: Needs review » Fixed

I tested it out, it worked fine. Thanks for the help, hefox!

Status: Fixed » Closed (fixed)

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