Skip to content

Conversation

@LordSimal
Copy link
Contributor

@LordSimal LordSimal commented Nov 18, 2025

Fixes #446

Its not really backwards compatible as several method and property types have changed. But it still allows int's being patched into it, so existing calls don't need to be adjusted.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a Priority enum to replace integer priority values throughout the queue system, providing better type safety while maintaining backward compatibility with integer values.

Key Changes:

  • Added a new Priority enum with 10 priority levels (Critical=1 through Idle=10)
  • Updated QueuedJob entity to support both Priority enum and integer types for the priority property
  • Modified display templates to use the new priority_int virtual property for rendering integer values

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Model/Enum/Priority.php New enum defining 10 priority levels with integer backing values
src/Model/Entity/QueuedJob.php Added Priority enum support and priority_int virtual property accessor for display purposes
src/Model/Table/QueuedJobsTable.php Configured EnumType mapping for the priority column to handle enum/int conversion
src/Config/JobConfig.php Updated type annotations to accept Priority enum or int for priority methods
tests/TestCase/Controller/Admin/QueuedJobsControllerTest.php Updated test assertion to verify Priority enum conversion from integer input
templates/Admin/QueuedJobs/view.php Changed to use priority_int for displaying the priority value
templates/Admin/QueuedJobs/index.php Changed to use priority_int for displaying the priority value
templates/Admin/Queue/index.php Changed to use priority_int for displaying priority in pending and scheduled job lists
src/Command/JobCommand.php Changed to use priority_int for console output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dereuromark
Copy link
Owner

That is indeed somewhat bc breaking
I thought we just add a simple enum with popular values, like

enum Priority: int {
    case High = 1;
    case Normal = 5;
    case Low = 10;
}

And people can use either that for creating the options array value, or classic int for the meantime.

@LordSimal
Copy link
Contributor Author

Well I wouldn't like to have to always add ->value to all job creation calls since I want to pass down the enum. Therefore the EnumType needs to be attached to that column and causes the rest.

@dereuromark
Copy link
Owner

Whats the use case of passing it down? Do you have some code examples?

@dereuromark
Copy link
Owner

We could keep the setter for now that transforms it internally to int (until next major anyways)

public function setPriority(Priority|int|null $priority) {

This way you dont have to wry about it anymore, its fully BC and you can use a speaking enum.

@LordSimal
Copy link
Contributor Author

I have no idea why that worker key is now longer than 40 chars as sha1() should always return a 40 char long string...

@dereuromark dereuromark merged commit e9bfd91 into dereuromark:master Nov 21, 2025
8 checks passed
@dereuromark
Copy link
Owner

Docs in f69cac3

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.

RFC: make priority config an enum

2 participants