- @kuhikar opened merge request.
During execution of update hooks, Drush fails with the following error:
> [notice] Update started: opigno_messaging_update_9003
> [error] The module module does not exist.
> [error] Update failed: opigno_messaging_update_9003
and
> [notice] Update started: opigno_messaging_update_9004
> [error] The module opigno_lms does not exist.
> [error] Update failed: opigno_messaging_update_9004
Apply module update from a previous version, in my case I was applying update to "opigno/opigno_lms", via composer 1.x, from version 2.29. Now using "opigno/opigno_lms" version 3.1.1
Resolution to the hook_update_9003, hook_update_9004 is required, since it called incorrect set of function arguments:
function opigno_messaging_update_9003() {
module_load_include('install', 'opigno_module');
_opigno_module_apply_update('module', 'opigno_messaging', 'config/optional', [
'views.view.private_message'
]);
}
function opigno_messaging_update_9004() {
module_load_include('install', 'opigno_module');
if (!\Drupal::moduleHandler()->moduleExists('honeypot')) {
\Drupal::service('module_installer')->install(['honeypot']);
}
_opigno_module_apply_update('profile', 'opigno_lms', 'config/optional', ['honeypot.settings']);
}
// Note that the "_opigno_module_apply_update" requires first argument to be a module name (it appears that a module type(theme, profile or theme) was passed instead). please check opigno_module.install file.
The expected function call is:
function opigno_messaging_update_9003() {
module_load_include('install', 'opigno_module');
_opigno_module_apply_update('opigno_messaging', 'config/optional', [
'views.view.private_message',
]);
}
Calling the config files from profile is a work around, created new menthod _opigno_messaging_apply_update (adapted from opigno_lms.install)
/**
* Import honeypot configs.
*/
function opigno_messaging_update_9004() {
if (!\Drupal::moduleHandler()->moduleExists('honeypot')) {
\Drupal::service('module_installer')->install(['honeypot']);
}
_opigno_messaging_apply_update('profile', 'opigno_lms', 'config/optional', [
'honeypot.settings',
]);
}
/**
* Configs update helper function.
*/
function _opigno_messaging_apply_update($type, $name, $path, $ymls) {
$theme_path = sprintf("%s/%s/", \Drupal::service('extension.list.' . $type)->getPath($name), $path);
$config_factory = \Drupal::configFactory();
$config_storage = \Drupal::service('config.storage');
$configs = [];
foreach ($ymls as $yml) {
$configs[$yml] = $theme_path;
}
foreach ($configs as $config => $config_path) {
$source = new FileStorage($config_path);
$data = $source->read($config);
if (is_array($data)) {
$config_factory->getEditable($config)->setData($data)->save(TRUE);
$config_storage->write($config, $data);
}
else {
\Drupal::messenger()->addWarning(t('Incorrect data of @config', ['@config' => $config]));
}
}
}
N/A (no)
N/A (no)
N/A (no)
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.