Problem/Motivation
After installing the node_revision_delete module and successfully deleting revisions.
The content moderation module has broke with the following random exception.
Error: Call to a member function wasDefaultRevision() on null in Drupal\content_moderation\ModerationInformation->hasPendingRevision() (line 157 of core/modules/content_moderation/src/ModerationInformation.php).
Drupal\content_moderation\ModerationInformation->hasPendingRevision(Object) (Line: 58)
Drupal\content_moderation\Access\LatestRevisionCheck->access(Object, Object, Object)
call_user_func_array(Array, Array) (Line: 159)
Drupal\Core\Access\AccessManager->performCheck('access_check.latest_revision', Object) (Line: 135)
Drupal\Core\Access\AccessManager->check(Object, Object, NULL, 1) (Line: 92)
...
The problem is in the code that is not checking a return value sufficiently.
$latest_revision = $storage->loadRevision($latest_revision_id);
$result = !$latest_revision->wasDefaultRevision();
The call to $storage->loadRevision($latest_revision_id);
can return a revision ORNULL
. The code is not handling the scenario and thus fails.
Proposed resolution
Change the code in that manner, empirically it resolved the exception for me.
$latest_revision = $storage->loadRevision($latest_revision_id);
$result = $latest_revision && !$latest_revision->wasDefaultRevision();
The site returned to normal operation with the proposed change for me.
Will provide a patch shortly.
Remaining tasks
Patch, discussion, etc.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.