Skip to content

Add Workflow Transition plugin files and configuration for automated task handling - #5

Merged
ditsuke merged 5 commits into
automated-workflow-devfrom
feat/task-workflowtransition
Jun 29, 2026
Merged

Add Workflow Transition plugin files and configuration for automated task handling#5
ditsuke merged 5 commits into
automated-workflow-devfrom
feat/task-workflowtransition

Conversation

@Fr3shDev

Copy link
Copy Markdown
Collaborator

Pull Request resolves issue #4 .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

Adds a new Joomla Scheduler task plugin plg_task_workflowtransition that fires automated workflow transitions for items whose scheduled deadline has passed.

  • Registers a workflow.automation task type with com_scheduler
  • On each run, joins workflow_automation_schedule with workflow_transitions and workflow_transition_automation to find all (item, rule) pairs where next_transition_at <= NOW() and the rule is not currently locked
  • Groups results by rule and locks each rule via locked_until before processing to prevent concurrent scheduler instances from double-firing the same transition
  • Sets the application state flag workflow.triggered_by = 'automation' before calling Workflow::executeTransition() so plg_workflow_automation records the correct trigger source in workflow_automation_schedule
  • Uses try/finally to guarantee the lock is released and the flag is reset even if a transition throws
    This plugin is the execution engine of the automated workflow feature. It depends on plg_workflow_automation (introduced in PR #3) to populate workflow_automation_schedule and keep next_transition_at up to date.

Testing Instructions

  1. Apply PR #3 (plg_workflow_automation) first if not already merged
  2. Drop the plugins/task/workflowtransition/ directory into your Joomla installation
  3. Go to System → Discover, discover and install "Workflow - Automation Task", then enable it
  4. Ensure at least one row exists in #__workflow_transition_automation with published = 1 and a valid interval_value/interval_unit
  5. Manually transition a content item through a workflow stage that has an automation rule — this causes plg_workflow_automation to write a row to #__workflow_automation_schedule with a computed next_transition_at
  6. Either wait for next_transition_at to pass or manually update the row: UPDATE #__workflow_automation_schedule SET next_transition_at = NOW() WHERE id = X;
  7. Go to System → Scheduled Tasks, create a new task of type "Workflow Automation", save, and click Run
  8. Re-query #__workflow_automation_schedule and verify:
  • The item's stage_id changed to the target stage
  • triggered_by = 'automation'
  • next_transition_at reflects the deadline for the new stage (or NULL if no rule applies)
  1. Query #__workflow_transition_automation and verify locked_until is NULL (lock released)

Actual result BEFORE applying this Pull Request

No automated mechanism exists to fire workflow transitions on a schedule. All transitions require manual user action in the Joomla admin.

Expected result AFTER applying this Pull Request

Items in a workflow stage with a configured automation rule are automatically transitioned to the target stage when their scheduled deadline passes. The transition is recorded with triggered_by = 'automation' in #__workflow_automation_schedule, distinguishing automated transitions from manual ones.

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@Fr3shDev
Fr3shDev requested review from Dileepadari and ditsuke June 20, 2026 12:02
Comment thread plugins/task/workflowtransition/src/Extension/WorkflowTransition.php Outdated
Comment thread plugins/task/workflowtransition/src/Extension/WorkflowTransition.php Outdated
Comment thread plugins/task/workflowtransition/src/Extension/WorkflowTransition.php Outdated
- Added `triggeredBy` argument handling in `WorkflowTransitionEvent` to differentiate between manual and automated transitions.
- Updated `ExtensionHelper` to include the new `workflowtransition` plugin.
- Modified `executeTransition` method in `Workflow` class to accept `triggeredBy` parameter.
- Improved language file for `workflowtransition` plugin to correct descriptions and titles.
- Refactored `WorkflowTransition` class to handle automation more effectively, including deadline computation and rescheduling logic.
- Enhanced `Automation` class to manage new items and compute next transition times based on cron expressions.
@Fr3shDev
Fr3shDev requested a review from ditsuke June 23, 2026 18:28
@ditsuke
ditsuke merged commit d623f0f into automated-workflow-dev Jun 29, 2026
74 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants