Skip to content

RedirectFinisher breaks finisher execution order when using numeric keys #1346

@thomasrawiel

Description

@thomasrawiel

In the current Powermail finisher execution, finishers are sorted by their numeric keys.

This causes 2 problems in my opinion:

  1. Currently, developers have to manually pick integer keys for all finishers. When combining multiple extensions, key collisions or high numbers are unpredictable.

  2. The RedirectFinisher immediately sends a redirect response when executed.
    throw new PropagateResponseException($response); in the RedirectFinisher halts the current finisher loop and immediately returns the response.
    So any finisher with a numeric key higher than the RedirectFinisher will never be executed, because the redirect terminates script execution or sends headers before subsequent finishers can run.

Example configuration:

plugin.tx_powermail.settings.setup.finishers {
  10.class = In2code\Powermail\Finisher\SaveToAnyTableFinisher
  20.class = In2code\Powermail\Finisher\SendParametersFinisher
  100.class = In2code\Powermail\Finisher\RedirectFinisher
  200.class = Vendor\Ext\Finisher\CustomFinisher  <-- This will never run
  1771421989.class = Vendor\OtherExt\Finisher\OtherCustomFinisher<-- This will never run
}

Expected behavior

All finishers should run in order, and the RedirectFinisher should always execute last, so it does not prevent other finishers from running.

Suggested solution

Introduce a concept of a “finally” (or similar naming) finisher or treat the RedirectFinisher as a final step, ensuring it always runs after all other finishers.
Any solution should respect current configurations where developers have already "moved" (as in changed the numeric key) RedirectFinisher manually.
This ensures predictable execution order and avoids losing any custom finisher logic.

The TYPO3 docs for custom inputs suggest using the current timestamp for the nodeRegistry: I would suggest the same here: Custom finishers should use the current timestamp as the key (if the order doesn't actually matter for that finisher)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions