Added new update hook to make sure js_cookie is enabled
1 unresolved thread
Closes #3449275
Merge request reports
Activity
Filter activity
56 56 $config->save(TRUE); 57 57 } 58 59 /** 60 * Make sure the js_cookie dependency is enabled. 61 */ 62 function autologout_update_9201(&$sandbox): void { 63 // Issue #3449275: Multiple warnings after upgrading to 8.x-1.5 & 2.x with js_cookie. 64 // The module to check. 65 $module = 'js_cookie'; 66 /** @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler */ 67 $moduleHandler = \Drupal::service('module_handler'); 68 /** @var \Drupal\Core\Extension\ModuleInstallerInterface $moduleInstaller */ 69 $moduleInstaller = \Drupal::service('module_installer'); 70 71 if (!$moduleHandler->moduleExists($module)) { IMO, that sounds like a good thing since it will cause the update to fail, alerting the user. But looking at the code, there is no error thrown. It returns just a
true
orfalse
. It's simply anisset
check.Edited by Mike DeckerYes - I read that as why the if condition should be removed, so that an exception is thrown if the module is missing.
E.g. can we just do
63 // Issue #3449275: Multiple warnings after upgrading to 8.x-1.5 & 2.x with js_cookie. 64 // The module to check. 65 $module = 'js_cookie'; 66 /** @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler */ 67 $moduleHandler = \Drupal::service('module_handler'); 68 /** @var \Drupal\Core\Extension\ModuleInstallerInterface $moduleInstaller */ 69 $moduleInstaller = \Drupal::service('module_installer'); 70 71 if (!$moduleHandler->moduleExists($module)) { 72 $moduleInstaller->install([$module]); 73 } 63 \Drupal::service('module_installer')->install(['js_cookie']); Edited by Eric SmithJust hit this issue with upgrading. Just running an install with no conditionals seems to be what most contrib modules do. It fails relatively gracefully when the module code doesn't exist, allowing the update to be re-ran - so I'd +1 the suggested change by @ericgsmith
Edited by Tawny Bartlett
Please register or sign in to reply