Fix the entity revision revert and delete buttons on the revisions tab #4295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.