Hi,

i run into the problem that in some cases ( i have no idea why and at which time ) the features exports the field instance display settings with the field weight value as string and sometimes as integer. Example:

$fields['node-xxx']['field_instance']['display']['weight'] = 14
$fields['node-xxx']['field_instance']['display']['weight'] = '14'

this problem causes in a permanent override status. If someone had a idea where the right place for debugging i keep an eye on it.

thanks
Dennis

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrsimonelliott’s picture

Yeah, I have this exact issue too.

It seems that in table field_config_instance, some fields weights are stored as integers and some fields weight as strings. Features only accommodates weights stored as strings. Whilst the actual weight value corresponds between the db and Feature code, the method of storage is causing feature to be overridden.

From two similar fields in table field_config_instance > data
s:6:"weight";s:1:"5"; == Features is happy with this
vs
s:6:"weight";i:8; == always overridden

YesCT’s picture

Title: Field Instance Export "weight" - brings me in a Override ping/pong » Field Instance Export "weight" - brings me in a Override ping/pong - quotes and no quotes
FileSize
50.08 KB

on my server, the override is without the quotes, and the default (which comes from a feature generated on my laptop localhost MAMP) has the quotes.

'weight' => '6',

vs

'weight' => 6,

screen shot of overrides

Could this be fixed by changing the database... ?

YesCT’s picture

could this be because of a module I added, like that new module had a type for weight were as before, it was not set and was defaulting... I wonder if it would be helpful for us to post what modules we have.

YesCT’s picture

I mentioned local, I'm on a MAMP. The server is on Pantheon.

Here is a drush pm-list

$ drush pm-list
 Package           Name                                        Type    Status         Version       
 Administration    Actions permissions (actions_permissions)   Module  Not installed  7.x-3.0-rc1   
 Administration    Admin (admin)                               Module  Enabled        7.x-2.0-beta3 
 Administration    Content type overview                       Module  Not installed  7.x-1.0-beta2 
                   (content_type_overview)                                                          
 Administration    Filter permissions (filter_perms)           Module  Enabled        7.x-1.0       
 Chaos tool suite  Bulk Export (bulk_export)                   Module  Not installed  7.x-1.1       
 Chaos tool suite  Chaos tools (ctools)                        Module  Enabled        7.x-1.1       
 Chaos tool suite  Chaos Tools (CTools) AJAX Example           Module  Not installed  7.x-1.1       
                   (ctools_ajax_sample)                                                             
 Chaos tool suite  Chaos Tools (CTools) Plugin Example         Module  Not installed  7.x-1.1       
                   (ctools_plugin_example)                                                          
 Chaos tool suite  Custom content panes                        Module  Enabled        7.x-1.1       
                   (ctools_custom_content)                                                          
 Chaos tool suite  Custom rulesets (ctools_access_ruleset)     Module  Not installed  7.x-1.1       
 Chaos tool suite  Page manager (page_manager)                 Module  Enabled        7.x-1.1       
 Chaos tool suite  Page manager existing pages                 Module  Enabled        7.x-1.4       
                   (pm_existing_pages)                                                              
 Chaos tool suite  Stylizer (stylizer)                         Module  Enabled        7.x-1.1       
 Chaos tool suite  Views content panes (views_content)         Module  Enabled        7.x-1.1       
 Core              Aggregator (aggregator)                     Module  Not installed  7.15          
 Core              Block (block)                               Module  Enabled        7.15          
 Core              Blog (blog)                                 Module  Not installed  7.15          
 Core              Book (book)                                 Module  Not installed  7.15          
 Core              Color (color)                               Module  Enabled        7.15          
 Core              Comment (comment)                           Module  Enabled        7.15          
 Core              Contact (contact)                           Module  Not installed  7.15          
 Core              Content translation (translation)           Module  Not installed  7.15          
 Core              Contextual links (contextual)               Module  Enabled        7.15          
 Core              Dashboard (dashboard)                       Module  Enabled        7.15          
 Core              Database logging (dblog)                    Module  Enabled        7.15          
 Core              Field (field)                               Module  Enabled        7.15          
 Core              Field SQL storage (field_sql_storage)       Module  Enabled        7.15          
 Core              Field UI (field_ui)                         Module  Enabled        7.15          
 Core              File (file)                                 Module  Enabled        7.15          
 Core              Filter (filter)                             Module  Enabled        7.15          
 Core              Forum (forum)                               Module  Not installed  7.15          
 Core              Help (help)                                 Module  Enabled        7.15          
 Core              Image (image)                               Module  Enabled        7.15          
 Core              List (list)                                 Module  Enabled        7.15          
 Core              Locale (locale)                             Module  Not installed  7.15          
 Core              Menu (menu)                                 Module  Enabled        7.15          
 Core              Node (node)                                 Module  Enabled        7.15          
 Core              Number (number)                             Module  Enabled        7.15          
 Core              OpenID (openid)                             Module  Not installed  7.15          
 Core              Options (options)                           Module  Enabled        7.15          
 Core              Overlay (overlay)                           Module  Enabled        7.15          
 Core              Path (path)                                 Module  Enabled        7.15          
 Core              PHP filter (php)                            Module  Not installed  7.15          
 Core              Poll (poll)                                 Module  Not installed  7.15          
 Core              RDF (rdf)                                   Module  Enabled        7.15          
 Core              Search (search)                             Module  Enabled        7.15          
 Core              Shortcut (shortcut)                         Module  Enabled        7.15          
 Core              Statistics (statistics)                     Module  Not installed  7.15          
 Core              Syslog (syslog)                             Module  Not installed  7.15          
 Core              System (system)                             Module  Enabled        7.15          
 Core              Taxonomy (taxonomy)                         Module  Enabled        7.15          
 Core              Testing (simpletest)                        Module  Not installed  7.15          
 Core              Text (text)                                 Module  Enabled        7.15          
 Core              Toolbar (toolbar)                           Module  Enabled        7.15          
 Core              Tracker (tracker)                           Module  Not installed  7.15          
 Core              Trigger (trigger)                           Module  Not installed  7.15          
 Core              Update manager (update)                     Module  Enabled        7.15          
 Core              User (user)                                 Module  Enabled        7.15          
 Date/Time         Date (date)                                 Module  Enabled        7.x-2.6       
 Date/Time         Date All Day (date_all_day)                 Module  Enabled        7.x-2.6       
 Date/Time         Date API (date_api)                         Module  Enabled        7.x-2.6       
 Date/Time         Date Context (date_context)                 Module  Not installed  7.x-2.6       
 Date/Time         Date Migration (date_migrate)               Module  Not installed  7.x-2.6       
 Date/Time         Date Popup (date_popup)                     Module  Enabled        7.x-2.6       
 Date/Time         Date Popup Authored (date_popup_authored)   Module  Enabled        7.x-1.1       
 Date/Time         Date Repeat API (date_repeat)               Module  Not installed  7.x-2.6       
 Date/Time         Date Repeat Field (date_repeat_field)       Module  Not installed  7.x-2.6       
 Date/Time         Date Tools (date_tools)                     Module  Not installed  7.x-2.6       
 Date/Time         Date Views (date_views)                     Module  Enabled        7.x-2.6       
 Development       Devel (devel)                               Module  Enabled        7.x-1.3       
 Development       Devel generate (devel_generate)             Module  Not installed  7.x-1.3       
 Development       Devel node access (devel_node_access)       Module  Not installed  7.x-1.3       
 Features          Date Migration Example                      Module  Not installed  7.x-2.6       
                   (date_migrate_example)                                                           
 Features          Features (features)                         Module  Enabled        7.x-1.0       
 Features          **** A Init Site Settings                   Module  Enabled        7.x-1.17      
                   (****_site_settings)                                                             
 Features          **** Contributor Profile (contrib_profile)  Module  Enabled        7.x-1.6       
 Features          **** Entry (****_entry)                     Module  Enabled        7.x-1.6       
 Features          **** Init (****_init)                       Module  Enabled        7.x-1.12      
 Features          **** Workbench (****_workbench)             Module  Enabled        7.x-1.2       
 Features          UUID Services Example                       Module  Not installed  7.x-1.0-alpha 
                   (uuid_services_example)                                            3             
 Fields            Computed Field (computed_field)             Module  Enabled        7.x-1.0-beta1 
 Fields            Fieldgroup (field_group)                    Module  Enabled        7.x-1.1       
 Fields            Link (link)                                 Module  Enabled        7.x-1.0       
 Fields            References dialog (references_dialog)       Module  Enabled        7.x-1.0-alpha 
                                                                                      4             
 Fusion            Apply skins (fusion_apply)                  Module  Not installed  7.x-2.0-beta1 
 Accelerator                                                                                        
 Fusion            Apply skins for pages and regions           Module  Not installed  7.x-2.0-beta1 
 Accelerator       (fusion_apply_rules)                                                             
 Fusion            Apply skins UI (fusion_apply_ui)            Module  Not installed  7.x-2.0-beta1 
 Accelerator                                                                                        
 Fusion            Fusion grid tools (fusion_accelerator)      Module  Not installed  7.x-2.0-beta1 
 Accelerator                                                                                        
 Fusion            Fusion labels (fusion_labels)               Module  Not installed  7.x-2.0-beta1 
 Accelerator                                                                                        
 Fusion            Responsive layouts for IE 6-8               Module  Not installed  7.x-2.0-beta1 
 Accelerator       (fusion_responsive_ie)                                                           
 Input filters     Caption Filter (caption_filter)             Module  Enabled        7.x-1.2       
 Input filters     Image resize filter (image_resize_filter)   Module  Enabled        7.x-1.13      
 Input filters     WYSIWYG Filter (wysiwyg_filter)             Module  Enabled        7.x-1.6-rc2   
 Media             File entity (file_entity)                   Module  Enabled        7.x-1.2       
 Media             Media (media)                               Module  Enabled        7.x-1.2       
 Media             Media Internet Sources (media_internet)     Module  Enabled        7.x-1.2       
 Multilingual -    Rules translation (rules_i18n)              Module  Not installed  7.x-2.1       
 Internationaliza                                                                                   
 tion                                                                                               
 Node Limit        Node Limit (node_limit)                     Module  Enabled        7.x-1.0-alpha 
                                                                                      5             
 Node Limit        Node Limit Interval (node_limit_interval)   Module  Not installed  7.x-1.0-alpha 
                                                                                      5             
 Node Limit        Node Limit Role (node_limit_role)           Module  Not installed  7.x-1.0-alpha 
                                                                                      5             
 Node Limit        Node Limit Type (node_limit_type)           Module  Enabled        7.x-1.0-alpha 
                                                                                      5             
 Node Limit        Node Limit User (node_limit_user)           Module  Not installed  7.x-1.0-alpha 
                                                                                      5             
 Node Limit        Node Limit User of Role                     Module  Enabled        7.x-1.0-alpha 
                   (node_limit_userofrole)                                            5             
 Organic groups    Profile2 group access (profile2_og_access)  Module  Not installed  7.x-1.2       
 Other             Automatic Nodetitles (auto_nodetitle)       Module  Enabled        7.x-1.0       
 Other             Better Formats (better_formats)             Module  Enabled        7.x-1.0-beta1 
 Other             Conditional Stylesheets                     Module  Enabled        7.x-2.1       
                   (conditional_styles)                                                             
 Other             Custom Breadcrumbs (custom_breadcrumbs)     Module  Not installed  7.x-1.0-alpha 
                                                                                      1             
 Other             Diff (diff)                                 Module  Enabled        7.x-2.0       
 Other             Disable messages (disable_messages)         Module  Enabled        7.x-1.1       
 Other             Entity API (entity)                         Module  Enabled        7.x-1.0-rc3   
 Other             Entity tokens (entity_token)                Module  Enabled        7.x-1.0-rc3   
 Other             Libraries (libraries)                       Module  Enabled        7.x-2.0       
 Other             Menu Block (menu_block)                     Module  Enabled        7.x-2.3       
 Other             Menu Block Export (menu_block_export)       Module  Not installed  7.x-2.3       
 Other             Module filter (module_filter)               Module  Enabled        7.x-1.7       
 Other             Panels Breadcrumbs (panels_breadcrumbs)     Module  Enabled        7.x-1.6       
 Other             Pathauto (pathauto)                         Module  Enabled        7.x-1.2       
 Other             Profile2 (profile2)                         Module  Disabled       7.x-1.2       
 Other             Profile2 pages (profile2_page)              Module  Disabled       7.x-1.2       
 Other             Role delegation (role_delegation)           Module  Enabled        7.x-1.1       
 Other             Role watchdog (role_watchdog)               Module  Enabled        7.x-1.0       
 Other             Simple Google Maps (simple_gmap)            Module  Enabled        7.x-1.0-rc1   
 Other             Simplified menu administration              Module  Enabled        7.x-1.0-beta2 
                   (simplified_menu_admin)                                                          
 Other             Strongarm (strongarm)                       Module  Enabled        7.x-2.0       
 Other             TableField (tablefield)                     Module  Enabled        7.x-2.0       
 Other             Token (token)                               Module  Enabled        7.x-1.2       
 Panels            Fieldable Panels Panes                      Module  Enabled        7.x-1.1       
                   (fieldable_panels_panes)                                                         
 Panels            Mini panels (panels_mini)                   Module  Not installed  7.x-3.2       
 Panels            Panel nodes (panels_node)                   Module  Not installed  7.x-3.2       
 Panels            Panelizer (panelizer)                       Module  Enabled        7.x-2.0       
 Panels            Panels (panels)                             Module  Enabled        7.x-3.2       
 Panels            Panels In-Place Editor (panels_ipe)         Module  Enabled        7.x-3.2       
 Pantheon          Pantheon Apache Solr (pantheon_apachesolr)  Module  Not installed                
 Pantheon          Pantheon Platform API (pantheon_api)        Module  Enabled                      
 Responsive        Respond.js (respondjs)                      Module  Enabled        7.x-1.1+4-dev 
 Rules             Rules (rules)                               Module  Not installed  7.x-2.1       
 Rules             Rules Scheduler (rules_scheduler)           Module  Not installed  7.x-2.1       
 Rules             Rules UI (rules_admin)                      Module  Not installed  7.x-2.1       
 Search            Search API (search_api)                     Module  Not installed  7.x-1.2       
 Search            Search facets (search_api_facetapi)         Module  Not installed  7.x-1.2       
 Search            Search views (search_api_views)             Module  Not installed  7.x-1.2       
 Search            Solr search (search_api_solr)               Module  Not installed  7.x-1.0-rc2   
 Search Toolkit    Current Search Blocks (current_search)      Module  Not installed  7.x-1.1       
 Search Toolkit    Facet API (facetapi)                        Module  Enabled        7.x-1.1       
 Services -        UUID Services (uuid_services)               Module  Not installed  7.x-1.0-alpha 
 resources                                                                            3             
 User interface    Wysiwyg (wysiwyg)                           Module  Enabled        7.x-2.1+29-de 
                                                                                      v             
 UUID              Universally Unique ID (uuid)                Module  Enabled        7.x-1.0-alpha 
                                                                                      3             
 Views             Draggableviews (draggableviews)             Module  Enabled        7.x-2.0       
 Views             Views (views)                               Module  Enabled        7.x-3.3       
 Views             Views Bulk Operations                       Module  Enabled        7.x-3.0-rc1   
                   (views_bulk_operations)                                                          
 Views             Views Slideshow (views_slideshow)           Module  Enabled        7.x-3.0       
 Views             Views Slideshow: Cycle                      Module  Enabled        7.x-3.0       
                   (views_slideshow_cycle)                                                          
 Views             Views UI (views_ui)                         Module  Enabled        7.x-3.3       
 Workbench         Workbench (workbench)                       Module  Enabled        7.x-1.1       
 Workbench         Workbench Access (workbench_access)         Module  Disabled       7.x-1.0       
 Workbench         Workbench Files (workbench_files)           Module  Enabled        7.x-1.0       
 Workbench         Workbench Media (workbench_media)           Module  Enabled        7.x-1.0       
 Workbench         Workbench Moderation                        Module  Enabled        7.x-1.2       
                   (workbench_moderation)                                                           
 Core              Bartik (bartik)                             Theme   Enabled        7.15          
 Core              Garland (garland)                           Theme   Disabled       7.15          
 Core              Seven (seven)                               Theme   Enabled        7.15          
 Core              Stark (stark)                               Theme   Disabled       7.15          
 Other             Fusion Core (fusion_core)                   Theme   Disabled       7.x-2.0-beta2 
 Other             Fusion Starter (fusion_starter)             Theme   Disabled       7.x-2.0-beta2 
 Other             Fusion Starter Lite (fusion_starter_lite)   Theme   Disabled       7.x-2.0-beta2 
Blackice2999’s picture

Hi,

please try the patch from #1042088: Feature stuck in overridden state due to buggy hook detection - it fixes that problem. But we need more reviews for mpotter

thanks

mpotter’s picture

Some background on this:

The way Features works is to compare the exportable array currently in code with the same exportable array created from the current db state. To get the "default" value from the code, Features directly calls the default hook function. To get the "normal" value from the DB, Features creates an in-memory export of the current DB and then "evals" it to get the resulting array. Then Features sanitizes the results and uses md5 to compute a "signature" that can be compared.

Because of the "eval" step, a value of (weight = 5) and (weight = '5') result in a match. So if this is the only difference in a feature, the feature will actually show as "Default". It's only when you get another difference that causes the feature to be marked as Overridden that the 5 vs '5' will be displayed in the Diff panel because it's just doing a source-code "diff" for display purposes.

Bottom line is that these kind of differences aren't really "real" and should not cause a feature to be marked as overridden. There is usually some other difference that is really causing the feature to be marked as overridden and the 5 vs '5' is more of a red-herring in the diff output.

Not sure how the patch from 1042088 would have any impact on this, but I'll look into it.

Blackice2999’s picture

Hi mpotter,

thanks for your reply the patch from #5 not solved this problem. I run again into this ping/pong effect. I cant see why it happens and at which point it happend. But after your explain i keep an eye on other changes in the feature.

thanks
Dennis

mpotter’s picture

Yeah, if you get it in the future, post the *complete* list of diffs. The screenshot in this original post was cut off so it's hard to see if there are any other differences.

After reviewing the issue in #1042088: Feature stuck in overridden state due to buggy hook detection I think that would fix this only if you also have another module that is implementing one of the default hooks being used by features. That would cause the feature to be stuck in Overridden and when looking at the Diff tab it would show these 5 vs '5' issues and could confuse people.

I'm going to commit a version of the patch in the other issue since that's definitely a problem, but will leave this issue open in case somebody else runs into a case that can be reproduced reliably.

(btw, the underlying issue is that parts of the core Fields handling stores a string value instead of an integer value in some cases. Probably when the Weight field is read from the field submit form and isn't converted to intval() before saving it into the field_instance array. Features itself is just doing a var_export of the value and has no way to really know that Weight should always be an integer value)

mrsimonelliott’s picture

Hi mpotter,
Since you asked, here is a full diff of a feature suffering this issue. As you can see, the only reason this feature is overridden is because of multiple instances of this problem.
I've experienced this on several project recently.

Legend: 
Code:       drush features-revert will remove the overrides.
Overrides:  drush features-update will update the exported feature with the displayed overrides


Component: field
            'module' => 'text',
            'type' => 'text_default',
<           'weight' => '14',
---
>           'weight' => 14,
          ),
        ),
            'module' => 'text',
            'type' => 'text_default',
<           'weight' => '11',
---
>           'weight' => 11,
          ),
        ),
            'module' => 'text',
            'type' => 'text_default',
<           'weight' => '12',
---
>           'weight' => 12,
          ),
        ),
            'module' => 'text',
            'type' => 'text_default',
<           'weight' => '9',
---
>           'weight' => 9,
          ),
        ),
            'module' => 'text',
            'type' => 'text_default',
<           'weight' => '13',
---
>           'weight' => 13,
          ),
        ),
            'module' => 'list',
            'type' => 'list_default',
<           'weight' => '18',
---
>           'weight' => 18,
          ),
        ),
            'module' => 'link',
            'type' => 'link_default',
<           'weight' => '8',
---
>           'weight' => 8,
          ),
        ),

I have other features on this project which include fields with weights, but they don't display this issue.
Simon

mpotter’s picture

Still not able to reproduce this, with a lot of trying here. My guess is that the feature you show above still has something missing that isn't showing up in the plain code diff. It might help to post the *.info file so we can see exactly what all is being exported in the feature. It's usually something like a module that isn't enabled or some other reason the feature is stuck in the override state.

YesCT’s picture

I have a gut feeling to agree with "My guess is that the feature you show above still has something missing that isn't showing up in the plain code diff."

mpotter’s picture

Status: Active » Closed (cannot reproduce)

OK, in my continued attempt to keep the issue queue here more under control, I'm going to mark this as cannot reproduce for now. But feel free to re-open it if you come up with a case where you can reproduce it for further help.

joachim’s picture

Status: Closed (cannot reproduce) » Active

Getting this too on my features, but I'm not sure how I can help with reproducibility. The features in use on my project have all been through many, many updates so it would be impossible to know exactly how they got to this weights ping-pong state.

Could this be addressed perhaps by forcing field weight when exported to always be one or the other of number or string?

joachim’s picture

Status: Active » Needs review
FileSize
882 bytes

I had a look through my features and I can't see any kind of pattern. I thought at first that the 0 weights were numerical and the non-zero were strings, but that's not the case.

How about this for a fix?

mpotter’s picture

Status: Needs review » Postponed (maintainer needs more info)

Does the above patch cause your feature to be Default instead of Overridden? As I've said, since Features does an eval() on the results, I don't think this is a *real* override difference, it's just a difference in the raw code that Diff is using. But let me know if it really fixes your feature. Seems a bit kludgy but the real problem lies buried somewhere in core I think, so this might be ok for a workaround.

joachim’s picture

> Does the above patch cause your feature to be Default instead of Overridden

It causes it to be overridden because it standardizes all weight values as integers. Re-export the feature one more time so the code & the database agree. After that it's fixed for good.

> I don't think this is a *real* override difference, it's just a difference in the raw code that Diff is using

I'm not sure that's the case. My feature code had some weights as integers, some as strings. I *think* that the field config table's serialized options had a mixture too, but I'm not certain.

cesarmiquel’s picture

We are seeing this exact same issue. I'm attaching a drush fd so that you can see it. I did the following experiment: when I saw the error I corrected by hand the file that was causing the issue until I had only one weight which was different. When I do drush fd I get:

$ drush fd corecsp_content_types
Legend: 
Code:       drush features-revert will remove the overrides.
Overrides:  drush features-update will update the exported feature with the displayed overrides


Component: field
            'module' => 'node_reference',
            'type' => 'node_reference_default',
<           'weight' => 4,
---
>           'weight' => '4',
          ),
          'teaser' => array(

$ drush fl
 Name                      Feature                   Status    State        
...
 Core CSP Content Types    corecsp_content_types     Enabled   Needs review 
...

Now I edited the file and fixed the weight and got:

After removing final diff:

$ drush fd corecsp_content_types
Feature is in its default state. No diff needed.                                                                                                                               $ drush fl
 Name                      Feature                   Status    State      
...
 Core CSP Content Types    corecsp_content_types     Enabled              
...

I think this confirms that this is the only thing that makes the feature overwritten.

Two more things:

  1. We are bouncing the features between developers one of which has php 5.4 while others have php 5.3
  2. We are using features-7.x-1.0 but tested also on the latest dev (7.x-1.1-alpha2+0-dev) and experienced the same issue

I'll try the patch in #14 and see if it works.

Offtopic: 'newbie question': should I change the Version field in the issue to 7.x-1.0 ?

manuelBS’s picture

Patch at #14 solved my problem with weights in field instances export

mpotter’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community
lise.perceives’s picture

Status: Needs work » Reviewed & tested by the community

I have posted 2 versions of a feature, that create this error for me.

http://drupal.org/node/1061178#comment-6762978

I have tested the patch. It works (it no longer reports the problematic feature as overridden). However, now all my other features are reported as overridden ... And revert doesn't work on them. So maybe there should be a step, where existing features are updated when the features module is updated?

Patch + recreate all features works for me, and that's what I ended up doing.

mpotter’s picture

Status: Reviewed & tested by the community » Needs work

Hmm, sounds like this needs more work then. We shouldn't be changing anything that causes all existing features to be marked as overridden. And Features will never automatically update your features since that can cause a lot of sites to break who have made local DB changes and have purposely overridden features.

joachim’s picture

> We shouldn't be changing anything that causes all existing features to be marked as overridden.

I've found that happens fairly often -- or at least, module changes cause later feature updates to show loads of extra cruft that's not related to the actual changes.

lise.perceives’s picture

BTW. When I work with features, I get a lot of these:

Notice: Array to string conversion in EntityAPIControllerExportable->applyConditions() (line 624 of C:\Program Files\BitNami Drupal Stack\apps\drupal\htdocs\profiles\agnitio\modules\contrib\entity\includes\entity.controller.inc).
Notice: Array to string conversion in features_get_orphans() (line 700 of C:\Program Files\BitNami Drupal Stack\apps\drupal\htdocs\profiles\agnitio\modules\contrib\features\features.module).

mpotter’s picture

lise.perceives: please search the issue queue before posting a new issue and never post something like this that is unrelated to the specific issue thread. If it doesn't already exist, create a new issue ticket.

lise.perceives’s picture

I didn't know whether this new behavior was related to this error. However, you're right. This has already been handled in http://drupal.org/node/1514764 .

impleri’s picture

Status: Reviewed & tested by the community » Needs work

@mpotter, is there a reason why this is eval'ing the DB code and comparing the two arrays rather than reading the existing file and comparing it against the file generated from the DB? When I've got a bit of time, I'll try working out a patch unless I hear back that it's already been tried.

lencrockett’s picture

I can confirm this is happening to me on a simple feature. Local site is running MAMP (PHP 5.3.6) and exports string weights, staging server exports integers (PHP 5.3.5). I ran both the complete modules through file merge and found that the only differences were in how the weights were expressed. Simply editing the staging version to remove the single quotation marks did indeed fix the perpetual "Overridden" state. Oddly this only occurred on a single feature whereas others I have created and deployed without issue. Might have to do with one component.

impleri’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
624 bytes

Here's a simple patch against 7.x-2.x-dev HEAD which simply adds intval and floatval routines in features_var_export(). It doesn't necessarily fix the deeper issue, but it does ensure that all exported numerics are integers or floats which should at least keep the values consistent.

danielnolde’s picture

The patch in #28 solves the issue for me and works like a charm, even with features version 1. Thanks!! Hope to see this small but relieving change committed to features soon.

mpotter’s picture

Status: Needs review » Fixed

Cool, that's a much less intrusive solution. I agree that there is probably a deeper issue here that is very dependent on specific components and past database states, but it's going to be nearly impossible to debug and reproduce. So we'll go with fixing the integer Weight values for now. Committed #28 to 3fc3a94.

Status: Fixed » Closed (fixed)

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

jweowu’s picture

Post-patch, I've encountered a features over-ride situation which will make the following change after a drush features-update:

-          'jquery_colorpicker' => '000000',
+          'jquery_colorpicker' => 0,

The string '000000' is a RGB colour (black; another example would be 'jquery_colorpicker' => 'a621a6',), and this all comes from the jquery_colorpicker module.

This seems to point to is_numeric($var) not being a reliable condition if you don't know the purpose to which the value will be put.

Interestingly, the drush features-diff output for the over-ride is:

Component: field
        'default_value' => array(
<         0 => array(
<           'jquery_colorpicker' => 0,
<         ),
---
>         0 => array(),
        ),
jweowu’s picture

Status: Closed (fixed) » Needs work

Maybe it would be enough to verify that when you convert back to a string, you get the same value you started with?

jweowu’s picture

Ack. I generated this patch in the wrong directory. #35 is the correct one.

jweowu’s picture

Status: Needs work » Needs review
FileSize
795 bytes
Anonymous’s picture

Should features really care about what is stored in the field_config* tables? I think there's a case to be made that features should not interfere with whatever FieldAPI decides to stuff in the database - if there's glitches in FieldAPI or contrib around types, they should really be fixed at source. Here's a simple patch that ensures that whatever is exported is stored as the same type by using the identity operator instead of equivalence.

jweowu’s picture

0xdeadbeef: Keep in mind that #28 was committed (albeit still in need of #35 if this approach is retained). My impression is that your patch is intended to replace all of that, so you should also be reverting 3fc3a94.

Anonymous’s picture

If the consensus is that the approach is sound, i'll re-roll with a revert. As it is, the already committed solution is awkward for us as it would mean re-creating a load of features from scratch.

Ronino’s picture

I had issues similar to those described in #32 with the patch from #28. After applying, I get changes like this:

Component: field
        'bundle' => 'my_bundle',
        'default_value' => array(
<         0 => array(
<           'value' => 0,
<         ),
---
>         0 => array(),

This might lead to undesired changes.

However, the patch from #36 worked fine.

mpotter’s picture

I think #36 is a separate issue. The #28 fix that was already committed attempted to deal with exporting values in the correct format based on their data type and applies to all types of features.

#36 just applies to Field exports. For example, #39 describes a case well beyond the simple 14 vs '14' weight issue in the original post. #36 seems like a reasonable idea and should be able to be applied even keeping #28.

So let's get some additional review of this and I'll consider committing it.

jweowu’s picture

Assuming #28 stays committed, then I believe #35 is needed (see #32 and #33 for details), so if #36 is unrelated, that's a bit confusing.

Should #36 be split out into an actual separate issue?

Ronino’s picture

mpotter wrote:

I think #36 is a separate issue. The #28 fix that was already committed attempted to deal with exporting values in the correct format based on their data type and applies to all types of features.

#36 just applies to Field exports. For example, #39 describes a case well beyond the simple 14 vs '14' weight issue in the original post. #36 seems like a reasonable idea and should be able to be applied even keeping #28.

Hmm, I'm not sure. For me, #36 totally fixes the original problem, whereas #28 leads to issues described in #32 and #39. Since applying #36 (and not #28), I don't encounter 14 vs '14' issues any more...

mpotter’s picture

Status: Needs review » Fixed

#36 was actually already handled in a similar patch in #2088771: Unable to update a field/field_instance/field_base when equality operator things not-same arrays are the same commit 70daa4a.

I committed #35 in 78772d5.

Status: Fixed » Closed (fixed)

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

PawelR’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

Hi,
I would like to reopen this issue because I don't think it's fixed properly.
The way how it tries to fix this problem introduces a serious bug.
It converts numeric strings like "0" (returned by from field_info_instance() for example) to integers and these integers are getting written in to the various database configuration tables when features gets reverted.
Unfortunately this breaks Drupal core in at least two places:
https://www.drupal.org/node/2248129
https://www.drupal.org/node/2298975

I think this code:

else if (is_numeric($var)) {
    $floatval = floatval($var);
    if (is_string($var) && ((string) $floatval !== $var)) {
      // Do not convert a string to a number if the string
      // representation of that number is not identical to the
      // original value.
      $output = var_export($var, TRUE);
    }
    else {
      $output = $floatval;
    }
}

should be removed asap from features_var_export() function.

joachim’s picture

I don't know if this is related or not, but I've just made a feature that I'm using to define a view for a test case. I added 'hidden = TRUE' to the feature's info file, and I've just rerolled it for a change to the view, and now the diff shows this:

-hidden = TRUE
+hidden = 1

  • mpotter committed 3fc3a94 on 8.x-3.x
    Issue #1721926 by joachim, impleri | Blackice2999: Fixed Field Instance...
  • mpotter committed 78772d5 on 8.x-3.x
    Issue #1721926 by jweowu, joachim, impleri, 0xdeadbeef | Blackice2999:...
joachim’s picture

I've just noticed something that might or might not be relevant :)

ctools_var_export() and features_var_export() more or less do the same thing, but differ in their handling of integer values: features_var_export() ensures they are written to code as integers, whereas ctools_var_export() quotes them as strings.

Might it be that somehow in some circumstances the other export function is used? Eg, on creating the feature one is used, and on feature update the other?

kenorb’s picture

Status: Needs work » Closed (fixed)

Fixed as per #43. If there is any other issue, please raise the new ticket.