Argument #1 ($link) must be of type Drupal\linkchecker\LinkCheckerLinkInterface, null given

Created on 26 September 2023, almost 2 years ago

Problem/Motivation

During the execution of the queue linkchecker_status_handle we get the error message "TypeError: Drupal\linkchecker\Plugin\LinkStatusHandlerBase::handle(): Argument #1 ($link) must be of type Drupal\linkchecker\LinkCheckerLinkInterface, null given". This blocks the cron process.

Steps to reproduce

Have a queue item for the "linkchecker_status_handle" queue with an id that doesn't exist anymore in the linkchecker_link table.

Proposed resolution

Change the catch on line 79 from catching the Exception to catching the Throwable.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium cgoffin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @cgoffin
  • Assigned to abhishek_virasat
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    86 pass
  • 🇧🇪Belgium cgoffin

    Here also a patch file that can be used in your projects.

  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    Patch Failed to Apply
  • 🇳🇴Norway eiriksm Norway

    This sounds like the same issue as https://www.drupal.org/i/3247070

    Could you have a look there and see if we can close this one and collaborate on a fix in that issue? 🤓

  • Issue was unassigned.
  • 🇦🇺Australia timfletcher

    The workaround for me was to disable link rewriting entirely in the Linkchecker settings (the default is to rewrite links after 3 failed checks).

    The patch that returns when no $link is found 🐛 TypeError in LinkStatusHandle.php Needs work suppresses the error in the site logs, but saving a page still shows the white screen (WSOD).

    For context, I have LC indexing all rich text fields on my site, including in paragraphs. It hasn't completed scanning all fields yet, not sure if that could be causing any clashes?

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    87 pass
  • 🇺🇦Ukraine quadrexdev Lutsk

    I reproduced this issue and prepared a fix here - https://git.drupalcode.org/project/linkchecker/-/merge_requests/51

    a) Added post_update hook to fix orphaned entries in queues
    b) Added cleanUpQueues method that is being called in linkchecker_entity_delete for instances of LinkCheckerLinkInterface.
    c) Updated/added new tests

    Please review

  • Assigned to c-logemann
  • 🇩🇪Germany c-logemann Frankfurt/M, Germany

    I take a look to improve.

  • 🇩🇪Germany c-logemann Frankfurt/M, Germany

    The pipeline is running again.

  • 🇩🇪Germany c-logemann Frankfurt/M, Germany

    Because I could not reproduce this error I only tried to get the MR compatible again.

    @quadrexdev Because you could reproduce this error you can maybe check if the additional changes of related issue 🐛 TypeError in LinkStatusHandle.php Needs work comment #19 is needed or not. If you think everything is fine it's ok for me if you merge by yourself.

  • 🇺🇦Ukraine quadrexdev Lutsk

    I'll take a look, thanks @c-logemann for putting your effort to improve this

  • 🇺🇦Ukraine quadrexdev Lutsk

    @c-logemann I re-checked this issue, reproduced this problem again, and the changes from MR are fixing the problem. Also, this one - https://www.drupal.org/project/linkchecker/issues/3247070 🐛 TypeError in LinkStatusHandle.php Needs work is about the same problem, so we may close it as a duplicate, no changes required.

    P.S. I see that the cspell job is failing now due to the updated cspell.json file from the gitlab templates. Since it will be necessary to update config props/schema -> it is an API change that should be handled in the next major release. Moved it here - https://www.drupal.org/project/linkchecker/issues/3531794 📌 Fix cspell issues Active for 3.0.x.

    I can't merge it for some reason, dealing with this

  • Pipeline finished with Skipped
    about 2 months ago
    #529458
  • 🇦🇺Australia VladimirAus Brisbane, Australia

    Looks good.
    Thanks for contributing.

  • Pipeline finished with Skipped
    about 2 months ago
    #535070
  • 🇦🇺Australia VladimirAus Brisbane, Australia

    Merged. Thank you all. 🍻

  • Pipeline finished with Skipped
    about 2 months ago
    #535071
  • Pipeline finished with Skipped
    about 2 months ago
    #535072
  • Pipeline finished with Skipped
    about 2 months ago
    #535131
  • Pipeline finished with Skipped
    about 2 months ago
    #535225
  • 🇦🇺Australia VladimirAus Brisbane, Australia

    Thanks everyone! 🍰
    Committed and released.

  • Not entirely sure this belongs here, but on D10.5.1 I got this error when running drush cron after the update first to 2.0.2, but also after upgrading to 2.1-beta1 and also 2.1-dev:

    [error] Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'entity_id__target_id' in 'NEW': UPDATE "linkchecker_link" SET "status"=:db_update_placeholder_0, "urlhash"=:db_update_placeholder_1, "url"=:db_update_placeholder_2, "method"=:db_update_placeholder_3, "code"=:db_update_placeholder_4, "error"=:db_update_placeholder_5, "fail_count"=:db_update_placeholder_6, "last_check"=:db_update_placeholder_7, "entity_field"=:db_update_placeholder_8, "entity_langcode"=:db_update_placeholder_9, "uuid"=:db_update_placeholder_10, "parent_entity_type_id"=:db_update_placeholder_11, "parent_entity_id"=:db_update_placeholder_12
    WHERE "lid" = :db_condition_placeholder_0; Array
    (
    [:db_update_placeholder_0] => 1
    [:db_update_placeholder_1] => 843Ww4GoKjo8_2GBWYVLBg2qXvbipLfza-e3ZZKqInM
    [:db_update_placeholder_2] => https://www.somevalidpage.td/cdscontent/?contentid=10007.883159&portal=s...
    [:db_update_placeholder_3] => HEAD
    [:db_update_placeholder_4] => 200
    [:db_update_placeholder_5] => OK
    [:db_update_placeholder_6] => 0
    [:db_update_placeholder_7] => 1752255244
    [:db_update_placeholder_8] => body
    [:db_update_placeholder_9] => de
    [:db_update_placeholder_10] => a8c81c42-5bd2-4595-89ae-cc5272cb77c0
    [:db_update_placeholder_11] =>
    [:db_update_placeholder_12] =>
    [:db_condition_placeholder_0] => 8
    )
    in Drupal\Core\Entity\Sql\SqlContentEntityStorage->doSaveFieldItems() (line 914 of /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

    Then I tried to open admin/reports/linkchecker with the 2.1-dev module installed and saw this unexpected error:

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

    Drupal\Core\Entity\EntityTypeManager->getHandler('', 'storage') (Line: 195)
    Drupal\Core\Entity\EntityTypeManager->getStorage('') (Line: 186)
    Drupal\linkchecker\Entity\LinkCheckerLink->getParentEntity() (Line: 68)
    Drupal\linkchecker\LinkCheckerLinkAccessControlHandler->checkParentEntityAccess(Object, 'view', Object) (Line: 58)
    Drupal\linkchecker\LinkCheckerLinkAccessControlHandler->checkFieldAccess('view', Object, Object, Object) (Line: 343)
    Drupal\Core\Entity\EntityAccessControlHandler->fieldAccess('view', Object, Object, Object, 1) (Line: 154)
    Drupal\Core\Field\FieldItemList->access('view', NULL, 1) (Line: 256)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 257)
    Drupal\views\Entity\Render\EntityFieldRenderer->buildFields(Array) (Line: 143)
    Drupal\views\Entity\Render\EntityFieldRenderer->render(Object, Object) (Line: 873)
    Drupal\views\Plugin\views\field\EntityField->getItems(Object) (Line: 1195)
    Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 238)
    template_preprocess_views_view_field(Array, 'views_view_field', Array)
    call_user_func_array('template_preprocess_views_view_field', Array) (Line: 261)
    Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 490)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 1796)
    Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 769)
    Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
    call_user_func_array(Array, Array) (Line: 113)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 886)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 431)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 708)
    Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 574)
    Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, 1) (Line: 462)
    Drupal\views\Plugin\views\style\StylePluginBase->render() (Line: 2177)
    Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1593)
    Drupal\views\ViewExecutable->render() (Line: 201)
    Drupal\views\Plugin\views\display\Page->execute() (Line: 1690)
    Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 113)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 886)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 431)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 637)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 263)
    Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 219)
    Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    All caches had been cleared both times, before the cron run and the attempt to open the report.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024