I'm getting the following error when running cron with Link Checker enabled on several 9.2.7 sites:
TypeError: Argument 1 passed to Drupal\linkchecker\Plugin\LinkStatusHandlerBase::handle() must implement interface Drupal\linkchecker\LinkCheckerLinkInterface, null given, called in /Users/dicksb/Sites/MAMP/moweb/docroot/modules/contrib/linkchecker/src/Plugin/QueueWorker/LinkStatusHandle.php on line 79 in /Users/dicksb/Sites/MAMP/moweb/docroot/modules/contrib/linkchecker/src/Plugin/LinkStatusHandlerBase.php on line 107 #0 /Users/dicksb/Sites/MAMP/moweb/docroot/modules/contrib/linkchecker/src/Plugin/QueueWorker/LinkStatusHandle.php(79): Drupal\linkchecker\Plugin\LinkStatusHandlerBase->handle(NULL, Object(GuzzleHttp\Psr7\Response))
#1 /Users/dicksb/Sites/MAMP/moweb/docroot/core/lib/Drupal/Core/Cron.php(182): Drupal\linkchecker\Plugin\QueueWorker\LinkStatusHandle->processItem(Array)
#2 /Users/dicksb/Sites/MAMP/moweb/docroot/core/lib/Drupal/Core/Cron.php(147): Drupal\Core\Cron->processQueues()
#3 /Users/dicksb/Sites/MAMP/moweb/docroot/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#4 /Users/dicksb/Sites/MAMP/moweb/vendor/drush/drush/src/Drupal/Commands/core/DrupalCommands.php(76): Drupal\Core\ProxyClass\Cron->run()
#5 [internal function]: Drush\Drupal\Commands\core\DrupalCommands->cron(Array)
#6 /Users/dicksb/Sites/MAMP/moweb/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#7 /Users/dicksb/Sites/MAMP/moweb/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /Users/dicksb/Sites/MAMP/moweb/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#9 /Users/dicksb/Sites/MAMP/moweb/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(313): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#10 /Users/dicksb/Sites/MAMP/moweb/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /Users/dicksb/Sites/MAMP/moweb/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /Users/dicksb/Sites/MAMP/moweb/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /Users/dicksb/Sites/MAMP/moweb/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /Users/dicksb/Sites/MAMP/moweb/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /Users/dicksb/Sites/MAMP/moweb/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /Users/dicksb/Sites/MAMP/moweb/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#17 /Users/dicksb/Sites/MAMP/moweb/vendor/drush/drush/drush(4): require('/Users/dicksb/S...')
#18 {main}
TypeError: Argument 1 passed to Drupal\linkchecker\Plugin\LinkStatusHandlerBase::handle() must implement interface Drupal\linkchecker\LinkCheckerLinkInterface, null given, called in /Users/dicksb/Sites/MAMP/moweb/docroot/modules/contrib/linkchecker/src/Plugin/QueueWorker/LinkStatusHandle.php on line 79 in Drupal\linkchecker\Plugin\LinkStatusHandlerBase->handle() (line 107 of /Users/dicksb/Sites/MAMP/moweb/docroot/modules/contrib/linkchecker/src/Plugin/LinkStatusHandlerBase.php).
[warning] Drush command terminated abnormally.I cannot entirely reproduce this. A fresh install using the same core and the same custom install profile seems able to run cron just fine with Link Checker enabled, while (so far) about a half-dozen existing sites (also on the same core) started experiencing this error when Link Checker was enabled.
Uninstalling Link Checker stops the error. Reinstalling it causes the error to return, even if I don't configure any fields to be checked.
Error occurs both on Acquia Cloud and on my local MAMP environment.
Problem occurs with both 1.0-beta and 1.x-dev.
On a fresh install, I cannot reproduce the error even if I enable all the modules that are enabled on the sites where the error occurs.
I'm still trying to isolate this, but I'm hoping someone else may have an idea.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | TypeError_in_LinkStatusHandle_php_3247070-13.patch | 1.96 KB | kaszarobert |
| #11 | TypeError_in_LinkStatusHandle_php_3247070-11.patch | 585 bytes | szeberli |
Issue fork linkchecker-3247070
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wrd-oaitsd commentedComment #5
eiriksmWeird how you would get in that situation, but can you try the patch from the merge request?
Comment #6
wrd-oaitsd commentedThanks for the quick response! I believe that's solved the problem -- I've successfully run cron on two of the affected sites. I'm working my way through about 50 sites, some of which are throwing a separate, unrelated error that takes some time to correct, so it may be a couple of days before I'm certain about the rest. I'll post again when I can confirm.
Comment #7
wrd-oaitsd commentedYes, I have not encountered this error on any of about 50 sites since applying the patch. Thanks!
Comment #8
eiriksmGreat! Let's add some tests here too before we commit.
Thanks for testing and verifying! 💪
Comment #9
joelpittetRan into this too. Setting to needs work for the tests.
Comment #10
rex.barkdoll commentedJust wanted to comment that this fix worked for me. Running LinkChecker on a D8 site (which will be migrated soon), but I was getting the same error that let me to this and adding the patch/merge request fixed the issue.
Thanks :)
Comment #11
szeberli commentedI had the same problem. I have now created a small patch for this.
Comment #12
eiriksmTo those with the same problem: can we get some steps to reproduce this in here somehow? 🤓
Comment #13
ryan-l-robinson commentedAlso encountered this today, also as an update to an existing site. This error occurred on cron. If I tried to uninstall linkchecker, I could run cron from drush in the terminal but the entire site would crash with a different error. So obviously we went back to having the error on cron that doesn't affect visitors, at all as far as we can tell.
Drupal core 9.4.8.
PHP 8.0.26.
Comment #14
eiriksmCould you test the patch and see if that fixes it for you?
Comment #15
ryan-l-robinson commentedI think the answer is yes, but it wasn't as clear as I'd hoped. That error went away on the cron run with the patch applied.
Instead I got another one, which led me to https://www.drupal.org/project/linkchecker/issues/3247797 and followed the last comment there to disable the option to update redirected links.
No posted errors now running cron in the browser or via drush, at least in these first few manual tests. We'll see if it holds up over a few days.
I do still get a site-breaking error if I try to uninstall linkchecker, but hopefully I will never have to do that.
Comment #16
eiriksmI have a theory on why this happens. Could it be (to those of you who are experiencing this) that you have gone and deleted some link checker links. Like edit the "check" itself and deleted it?
Comment #17
aitala commentedHi,
Patch seems to work...
No idea why the error was occurring - Is a new Drupal 9 site...
Eric
Comment #18
timfletcher commentedI tried Patch #11 after finding issue 3389739 on the 2.x D10 version. The patch suppresses the error but still WSODs the page. Is it possible the cause of the error isn't the cause of the WSOD?
Comment #19
kaszarobertI updated the patch with proper array index checking, method argument type checking and catching Throwable to not produce WSOD if Exception or Error is thrown.
Comment #20
promespatch #19 works for me.
Comment #21
alt36 commentedI have a site which is currently throwing this error every time cron runs, and have been trying to figure out reproducible steps without success. However, I am reasonably confident about the following.
I have linkchecker configured to update redirected links after three checks (error.action_status_code_301 = 3)
I have two nodes which contain the same link (identical urlhash value in linkchecker_link table, lid=1643 and 1720, different entity_id__target_id values). The link returns 301 and both rows in linkchecker_link have fail_count=2. The queue table has a couple of hundred rows with name=linkchecker_status_handle. I've made a clone of my Drupal installation to debug and have manually executed "truncate queue".
I run "drush cron". Manually watching the queue table I see many linkchecker_status_handle being created. The "TypeError .. null given" error is then thrown. The queue entry with the smallest item_id has data containing "s:5:"links";a:2:{i:1643;s:4:"1643";i:1720;s:4:"1720";}", i.e it will deserialize to links with lid 1643 and 1720. However, linkchecker_link no longer has the row with lid=1643 but the row for lid=1720 is still present. This presumably is what leads to the error: LinkStatusHandle::processItem() loads a null $link which gets passed unchecked to $hanlder->handle()
Comment #22
joe huggansTested patch #19 and seems to be working
Comment #23
vladimirausThank you for contributing and testing.
RTBC
Comment #24
vladimirausAdded changes from patch #19 to MR.
Comment #25
vladimirausGreat work everyone.
I no longer have permissions to merge. 🤷♂️
Waiting for someone with permissions.
Comment #27
vladimirausThanks everyone. 🧁
Merged and released.