The stage logger plugin (plg_workflow_automation) reads workflow.triggered_by from application state to determine whether a transition was triggered manually or by automation. Currently nothing sets this flag to 'automation' because the scheduler task has not been built yet. When plg_task_workflowtransition is implemented, it must call Factory::getApplication()->set('workflow.triggered_by', 'automation') before each executeTrasition() call and reset it to 'manual' after.
Think of it like a sticky note on a shared whiteboard. The whiteboard always says 'manual' by default. When the scheduler task runs, the flow looks like this:
Scheduler finds article 3 is overdue
- Sticks note on whiteboard: "automation"
- Calls executeTransition()
- Joomla fires onWorkflowAfterTransition
- Our logger reads the whiteboard: "automation"
- Writes triggered_by = 'automation' to DB
- Removes note, whiteboard back to "manual"
Scheduler finds article 4 is overdue
- Sticks note: "automation"
- Calls executeTransition()
→ Logger reads "automation"
- Removes note, whiteboard back to "manual"
Why reset to 'manual' after each transition?
Because the scheduler fires multiple transitions in a single run. If you don't reset after each one, the flag stays 'automation' for the rest of the request. Any other transition that fires — triggered by a different plugin responding to the first transition, or anything else — would incorrectly get logged as 'automation'.
The rule is: the flag should only be 'automation' for the exact moment the scheduler is firing a specific transition. Immediately after, you clean up. This way only the transitions the scheduler explicitly fires get that label.
The stage logger plugin (plg_workflow_automation) reads workflow.triggered_by from application state to determine whether a transition was triggered manually or by automation. Currently nothing sets this flag to 'automation' because the scheduler task has not been built yet. When plg_task_workflowtransition is implemented, it must call Factory::getApplication()->set('workflow.triggered_by', 'automation') before each executeTrasition() call and reset it to 'manual' after.
Think of it like a sticky note on a shared whiteboard. The whiteboard always says 'manual' by default. When the scheduler task runs, the flow looks like this:
Scheduler finds article 3 is overdue
Scheduler finds article 4 is overdue
→ Logger reads "automation"
Why reset to 'manual' after each transition?
Because the scheduler fires multiple transitions in a single run. If you don't reset after each one, the flag stays 'automation' for the rest of the request. Any other transition that fires — triggered by a different plugin responding to the first transition, or anything else — would incorrectly get logged as 'automation'.
The rule is: the flag should only be 'automation' for the exact moment the scheduler is firing a specific transition. Immediately after, you clean up. This way only the transitions the scheduler explicitly fires get that label.