I maintain a module and for its new release I want to display a message about an important change in the release. For this, I am relying on having a new hook_post_update_NAME function in the new release to display the message but only if the function has not been run in the past.
The function myModule_post_update_notify in file myModule.post_update.php has this content:
$existing_updates = \Drupal::keyValue('post_update')->get('existing_updates');
if (array_search('myModule_post_update_notify', $existing_updates) === false) {
return t('Message');
}
After module update, this message appears with drush updb and the Drupal site's admin/reports/status page, but the hook_post_update_NAME function name does not get into database field for post_update > existing_updates when I look for it, for instance, with:
drush php:eval "print_r(\Drupal::keyValue('post_update')->get('existing_updates'));"
Shouldn't my hook_post_update_NAME function get into that database field? If it won't, then my logic of displaying the message when upgrading only from a hitherto previous module version is flawed.
Comments
I realize the issue was
I realize the issue was because of a syntax error. The code/logic of the function works as expected.