Hi,

I just installed features_override. My site has a feature (Features 1.0) which includes strongarmed variables (Strongarm 2.0).

I change one of these variables, Features and sees that my feature is overridden. However, when I go to "features-override/add", I'm told "No overridden components found.".

The variable that is overridden is a serialized array (if that matters).

Interestingly, I also warned that:

The following overridden view(s) are provided by other modules: company_news. To resolve this problem either revert each view or clone each view so that modified versions can be exported with your feature.

(company_news does not have any overridden components, and is also not the feature that contains the overridden variable - so not sure if it's related to the problem or not)

Really looking forward to trying this module. Thanks!

Comments

nedjo’s picture

Thanks for the report. I tested this (in D7) and it seemed to work. Steps I took:

* Install Debut Article feature.
* Edit the node options for the Article content type, setting the default state to unpublished.
* Return to the Override overview page. The node_options_article variable appears for selection.

Pls install Diff, if you don't already have it, and then click the "Review overrides" tab for the feature you've overridden and paste here the diff.

ryan_courtnage’s picture

StatusFileSize
new58.03 KB

Discovered something interesting while doing this. Some of my overrides are detected, but not the one involved in my original report.

Here's the current diff:

$ drush -l local.site.com features-diff site_core

Component: variable
          ),
          'talent_portfolio' => array(
<           '0' => 2,
---
>           '0' => 1,
>           '1' => 2,
          ),
        ),
      'api_version' => 1,
      'name' => 'preprocess_css',
<     'value' => '1',
---
>     'value' => '0',
    ),
    'preprocess_js' => array(
      'api_version' => 1,
      'name' => 'preprocess_js',
<     'value' => '1',
---
>     'value' => '0',
    ),
    'site_403' => array(

You'll see in the attached screenshot, that the overrides to preprocess_css and preprocess_js are detected. However, the third override is not detected.

As I mentioned, the difference is to a variable that is a serialized array (and it's a fairly big one too). It's the variable content_access.module uses to store it's per-content-type access settings. Below is what I currently have in the feature's .strongarm.inc file. I've commented where the diff occurs:

  $strongarm = new stdClass;
  $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
  $strongarm->api_version = 1;
  $strongarm->name = 'content_access_settings';
  $strongarm->value = array(
    'view' => array(
      'company_news' => array(
        0 => 2,
      ),
      'gift_card' => array(),
      'how_to' => array(
        0 => 2,
      ),
      'static' => array(
        0 => 2,
      ),
      'talent_match' => array(
        0 => 2,
      ),
      'stock_gift_card_image' => array(
        0 => 2,
      ),
      'webform' => array(
        0 => 2,
      ),
      'talent_fact' => array(
        0 => 2,
      ),
      'talent_portfolio' => array(   /******  This is where the diff/override is   *******/
        0 => 2,
      ),
    ),
    'view_own' => array(
      'company_news' => array(
        0 => 2,
      ),
      'gift_card' => array(),
      'how_to' => array(
        0 => 2,
      ),
      'static' => array(
        0 => 2,
      ),
      'talent_match' => array(
        0 => 2,
      ),
      'stock_gift_card_image' => array(
        0 => 2,
      ),
      'webform' => array(
        0 => 2,
      ),
      'talent_fact' => array(
        0 => 2,
      ),
      'talent_portfolio' => array(
        0 => 2,
      ),
    ),
    'per_node' => array(
      'company_news' => 0,
      'gift_card' => 0,
      'how_to' => 0,
      'static' => 0,
      'talent_match' => 0,
      'stock_gift_card_image' => 0,
      'webform' => 0,
      'talent_fact' => 0,
      'talent_portfolio' => 0,
    ),
    'priority' => array(
      'company_news' => '0',
      'gift_card' => '0',
      'how_to' => '0',
      'static' => '0',
      'talent_match' => '0',
      'stock_gift_card_image' => '0',
      'webform' => '0',
      'talent_fact' => '0',
      'talent_portfolio' => '0',
    ),
  );
nedjo’s picture

Thanks for the extra info. Don't immediately know why this isn't showing up. I vaguely recall an edge case involving an array with a single key of zero. I'll try to dig it up if I get a chance.

ryan_courtnage’s picture

After tracing through the code, I did indeed find a problem that will occur with the first key of indexed arrays (0).

In features_override.module:198, there is the following:

    if (in_array($key, array('content_has_extra_fields', FEATURES_OVERRIDE_RECURSION_MARKER))) {
      return;
    }

When my strongarm variable export (which contains an indexed array) is processed, this condition will return TRUE for key 0.

Looking at php.net, you'll see several people warning about in_array() not using strict comparisons, and how this can cause problems with 0: http://ca3.php.net/in_array

Seeing how this condition is really only looking for specific strings in $key (contains 'content_has_extra_fields' or 'features_override_recursion_marker'), it might be reasonable to cast $key to a string:

    if (in_array((string) $key, array('content_has_extra_fields', FEATURES_OVERRIDE_RECURSION_MARKER))) {
      return;
    }

This change fixes the problem with my override not being detected. There are probably other ways to skin the cat as well...

Ryan

ryan_courtnage’s picture

Title: Strongarm variable override not detected » Strongarm variable with indexed array - override not detected
Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.1 KB

Problem duplicated with -dev branch. Patch attached.

nedjo’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch, thanks! Will apply soon.

BarisW’s picture

Is this the same for the D7 version? I seems that my overridden variables are not being detected as well.

firflant’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev

Tested with various variables on D7. Did not work. This module is not compatible with Strongarm on D7?

What i really did:

1. Created and enabled the first feature with variable set to "0".
2. Created and enabled the second feature overriding this variable to "2".

After this both of them are overriden and variable in fact has value "0". Diff curiously shows that the first feature has a value "2" overriden to "0"

  'name' => 'comment_aktualnosci',
- 'value' => '2',
  ),

  'name' => 'comment_aktualnosci',
+ 'value' => '0',
  ),

and the second feature has "2" overriden to a blank line

- array(
- 'variable.comment_aktualnosci.value' => '2',
- )

+ array()

3. If I revert the first feature now - variable will have the proper overrriden value "2" and everything will be shown as default, so as it should be without reverting the parent feature, which in some cases can be unwanted.

I hope it help to find out a solution.

mpotter’s picture

Status: Reviewed & tested by the community » Needs work

Moving this back to "Needs work" for the 7.x-2.x branch since there is no patch posted for that version yet.

marttir’s picture

Status: Needs work » Needs review

Thanks @ciss, the #1 patch from that issue seems to fix problems with override detection / reverting features when Strongarm variables are overridden with Features Override.