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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu created an issue. See original summary.

amateescu’s picture

Status: Active » Needs review
FileSize
859 bytes

This should do it. Not sure if such a minor thing deserves explicit test coverage though..

Berdir’s picture

This 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.

Berdir’s picture

Status: Needs review » Needs work
dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra
Issue tags: +DrupalGlobalSprintWeekenddelhi2019

I will work on this in DrupalGlobalSprintWeekenddelhi2019

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
Issue tags: -DrupalGlobalSprintWeekenddelhi2019 +DrupalGlobalSprintWeekenddelhi20
FileSize
844 bytes

Here is the patch.

dhirendra.mishra’s picture

joshi.rohit100’s picture

Status: Needs review » Needs work

This 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) {}

dhirendra.mishra’s picture

Status: Needs work » Needs review
FileSize
1.62 KB

Here is the updated comment.

amateescu’s picture

Title: content_translation_entity_presave() calls a non-existing method on the $entity object » Clean up content_translation_entity_presave()
Category: Bug report » Task
FileSize
1.63 KB
1006 bytes

I looked around a bit and we do check isset($entity->original) a few times, so let's do that here as well.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Doesn't make a difference as it goes through __get(), but we should get back to the issue about adding methods for that anyway.

  • catch committed 4a43a3b on 8.7.x
    Issue #3030086 by amateescu, dhirendra.mishra, Berdir, joshi.rohit100:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4a43a3b and pushed to 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.