Problem/Motivation
When you have a webform that doesn't store the submission, the linkchecker_entity_insert fails, because there's no entity_id. The entity_id is used in updateEntityExtractIndex, but there's no check on the entity.
Steps to reproduce
- Create a webform and disable the storage of submissions
- Submit the webform
This will result in the following error:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entity_id' cannot be null: INSERT INTO {linkchecker_index} (entity_id, entity_type, last_extracted_time) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => webform_submission [:db_insert_placeholder_2] => 1633420538 )
Proposed resolution
Maybe it's an idea to exclude specific entity types from the linkchecker process. Only entities that are allowed are processed.
But the minimal solution would probably to check if the entity is saved (has an id), before processing.
Remaining tasks
- Create patch
| Comment | File | Size | Author |
|---|
Issue fork linkchecker-3240788
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
robert-io commentedBasic patch to check if the entity is stored.
Comment #3
eiriksmCould you have a look if the patch in #3184613: Wrong calculation of extraction status fixes your issue?
Comment #4
lostkangaroo commentedJust applied the patch from #3184613 and ran into a different error. The patch from that issue does not fix the issue in the summary.
The patch in this issue does allow the submission to happen but this should at least have tests included.
Comment #7
tedfordgif commentedAdd MR that checks for integer IDs, instead of the mere presence of an ID.
Comment #8
tedfordgif commentedMissed a few places in the previous patch.
Comment #9
robert-io commentedComment #10
arnaud-brugnon commentedis_int method is not a good solution.
For some unkown reason, entity id is not always an int in the PHP way.
I have weird behaviors on broken link reports if i use is_init.
It s mainly because paragraph id is not recognized as id and then linkcheckerlink entities are not deleted.
Comment #11
arnaud-brugnon commentedHere's my solution.
Comment #12
arnaud-brugnon commentedComment #14
acbramley commentedI don't think we need to cover entity_update or entity_delete, un-saved submissions would never go through these lifecycles as they are never saved.
We can also simply use
$entity->isNew()to check for the existence of an id.Comment #15
imre.horjanPatch #14 works for me.
Comment #16
abhijith s commentedGot different error but with same scenario when I disabled webform submissions.
Confirming the patch #14 worked for me.
Comment #18
vladimiraus✅ Removing patch #11 from MR
✅ Applying patch #14
✅ Hiding files in favour of MR
Comment #20
vladimirausMerged MR and committed!
Thank you 🥃
Comment #21
eiriksmCan we do a follow up to create tests for this issue?
Comment #22
vladimirausSounds good @eiriksm. Do you want to start issue and MR?