$this called in non object context - revert parts of #3197015 and add missing translation

Created on 3 January 2024, about 1 year ago

Problem/Motivation

Issue #3197015-2: Support Drupal 9 added calls to $this in non object context.

Description copied from #8 in that issue:

With #3197015-2 we are using $this->t() and $this->messenger in a static function, i.e. we are not in object context.

I also think we do not need the newly introduced dependency injections at all:

  • MessengerInterface $messenger is only used in public static function changeAuthorActionFinishedCallback(), so not in object context.
  • TranslationInterface $stringTranslation is not used at all (because #3197015-2 also added use StringTranslationTrait which would be enough for the call to $this->t() in the same function ...
  • ... but this also happens in the static function, so we cannot reference $this at all.

There is also still one untranslated string 'Changing author...' in public static function updateFields().

Steps to reproduce

The mentioned calls are only excuted if $success is FALSE in changeAuthorActionFinishedCallback() - so it should fail if an error occured while changing authors.

Proposed resolution

I think we should revert the changes #3197015 in ChangeAuthorActionForm.php and change $message = 'Changing author...' to $message = t('Changing author...').

Or did I get something wrong?

🐛 Bug report
Status

Needs review

Version

1.1

Component

Code

Created by

🇩🇪Germany gngn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @gngn
  • Status changed to Needs review about 1 year ago
  • 🇩🇪Germany gngn

    Patch as proposed.

  • 🇩🇪Germany gngn

    I just noticed that 📌 Support Drupal 9 Fixed also changed src/Form/ChangeAuthorActionForm.php besides src/ChangeAuthorAction.php.

    So I am only proposing to revert parts of #3197015 (changes in ChangeAuthorActionForm.php should be kept).

    Sorry about that, I am also changing issue subject and description.

Production build 0.71.5 2024