Skip to content

Add runtime fallback for Tools Time->duration() method#462

Merged
dereuromark merged 1 commit into
feature/isolated-admin-dashboardfrom
bugfix/tools-duration-fallback
Mar 17, 2026
Merged

Add runtime fallback for Tools Time->duration() method#462
dereuromark merged 1 commit into
feature/isolated-admin-dashboardfrom
bugfix/tools-duration-fallback

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

Summary

The duration() method is specific to the Tools TimeHelper and is not available in the core CakePHP TimeHelper. Applications not using the Tools plugin would get a fatal error when viewing completed jobs:

Call to undefined method App\View\Helper\TimeHelper::duration()

Changes

Added method_exists() checks for Time->duration() calls in:

  • templates/Admin/QueuedJobs/index.php
  • templates/Admin/QueuedJobs/view.php

The fallback uses PHP's native DateInterval::format('%H:%I:%S') with leading zeros trimmed for a clean display (e.g., "0:02:30" instead of "00:02:30").

Related

This follows the same pattern as the existing relLengthOfTime fallbacks added in f58ec4d.

The duration() method is specific to the Tools TimeHelper. Applications
not using the Tools plugin would get a fatal error. This adds a
method_exists check with a fallback to PHP's DateInterval::format().
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 17, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.70%. Comparing base (b410e2f) to head (1f9797e).
⚠️ Report is 4 commits behind head on feature/isolated-admin-dashboard.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                         Coverage Diff                         @@
##             feature/isolated-admin-dashboard     #462   +/-   ##
===================================================================
  Coverage                               73.70%   73.70%           
  Complexity                                838      838           
===================================================================
  Files                                      44       44           
  Lines                                    2906     2906           
===================================================================
  Hits                                     2142     2142           
  Misses                                    764      764           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark merged commit a2e9576 into feature/isolated-admin-dashboard Mar 17, 2026
16 checks passed
@dereuromark dereuromark deleted the bugfix/tools-duration-fallback branch March 17, 2026 21:50
dereuromark added a commit that referenced this pull request Mar 17, 2026
The duration() method is specific to the Tools TimeHelper. Applications
not using the Tools plugin would get a fatal error. This adds a
method_exists check with a fallback to PHP's DateInterval::format().

Port of #462 to master.
dereuromark added a commit that referenced this pull request Mar 18, 2026
* Add modern isolated admin dashboard with Bootstrap 5

- Create QueueAppController as isolated base for admin controllers
- Add queue.php layout with Bootstrap 5.3.3 and Font Awesome 6.7.2 via CDN
- Add reusable elements: sidebar, stats_card, status_badge, flash messages
- Update admin templates with card-based layout and modern styling
- Add new configuration options: adminLayout, dashboardAutoRefresh, ignoreAuthorization
- Update icon fallback to use Font Awesome 6 icons
- Add documentation for admin dashboard features

* Fix PHPStan error for optional Authorization dependency

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Add runtime fallback for Tools Time->duration() method (#462)

The duration() method is specific to the Tools TimeHelper. Applications
not using the Tools plugin would get a fatal error. This adds a
method_exists check with a fallback to PHP's DateInterval::format().

* Remove redundant sidebar links and improve template styling

- Remove Dashboard/List links from sidebars (now in navbar)
- Add nav-link CSS classes to sidebar links
- Add Font Awesome icons to sidebar action links
- Simplify link routes by removing explicit plugin/prefix
- Add block => true to postLinks in sidebars
- Clean up stats page sidebar and add list-group styling
- Add QueueScheduler link in navbar when plugin is loaded
- Add Chart.js CDN to layout for stats page

* Make demo jobs section collapsible (collapsed by default)

* Modernize all edit/form templates to Bootstrap 5

- Convert all edit pages from old sidebar nav to Bootstrap 5 cards
- Update grid classes from old Foundation to Bootstrap 5 (col-lg-*)
- Add proper form-control/form-select classes to all form inputs
- Add Font Awesome icons to all buttons and headers
- Use list-group for action links in sidebars
- Convert search element from inline float to responsive card layout
- Add proper spacing, alerts, and visual hierarchy
- QueuedJobs: edit, data, test, execute, import, migrate
- QueueProcesses: edit, view
- element: search

* Fix Execute Job placement and search task dropdown

- Move Execute Job link outside collapsible demo section
- Fix search element to use $jobTypes variable for task dropdown

* Fixes and improvements for admin dashboard

- Fix Chart.js infinite vertical expansion on stats page
- Use query parameter for job_type to support slashes in names
- Add back button when viewing specific job type stats
- Add mobile offcanvas navigation
- Add adminLayout and dashboardAutoRefresh to config example
- Remove ignoreAuthorization feature (security concerns)

* Default to isolated layout, add missing tests

- Change adminLayout default: null uses Queue.queue, false disables
- Add tests for clone(), execute(), and migrate() actions
- Update documentation to reflect new default behavior

* Fix CS

* Fix CS

* Add title attributes to duration and memory icons

* Add Server Time title to clock icons

* Simplify

# Conflicts:
#	templates/Admin/QueuedJobs/index.php

* Fix status display for requeued jobs

- Add isRequeued() method to QueueHelper to detect jobs that have failed but
  are within retry limits and will be picked up again
- Add warning state to ok.php element for orange/yellow display
- Update all status display logic in dashboard and QueuedJobs views to use
  hasFailed() and isRequeued() helper methods instead of raw field checks
- Requeued jobs now show with yellow "Requeued" badge instead of incorrectly
  showing as "Failed" or "Running"
- Add tests for isRequeued() method

* Fix dashboard stats double-counting jobs

Pending count was including running and failed jobs, causing the sum
of all stats cards to exceed the actual number of jobs. Now properly
subtracts running and failed counts from pending to avoid overlap.

* Improve dashboard stats display

- Reorder stats cards: Scheduled → Pending → Running → Failed
  (follows job lifecycle chronologically)
- Add safeguard against negative pendingJobs count with max(0, ...)
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