3

I have a problem in a custom module I can not figure out, I have an update hook like this one:

function article_update_7003() {
  features_revert(array('article' => array('field_base')));
}

But it does not revert the feature. But if I run that update, and manually change it to:

function article_update_7004() {
  features_revert(array('article' => array('field_base')));
}

And run it, the feature is reverted. Anyone that knows what is going on? I tried to duplicate it the first time, but that does not help...

function article_update_7003() {
  features_revert(array('article' => array('field_base')));
  features_revert(array('article' => array('field_base')));
}
3

It is my understanding that the update hook only runs once per update. The function is hook_update_n where 'N' is the instance of the update hook. Each time you want to revert your feature upon a code update you need a new update hook. This is why if you increase the number it works. If you are increasing your version numbers when you regenerate your feature, and also reverting your feature in code with an update hook, those numbers should match, and you will have an update hook for every version increment.

Source: Drupal API.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.