Review main Merged

71388[BUGFIX] Replace misleading instanceof check for notification actions

Oli Bartsch CR +2 V +2 Easy +5 −5 updated 10/01/21, 10:33

Commit message

With #95406, an instance of check was added to the
Notification component, to prevent a TypeError
in case the action is not defined.
That was actually a sign of a bad usage (e.g. passing null),
and therefore the action is now made optional instead.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 911

  1. Oli Bartsch uploaded patch set 1 09/30/21, 16:41

  2. Andreas Kienast voted on patch set 1 V +1 CR +1 09/30/21, 16:51

  3. core-ci voted on patch set 1 V +1 09/30/21, 16:56 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17361

  4. Benjamin Franzke commented on patch set 1 CR -1 10/01/21, 06:49

    Hey Oli, I'm curious what the test scenario is. For me, both the old and the new check return true. I've manually dispatched via the following code (as the slug notifcation is broken :\) added to a controller: $data = [ 'componentName' => 'redirects', 'eventName' => 'slugChanged', 'correlations' => [ 'correlationIdSlugUpdate' => 'foo', 'correlationIdRedirectCreation' => 'bar', ], 'autoUpdateSlugs' => true, 'autoCreateRedirects' => true, ]; GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule( 'TYPO3/CMS/Backend/BroadcastService', sprintf('function(service) { service.post(%s); }', json_encode($data)) ); The new check isn't bad, but I'd like to know why it failed at all in https://review.typo3.org/c/Packages/TYPO3.CMS/+/71379 and why the check was needed? The interface doesn't mark the action to be optional. So isn't the caller buggy here? I wonder if we could revert https://review.typo3.org/c/Packages/TYPO3.CMS/+/71379 instead.
  5. Oli Bartsch commented on patch set 1 10/01/21, 09:22

    Reply

    Hi, the reason for the previous patch is https://review.typo3.org/c/Packages/TYPO3.CMS/+/71375/4/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DragUploader.ts#366 I actually don't know why the instance of check always returns FALSE in my case. Even if I don't use the Abstract but the implementations, e.g. ImmediateAction. IMO We could also change the "Action" interface to action: AbstractAction|null; and then check if (action.action !== null) { await action.action.execute(e.currentTarget); } This might be the cleanest solution. What do you think?
  6. Benjamin Franzke uploaded patch set 2 10/01/21, 10:15

  7. Benjamin Franzke commented on patch set 2 10/01/21, 10:15

    Reply

    Thanks for the explanation. Sounds great, yea. Adapted as an optional interface member.
  8. Oli Bartsch voted on patch set 2 V +1 CR +1 10/01/21, 10:25

  9. core-ci voted on patch set 2 V +1 10/01/21, 10:32 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17398

  10. Andreas Kienast voted on patch set 2 V +2 CR +2 10/01/21, 10:33

  11. Andreas Kienast merged patch set 3 10/01/21, 10:33