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
Discovered in #2860097: Ensure that content translations can be moderated independently.
This is cannot be currently reproduced via the UI, however node links break when rendering a pending revision adding a new translation. This happens because the #lazy_builder
entry does not include the revision ID, so when loading the entity to actually render links, the default revision is loaded instead of the pending revision. In that case the default revision does not have the specified language and an exception is thrown.
Proposed resolution
Make sure the correct revision is loaded while rendering links.
Remaining tasks
- Validate the proposed solution
- Write a patch
- Reviews
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#12 | node-new_revision_translation_render-2939742-12.test.patch | 2.7 KB | plach |
#12 | node-new_revision_translation_render-2939742-12.patch | 4.84 KB | plach |
Comments
Comment #2
plachComment #3
plachMinor clean-up
Comment #4
plachBetter title
Comment #6
Wim LeersThis blocks #2860097: Ensure that content translations can be moderated independently.
I love how
#lazy_builder
makes the inputs EXPLICIT, which is why it's simple to explain and fix :)We can replace this with
$this->entityManager->getStorage()
.(This is a service injected into the parent class.)
Comment #7
Wim LeersI tried running the test without the code changes, and … it still passed. We need a failing test-only patch.
Also reviewed the test coverage, found only nits:
Nit: Just
{@inheritdoc}
.Nit: Seems extraneous to mention?
Nit: I think
(string)
is cleaner — and we use that in most tests.Comment #8
plachThis should be better.
Comment #9
plachAddressed automated code review.
Comment #10
plachGeez, uploaded the wrong patch, sorry :(
Comment #11
plachComment #12
plachWim spotted that the new test wasn't actually covering the issue, great catch!
Comment #13
Wim LeersAssuming the test-only patch fails, this is ready. The actual code changes are beautifully simple!
Comment #16
plachThere are 4 failures in HEAD common to both patches, but the test-only patch has also a failure in the new test. Based on that, restoring RTBC. This should be green/red as expected, as soon as HEAD is fixed.
Comment #18
Wim LeersOnly failed because #12 has the failing test-only patch after the passing fix+tests patch.
Comment #19
effulgentsia CreditAttribution: effulgentsia at Acquia commentedLooks great. Adding reviewer credit.
Comment #22
effulgentsia CreditAttribution: effulgentsia at Acquia commentedPushed to 8.6.x and 8.5.x.
Comment #23
effulgentsia CreditAttribution: effulgentsia at Acquia commentedComment #26
quietone CreditAttribution: quietone at PreviousNext commentedClosed #2827913: hook_node_links_alter() always receives most recent revision of entity as a duplicate, adding credit.