Looking through features.module, most other functions that implement hook_features_export_render only take two arguments.
I can't wrap my head around exactly what $features_export does, but making it an optional parameter gets rid of the error...

Comments

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new525 bytes

Is this really all it is? Someone who understands the purpose of $features_export, please verify.

Status: Needs review » Needs work

The last submitted patch, rules_814416.patch, failed testing.

tim.plunkett’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
StatusFileSize
new771 bytes

Whoops, svn diff != cvs diff. Trying again.

tim.plunkett’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work

hm, what is it why has it gone away? Maybe the feature API changed? Also probably the default should be more an array? If it's not necessary anymore at all, we can remove the parameter (php is fine if you call it with more parameters).

tim.plunkett’s picture

Two months ago the function was changed from rules_features_export_render to rules_categories_features_export_render. Features doesn't seem to have had any API changes relating to hook_features_export_render().

Also, you're completely correct about the default being an array, not a string.

$features_export seems to be in there solely for exporting "rule_sets". Not sure what that's about.

mstef’s picture

Component: Features integration » Rules Engine
Status: Needs review » Needs work

This was my take at it, as I've written Features integration before.

http://drupal.org/files/issues/rules.export.fixFeatures.patch

I haven't look at comment #3. I don't think my patch will apply cleanly to CVS.

drnugent’s picture

Component: Rules Engine » Features integration
Status: Needs work » Needs review

Changed default value to array. The latest beta of Features still has code that can pass a third parameter so I'm guessing it's best to leave this in and set a default.

drnugent’s picture

Component: Rules Engine » Features integration
Status: Needs work » Needs review
StatusFileSize
new925 bytes

Looks like my patch got eaten last time.

Status: Needs review » Needs work

The last submitted patch, rules_814416b.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new777 bytes

Bad patch format.

drnugent’s picture

Thanks Tim

fago’s picture

Status: Needs review » Fixed

Thanks, indeed features doesn't have such a parameter (any more) and rules doesn't it any more either, so I totally removed that parameter.

Status: Fixed » Closed (fixed)

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

Josh Benner’s picture

Status: Closed (fixed) » Needs work

Removing the 3rd parameter is not technically correct. The hook documentation from the features API file:

/**
 * Component hook. The hook should be implemented using the name ot the
 * component, not the module, eg. [component]_features_export() rather than
 * [module]_features_export().
 *
 * Render one or more component objects to code.
 *
 * @param string $module_name
 *   The name of the feature module to be exported.
 * @param array $data
 *   An array of machine name identifiers for the objects to be rendered.
 * @param array $export
 *   The full export array of the current feature being exported. This is only
 *   passed when hook_features_export_render() is invoked for an actual feature
 *   update or recreate, not during state checks or other operations.
 * @return array
 *   An associative array of rendered PHP code where the key is the name of the
 *   hook that should wrap the PHP code. The hook should not include the name
 *   of the module, e.g. the key for `hook_example` should simply be `example`.
 */
function hook_features_export_render($module_name, $data, $export = NULL) {
  $code = array();
  $code[] = '$mycomponents = array();';
  foreach ($data as $name) {
    $code[] = "  \$mycomponents['{$name}'] = " . features_var_export(mycomponent_load($name)) .";";
  }
  $code[] = "return \$mycomponents;";
  $code = implode("\n", $mycomponents);
  return array('mycomponent_defaults' => $code);
}
tim.plunkett’s picture

The third parameter was re-added a month ago, it seems. After we fixed the issue the first time.

fago’s picture

Status: Needs work » Closed (fixed)
mitchell’s picture

Component: Features integration » Provided Module Integrations

Moving to "Provided Module Integrations" component.