Happens a lot on admin/build/features/manage

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Status: Active » Needs review
FileSize
1.47 KB
hefox’s picture

Status: Needs review » Needs work

Don't have strict enabed

+++ b/includes/features.content.inc
@@ -148,11 +148,13 @@ function content_features_rebuild($module) {
+      $existing_instance = array_shift($read);

Would reset be better here?

+++ b/includes/features.content.inc
@@ -148,11 +148,13 @@ function content_features_rebuild($module) {
+      unset($read);

Is this unset really worth it? If continue with the array_shift instead of reset, it's just an empty array leftover. It's fairly non-standard to do, tmk.

+++ b/includes/features.content.inc
@@ -167,7 +169,7 @@ function content_features_rebuild($module) {
         // Summary: content_field_instance_create() will fall back to prior
-        // instance values for weight, label, desc if not set. 
+        // instance values for weight, label, desc if not set.

Unrelated white space

mikeytown2’s picture

White space fixes happen automatically by my editor.

If an empty array is all that is left (array that has one value), why not access the existing instance via the known key; or are the keys unknown (why not use key() then)? I did an unset because we don't use the variable after extracting what we want from it; I didn't know the size of whats left thus the use of unset to make sure memory usage doesn't get out of control.

Use this on your dev environment.

  // Report all php errors.
  error_reporting(-1);
hefox’s picture

Need to fix the whitespace in features, but coding standard issues should generally not be part of an unrelated patch.

The function should only be returning an array with one item given the parameters sent to it (there should only be one field per field_name/type), so just need to get that one element in that array, thus array_shift leaves an empty array when it's done.

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
1.45 KB

Here's a patch without unset.

hefox’s picture

Status: Needs review » Fixed

Thanks

Status: Fixed » Closed (fixed)

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