- 🇪🇸Spain carlosgm91 Alicante
During corn execution if by mistake from '/admin/config/content/linkchecker', somebody set an user under 'Error handling / Impersonate user account' that later for whatever reason, is deleted and the setting is not updated, the hook_cron throws this error because try to load an inexistent user.
I have updated the patch, in case that the value of the variable after the user_load is empty, then load the superadmin to avoid Fatal errors during the execution and allow the normal execution of Drupal Cron.
I created this issue but i think that now is irrelevant:
https://www.drupal.org/project/linkchecker/issues/3422365 🐛 Cron Execution issue - Error: Call to a member function id() on bool in Drupal\linkchecker\Plugin\LinkStatusHandlerBase->switchSession() Active - First commit to issue fork.
- 🇺🇦Ukraine quadrexdev Lutsk
I did reproduce the issue on the 2.0.x release as well.
To summarize steps from #10 - this error is reproducible if any status handler plugin is enabled. It happens here - \Drupal\linkchecker\Plugin\LinkStatusHandlerBase::switchSession because the user object is passed instead of the user ID.
I do believe it should be detected and tested in LinkcheckerRepair301Test and LinkcheckerUnpublish404Test but for some reason, tests are passing... I'll try to investigate it and fix
- 🇺🇦Ukraine quadrexdev Lutsk
Ok, so I found a place where the error happens: module system, \Drupal\system\TimeZoneResolver::getTimeZone.
Since here we're setting the user object as uid (idk why) - \Drupal\linkchecker\Plugin\LinkStatusHandlerBase::switchSession ->
$this->uid > 0
check in \Drupal\Core\Session\UserSession::isAuthenticated method leads to the error (called in TimeZoneResolver event subscriber)
More details in the attached screenshot
- Merge request !69#3247797 Fixed fatal error after enabling LinkStatusHandler plugins → (Open) created by quadrexdev
- last update
7 months ago Build Successful - Merge request !70#3247797 Fixed fatal error after enabling LinkStatusHandler plugins → (Merged) created by quadrexdev
- last update
7 months ago 86 pass - Status changed to Needs review
7 months ago 4:52pm 11 April 2024 - last update
7 months ago Patch Failed to Apply - last update
7 months ago 84 pass, 4 fail - 🇺🇦Ukraine quadrexdev Lutsk
I guess it could be reviewed now.
P.S. in LinkcheckerUnpublish404Test and LinkcheckerRepair301Test I have added the 'system' module in $this->installConfig so that system configs will be installed and the check
$this->currentUser->isAuthenticated()
will be called here: \Drupal\system\TimeZoneResolver::getTimeZone
protected function getTimeZone() { $config = $this->configFactory->get('system.date'); if ($config->get('timezone.user.configurable') && $this->currentUser->isAuthenticated() && $this->currentUser->getTimezone()) { return $this->currentUser->getTimeZone(); } elseif ($default_timezone = $config->get('timezone.default')) { return $default_timezone; } return NULL; }
The last submitted patch, 7: object_of_class_user_could_not_be_converted_to_string-3247797-7.patch, failed testing. View results →
- last update
7 months ago 86 pass - last update
7 months ago 86 pass -
quadrexdev →
committed 2955689b on 2.0.x
#3247797 Fixed fatal error during cron run after enabling...
-
quadrexdev →
committed 2955689b on 2.0.x
- Status changed to Fixed
3 months ago 3:49pm 5 August 2024 - 🇺🇦Ukraine quadrexdev Lutsk
Re-checked and committed on 2.0.x, thanks everyone for your contribution ❤️
Automatically closed - issue fixed for 2 weeks with no activity.