Problem/Motivation
When we run the CRON command it is interrupted by the error below:
[error] TypeError: Drupal\node_revision_delete\NodeRevisionDelete::getCandidatesRevisionsByNumber(): Argument #1 ($number) must be of type int, null given, called in /var/www/docroot/modules/contrib/node_revision_delete/node_revision_delete.module on line 308 in Drupal\node_revision_delete\NodeRevisionDelete->getCandidatesRevisionsByNumber() (line 287 of /var/www/docroot/modules/contrib/node_revision_delete/src/NodeRevisionDelete.php) #0 /var/www/docroot/modules/contrib/node_revision_delete/node_revision_delete.module(308): Drupal\node_revision_delete\NodeRevisionDelete->getCandidatesRevisionsByNumber(NULL)
Steps to reproduce
We recently updated the Drupal core to version 9.4.8 along with the site studio core to version 6.9
Everything works perfectly on the site, but when running the Cron command, the error occurs.
Proposed resolution
Add a check to the variable checking if it received any value or NULL
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | node_revision_delete-cron-NULL-3320816-4.patch | 759 bytes | eric_a |
Comments
Comment #2
cleversonr commentedTo resolve this issue, make the changes below to the node_revision_delete.settings.yml file:
Comment #3
eric_a commentedYes, I think this fatal error was introduced with 1.0.0-RC5.
Assuming that @cleversonr is not working on a patch or merge request I'm re-assigning this issue and will try to come up with a fix today.
Comment #4
eric_a commentedI guess that before the RC5 type declarations the NULL value was juggled to int 0 at some point. (If not, then possibly all valid revisions were attempted to be deleted at cron time.) If so then it's logical to just do the same here. The simplest would be to add 0 as a default to the
get('node_revision_delete_cron').But really, during cron run it just doesn't seem logical to continue querying and processing if the value is NULL, unless I'm misreading the docs and completely misunderstanding the intent of the code. Same for the 0 value, but I think it is best to just fix the fatal here and leave the 0 case for a separate issue, especially since the NULL is a new fatal, in one place, while the 0 case already existed, in multiple places in the code base.
To trigger this error one must succeed in setting node_revision_delete_cron to the NULL value, which is certainly possible. (And probably easier before RC5.)
Comment #5
adriancidThanks