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
content_translation_entity_presave()
calls $entity->entityType()
, when it should be calling $entity->getEntityTypeId()
.
Proposed resolution
Fix it.
Remaining tasks
Add test coverage maybe?
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
Release notes snippet
Nope.
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff-10.txt | 1006 bytes | amateescu |
#10 | 3030086-10.patch | 1.63 KB | amateescu |
#9 | Content-transalation-3030086-9.patch | 1.62 KB | dhirendra.mishra |
#6 | Content-transalation-3030086-6.patch | 844 bytes | dhirendra.mishra |
#2 | 3030086.patch | 859 bytes | amateescu |
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis should do it. Not sure if such a minor thing deserves explicit test coverage though..
Comment #3
BerdirThis came up before I believe, like in issues that tried to add proper methods for $entity->original and got stalled.
The thing is that it obviously doesn't ever go in there, as this would be a fatal error then. And $entity->original really should always be set. This might be some left-over cruft from 7.x when people did crazy things to just save single fields and so on.
So I'd suggest to just drop the whole part completely, *maybe* add a && $entity->original in the initial condition but I don't think we really bother with that in other hooks.
Comment #4
BerdirComment #5
dhirendra.mishra CreditAttribution: dhirendra.mishra at Srijan | A Material+ Company commentedI will work on this in DrupalGlobalSprintWeekenddelhi2019
Comment #6
dhirendra.mishra CreditAttribution: dhirendra.mishra at Srijan | A Material+ Company commentedHere is the patch.
Comment #7
dhirendra.mishra CreditAttribution: dhirendra.mishra at Srijan | A Material+ Company commentedComment #8
joshi.rohit100This will not work as
->getStorage()
requires string (entity type) as argument and in this case it will object.What I understand from the #3 is that we just need to add the condition && $entity->original at top like this -
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && !$entity->isNew()) && $entity->original) {}
Comment #9
dhirendra.mishra CreditAttribution: dhirendra.mishra at Srijan | A Material+ Company for Srijan | A Material+ Company commentedHere is the updated comment.
Comment #10
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI looked around a bit and we do check
isset($entity->original)
a few times, so let's do that here as well.Comment #11
BerdirDoesn't make a difference as it goes through __get(), but we should get back to the issue about adding methods for that anyway.
Comment #13
catchCommitted 4a43a3b and pushed to 8.7.x. Thanks!