When a user has translations and we click "Cancel account " on /user/[uid]/edit, it throws a fatal error:
Error: Call to undefined method Drupal\user\Entity\User::getEntity() in Drupal\content_translation\ContentTranslationHandler->entityFormDelete() (line 681)
Juste the line before, there is this code:

$form_object = $form_state->getFormObject()->getEntity();

I think it should be:

$form_object = $form_state->getFormObject();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SylvainM created an issue. See original summary.

SylvainM’s picture

Status: Active » Needs review
FileSize
884 bytes

Attached patch fixes the error

Berdir’s picture

Component: language system » content_translation.module
Priority: Normal » Major

Looks correct, but how are we not testing this... definitely needs tests :)

Also at least major.

borisson_’s picture

Issue tags: +Needs tests

Adding needs tests per #3.

SylvainM’s picture

I will try to add tests this week

dravenk’s picture

If $form_state->getFormObject() not return a entity. what is return from there? Sorry, I can't repeat it. Can you provide the more detailed reproduction steps.?

SylvainM’s picture

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This looks super solid, I like the test and it fails without the fix, so great work!

kala4ek’s picture

Just checked at freshly 8.6.x
Works like a charm.

Status: Reviewed & tested by the community » Needs work
Mixologic’s picture

Status: Needs work » Reviewed & tested by the community

Temporary testbot hiccup.

catch’s picture

Status: Reviewed & tested by the community » Needs review

It looks to me like this would fail for untranslated user deletion too - should we add test coverage for that? (And also change the issue title?)

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

We have lots of tests for deleting untranslated users IMHO.

This is in the content translation handler, that thing is never called if it is not translatable. It is called by \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() as a delete submit callback, which in turn is called by content_translation_form_alter() if the entity type is marked as translatable.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Good point.

Committed/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!

  • catch committed 77b3dbd on 8.6.x
    Issue #2943646 by SylvainM: Translated user can not be deleted
    

  • catch committed 43b6860 on 8.5.x
    Issue #2943646 by SylvainM: Translated user can not be deleted
    
    (cherry...

Status: Fixed » Closed (fixed)

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