Linkchecker incorrectly reports permanent redirects on internal linkit links

Created on 7 June 2023, almost 2 years ago

Problem/Motivation

When running linkchecker on internal links we found that internal linkit links were incorrectly being reported as moved permanently because linkchecker is checking the node body directly without invoking any filters.

Ex: Error Moved Permanently for link: http://dev.ddev.site/node/431

If the filters were applied prior to linkchecking then the proper url alias would be checked and no error reported.

Steps to reproduce

1. Enabled linkit on node body
2. Enable linkit
3. Create a link using linkit in a test node
4. Run linkchecker

Proposed resolution

On text, text_long and text_with_summary fields invoke the field item view method during link extraction.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada joel_osc

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

Merge Requests

Comments & Activities

  • Issue created by @joel_osc
  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update almost 2 years ago
    Patch Failed to Apply
  • πŸ‡¨πŸ‡¦Canada joel_osc

    Here is a patch that will invoke the filters prior to linkchecking.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update almost 2 years ago
    Build Successful
  • πŸ‡¨πŸ‡¦Canada joel_osc

    Not sure what happened to the first patch, here is a properly formatted one.

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Thanks πŸ™

    For starters, do you mind fixing the coding standards in your patch? πŸ€“

  • Status changed to Needs work almost 2 years ago
  • πŸ‡³πŸ‡΄Norway eiriksm Norway
  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update almost 2 years ago
    Build Successful
  • πŸ‡¨πŸ‡¦Canada joel_osc

    Fixed long comment line... thx!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I can sadly confirm this issue. All URLs made by linkit dynamically are unaliased and therefore cause 301 redirect detection.

    As linkit is widely used and also the ckeditor integration, I'd say this is a bug.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • Merge request !83Added patch #6 β†’ (Open) created by Anybody
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I created a MR against 2.1.x from the patch in #6 now to give it a try.
    @eiriksm what would you say regarding the logics? I'm not experienced enough in this module yet to decide on that.

    I'll report if it works at least.

  • Pipeline finished with Failed
    8 months ago
    Total: 201s
    #273604
  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
     ------ ---------------------------------------------------------------------- 
      Line   src/LinkExtractorService.php                                          
     ------ ---------------------------------------------------------------------- 
      168    \Drupal calls should be avoided in classes, use dependency injection  
             instead                                                               
     ------ ----------------------------------------------------------------------
    
  • Pipeline finished with Failed
    8 months ago
    Total: 201s
    #273655
  • Pipeline finished with Canceled
    8 months ago
    Total: 31s
    #273663
  • Pipeline finished with Failed
    8 months ago
    Total: 198s
    #273664
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Okay I can tell that this at least still fixes the issue with linkit. Link checking now works as expected again and has correct results.

    Still some things left to be done:

    • Use dependency injection
    • Check why tests fail, eventually fix implementation
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Static patch for the time being.

  • Pipeline finished with Failed
    8 months ago
    Total: 201s
    #273670
  • πŸ‡ΊπŸ‡ΈUnited States timwood Rockville, Maryland

    Is this not related to the linkchecker settings under "Link Extraction" > Text formats for link extraction (side note, this should probably be labeled "Text filters")? If you check the following filter then the Linkit filter will not run and process your links during extraction.

    Linkit URL converter
    Updates links inserted by Linkit to point to entity URL aliases.

Production build 0.71.5 2024