I'm encountering some strange behavior. Not sure whether this should be in the entity or features queue. My features module is 7.x-1.0-beta3.

I have an entity of custom type "datasource" that I've added to a feature. I exported the feature to code and the features UI shows that the datasource entity in the feature has status "default". Editing the entity (modifying the name, for example) results in the features UI showing the entity as "overridden". So far so good. Upon reverting the entity (via either the features UI or drush), the entity still shows as "overridden" in the features UI. Worse, the entity is no longer in the database! For some reason, reverting the entity deletes it.

Any ideas? Thanks!

CommentFileSizeAuthor
#12 1211272-save-component-on-revert.patch519 bytesJosh Waihi
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jdleonard’s picture

Priority: Normal » Major

One more tidbit: the module database field for the entity is NULL even after exporting to code.

jdleonard’s picture

I'm pretty new to features (and entity). Looks like module = NULL is normal in this case.

Looks like this problem was encountered with views too. Perhaps a similar fix needs to be applied to entity?
#1157048: Feature-packages appear overridden when they are not

jdleonard’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta10
Status: Active » Closed (cannot reproduce)

This appears to be fixed in beta10 :)

jdleonard’s picture

Status: Closed (cannot reproduce) » Active

Strike that. It just happened again. I haven't been able to nail down good repro steps.

klausi’s picture

Status: Active » Postponed (maintainer needs more info)

Sounds like your entity does not exist in code anymore? If you revert an entity it gets deleted from the DB and newly imported via the default() hook. If that default hook is not present anymore the entity of course vanishes.

jdleonard’s picture

Status: Postponed (maintainer needs more info) » Active

I wish it were that simple, but the entity definitely still exists in code. Re-installing the module gets it back in the database as expected. I don't know where to begin debugging this.

klausi’s picture

Where do you define your entity? You should use hook_default_YOUR_ENTITY_TYPE_NAME()
Could you post the code?

jdleonard’s picture

entity: tbm_school

/**
 * Implementation of hook_default_tbm_school().
 */
function tbm_default_tbm_school() {
  $items = array();
  $items['rice_university'] = entity_import('tbm_school', '{
    "machine_name" : "rice_university",
    "name" : "Rice University",
    "url" : "http:\\/\\/www.rice.edu",
    "nickname" : "Rice",
    "email_domains" : "rice.edu",
    "sponsors" : "Rice University Student Association",
    "sponsor_urls" : "http:\\/\\/sa.rice.edu",
    "enabled" : "1",
    "listed" : "1",
    "rdf_mapping" : []
  }');
  $items['test_college'] = entity_import('tbm_school', '{
    "machine_name" : "test_college",
    "name" : "Test College",
    "url" : "",
    "nickname" : "Test Test",
    "email_domains" : "jdleonard.net",
    "sponsors" : "",
    "sponsor_urls" : "",
    "enabled" : "1",
    "listed" : "1",
    "rdf_mapping" : []
  }');
  return $items;
}
fago’s picture

Status: Active » Postponed (maintainer needs more info)

That looks good to me, does it still happen with entity API >= beta 10?

jdleonard’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Once again, I can't repro. I'll reopen if I encounter this again, thanks.

jdleonard’s picture

Project: Entity API » Features
Version: 7.x-1.0-beta10 » 7.x-1.x-dev
Component: Code - misc » Code
Status: Closed (cannot reproduce) » Active

Re-opening and moving to features queue.

I've encountered this again, this time with ctools/panels. Reverting a page variant removes it instead of reverting to the variant in code.

Josh Waihi’s picture

after finding issue reverting nodequeue features over in #373174: Export and import capability for nodequeue I found that this was because features ctools implementation didn't re-save the deleted component. Attached is a patch that seems to fix this.

Josh Waihi’s picture

Status: Active » Needs review

Updating status for review.

Josh Waihi’s picture

Title: Reverting feature deletes it! » Reverting features deletes ctools components

Making title more relevant.

jdleonard’s picture

Once again, I'm having trouble reproducing the bug I reported both with and without #12. All I can say for now is the patch doesn't seem to make things worse.

David Stosik’s picture

Priority: Major » Critical

Same here. To try and reproduce bug :
- have a feature describing a content type
- create a new node for this content type, and fill as many fields as possible
- change any setting concerning a field on this content type (let's say, how is displayed the body in default display)
- now, the feature is in "override" state, let's revert it
- LOOK your node is still here, but all content is gone !
- check in database ? all field_data_ and field_revision_ tables concerning your content type are empty

Sadly, patch in #12 doesn't fix anything...

David Stosik’s picture

Status: Needs review » Needs work
roborn’s picture

@David Stosik are you reverting via Features UI or Drush? I get the same issue as #16, but only when using Drush.

Simon Georges’s picture

@roborn, David is mainly reverting using Drush (I work with him). I don't think we've tested using the UI. Just so you know, there's no problem any more after applying patch from #1302228: field_has_data() returns inconsistent results – possible data loss.

roborn’s picture

@Simon thanks for the link. Me and thomjjames were trying to solve this problem, and he stumbled upon that patch, which seems to solve #16

mpotter’s picture

Priority: Critical » Normal
Status: Needs work » Closed (cannot reproduce)

I don't see how the patch in #16 would have any effect (save immediately after deleting). Can somebody confirm if this is still happening in the latest 1.x-dev version of Features? At this point I cannot reproduce.