drupal-console
drupal-console copied to clipboard
Fix the entity revision revert and delete buttons on the revisions tab
Problem/Motivation
When creating an entity using Drupal 8.9.13 and Console 1.9.7 and the command generate:entity:content the revert and delete links on the entity's revisions tab fail with an error
Error: Call to a member function loadRevision() on null in Drupal\my_module\Form\ExampleRevisionRevertForm->buildForm() (line 90 of /web/public/modules/custom/my_module/src/Form/ExampleRevisionRevertForm.php)
and
Error: Call to a member function loadRevision() on null in Drupal\my_module\Form\ExampleRevisionDeleteForm->buildForm() (line 90 of /web/public/modules/custom/my_module/src/Form/ExampleRevisionDeleteForm.php)
These two errors are caused by $this->{{ entity_class }}Storage->loadRevision as the entity class has a capital letter at the start whereas other references to it use a lower case first letter.
There is a further error on the delete confirmation page when the created entity is not translatable.
This is caused by a hard coded reference to the {'~entity_name~'_field_revision} table which doesn't exist for entities that aren't translatable.
How to reproduce
Using Drupal 8.9.13 and Console 1.9.7 create an entity using 'generate:entity:content'. Add a piece of content and save Revise the piece of entity and save Click the Revisions tab and try and revert or delete the old revision.
Solution
This patch alters the relevant templates and should fix all of these problems.