Problem/Motivation
The autologout_update_9201 hook in autologout.install attempts to
install the js_cookie module as a dependency.
However, js_cookie is no longer listed as a dependency in
autologout.info.yml. Running drush updb on a fresh install or on
sites that do not have js_cookie available results in a fatal error:
Unable to install modules js_cookie due to missing modules js_cookie.
Steps to reproduce
- Install Drupal with the autologout module version 8.x-1.4.
- Run
drush updb to ensure the database is up to date.
- Update the autologout module to version 8.x-1.7.
- Run
drush updb.
- Observe the error: Unable to install modules js_cookie due to missing modules
js_cookie.
Proposed resolution
Remove the autologout_update_9201 hook from autologout.install
entirely, as the js_cookie dependency no longer exists in the module.
Remaining tasks
- Push, Review and merge patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
joaopauloscho commentedI'm working on this.
Comment #4
joaopauloscho commentedReady for review, thanks.
Comment #5
yannickooReally nice, thanks for this! I think you would need to implement hook_update_last_removed to let Drupal be aware of that.
Comment #7
jonathandealmeida commentedThe hook_update_last_removed() was added.
Comment #8
yannickooThanks for quick action, RTBC from my side 💪
Comment #9
the_g_bomb commentedAs a thought, is it worth keeping the js_cookie dependency in the composer.json file for anyone else upgrading after this goes in, so that the module can be properly uninstalled?
We can drop the composer dependency in a future release.
We could also return a message saying the dependency has been dropped and the module can be uninstalled if it is no longer required elsewhere. If it is needed, users need to make sure they add it to their own composer json file.
Comment #10
the_g_bomb commentedThis should target the 2.x branch
As per the comment here:
https://www.drupal.org/project/autologout/issues/3308456#comment-16516672
We should be be mindful of the doc block comments
Comment #12
the_g_bomb commentedAdding an alternative as a Proof of concept solution
Comment #13
yannickooI can confirm that I had to re-add the Composer dependency to fix our pipeline when deploying this 😇 Having that dependency back will simplify the process.
Comment #14
the_g_bomb commentedSorry, I've been really busy at work, and I hope to get back to this asap.
Comment #16
the_g_bomb commentedMerged, thank you.
Comment #19
ressaThanks for working on this. I just updated to 2.0.3 and saw this message:
But when I tried I got this message (and I now see
"require": { "drupal/js_cookie": "*" }in composer.json):After reading the comments here, maybe the update feedback text could be updated to something like this, to be more precise?
Comment #20
the_g_bomb commentedHmm, in retrospect, the wording could be clearer.
The intention was uninstalled means
drush pmu js_cookieRemoved would be
composer remove drupal/js_cookieWhen I release a 3.0 version, the composer JSON file won't have drupal/js_cookie included in it, so the module will get removed if nothing else needs it.
Comment #21
ressaThanks for a fast answer @the_g_bomb, and you're so right: To install/uninstall (Drush/GUI) or download/delete (Composer) a module are two different things. I conflated them, thinking that if a module is uninstalled, it ought to be deletable as well, which it is not in this case ... And a perfectly fine choice, since it prevents problems during the phase out of js_cookie, and I totally support that model.
So the wording is correct, but perhaps we could tag on a sentence, something along these lines?