Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\Core\Entity\Entity::urlRouteParameters()
calls $this->getRevisionId()
when called with the revision
link template even if $this
does not implement \Drupal\Core\Entity\RevisionableInterface
.
The similar code in Entity::toUrl()
has the proper check:
if ($rel === 'revision' && $this instanceof RevisionableInterface && $this->isDefaultRevision()) {
$rel = 'canonical';
}
Proposed resolution
Add a check for RevisionableInterface
.
Test coverage for this is blocked on #2751395: Rewrite EntityUrlTest.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2751583-3.patch | 1.3 KB | tstoeckler |
#4 | 2751583-3--test-only.patch | 713 bytes | tstoeckler |
Comments
Comment #2
tstoecklerHere we go.
Comment #3
tstoecklerComment #4
tstoecklerYay, #2751395: Rewrite EntityUrlTest was committed. So now with comes with test coverage. The
--tests-only
patch is also the interdiff.I wanted to add a comment before the line in the test to explain why we use the
revision
template there, but didn't manage to find proper words without writing an entire essay. Also, if people look at the actual code that is being run, it should be fairly evident, so maybe it's OK like this...Comment #6
dawehnerYeah, one could even argue that its already enough that phpstorm complains about it.
Comment #7
alexpottCommitted 7742f48 and pushed to 8.1.x and 8.2.x. Thanks!