I found an issue while I tried to execute the database update on this module.
$ drush updb -y
------------ ---------------- -------------- -------------------------------------
Module Update ID Type Description
------------ ---------------- -------------- -------------------------------------
checklistapi 8001 hook_update_n Update saved progress configuration to new schema.
> [notice] Update started: checklistapi_update_8001
> [error] Call to a member function get() on null
> [error] Update failed: checklistapi_update_8001
After I debugged I found what's happening.
Checklist definition is loaded at line 17 what's working fine but right next it tries to use `->config` public attribute what's null by default.
// Code....
function checklistapi_update_8001() {
// Code....
$checklist = checklistapi_checklist_load($id);
$config = $checklist->config->get(ChecklistapiChecklist::PROGRESS_CONFIG_KEY);
// Code....
I reviewed `Drupal\checklistapi\ChecklistapiChecklist` class to verify the `$config` attribute, and I also noticed it was marked as deprecated:
/**
* The configuration object for saving progress.
*
* @var \Drupal\Core\Config\Config
*
* @deprecated since version 8.x-1.9, to be removed in 8.x-2.0.
*/
public $config;
Comments
Comment #2
keboca commentedI'm not pretty familiar on how to retrieve the proper configuration object here that's the reason why I added a simple validation to avoid any execution when configuration is not defined what at least it will avoid an error to happen.
Comment #3
mmekutHi keboca, thanks for the patch. i ran into same issue while running DB updates.
Meanwhile you don't need to know how to retrieve the proper configuration object, the maintainer will cross check that on next release.
I found your patch a little awkward so instead of specifically checking for a null object like this
found in your patch file, I did this
since an undefined, uninitialized OR null object returns false in an if statement
...........and the update ran smoothly
Thanks for the clue
Comment #5
traviscarden commentedThanks, @keboca!