Problem/Motivation
When using the Trash module,
deleted entities are stamped with a timestamp in the deleted column
of their data table. The getQuery() method in LinkExtractorBatch
does not filter out these entities, so they are returned as candidates for extraction.
However, loadMultiple() does not return soft-deleted entities, causing a
mismatch between the IDs found by the query and the entities actually loaded.
This results in an infinite loop during drush linkchecker:analyze or
the UI batch process, where the same unloadable entity IDs are returned on every batch
run but never processed, preventing the batch from ever finishing.
The same infinite loop can also occur with other types of database inconsistencies
where an entity exists in the index tables but cannot be loaded by
loadMultiple().
Steps to reproduce
- Install the Trash module.
- Delete one or more nodes (move them to trash).
- Run
drush linkchecker:analyze. - The process gets stuck and never reaches 100%.
Proposed resolution
Fixes in LinkExtractorBatch:
- Filter deleted entities in
getQuery(): Check
if the entity's data table has adeletedcolumn (indicating the Trash
module or similar is installed) and add anIS NULLcondition to exclude
deleted entities from extraction candidates. - Handle unloadable entities: If
loadMultiple()
returns fewer entities than IDs were found, mark the missing IDs as indexed in
linkchecker_indexand log a warning. This prevents an infinite loop
for any type of DB inconsistency and gives administrators visibility into the problem. - Add infinite loop guard to
batchProcessEntities():
IfprocessEntities()returns 0 processed items, mark the batch as
finished regardless of the total count. This is a safety net to prevent infinite
loops from any future edge case.
Remaining tasks
- Review and testing
| Comment | File | Size | Author |
|---|
Issue fork linkchecker-3604180
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 #3
shank115 commentedComment #4
andrerb commentedComment #6
codebymikey commentedComment #7
codebymikey commentedAttached static patch without composer.json, info.yml and cspell changes since the info.yml leads to conflicts when applied on composer.