Add TaskMetadata for instantiation-free task introspection#3
Open
jamisonbryant wants to merge 2 commits intocake5from
Open
Add TaskMetadata for instantiation-free task introspection#3jamisonbryant wants to merge 2 commits intocake5from
jamisonbryant wants to merge 2 commits intocake5from
Conversation
Read task property defaults (timeout, retries, rate, costs, unique) and description via reflection instead of instantiating the class. This supports tasks with required DI constructor parameters where new $className() would fail with ArgumentCountError.
There was a problem hiding this comment.
Pull request overview
Adds instantiation-free task introspection to avoid ArgumentCountError for tasks with required constructor DI params when the system reads task metadata (timeout/retries/rate/costs/unique/description).
Changes:
- Introduces
Queue\Queue\TaskMetadatato read task property defaults via reflection and obtaindescription()without invoking constructors. - Updates
Config::taskConfig()andAdmin\QueueController::index()to useTaskMetadata::fromClass()instead ofnew $className(). - Adds/updates tests and test-app fixtures to cover metadata introspection and DI-constructor tasks.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Queue/TaskMetadata.php |
New reflection-based metadata reader to avoid task instantiation. |
src/Queue/Config.php |
Switches task config building to read metadata via TaskMetadata. |
src/Controller/Admin/QueueController.php |
Avoids instantiating tasks for descriptions; uses is_subclass_of() for interface checks before instantiation. |
tests/TestCase/Queue/TaskMetadataTest.php |
Adds coverage for property-default reading, description reading, and DI-constructor tasks. |
tests/test_app/src/Queue/Task/MetadataTask.php |
Test fixture task with explicit metadata defaults and description override. |
tests/TestCase/Command/InfoCommandTest.php |
Updates expected task count due to new test task fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update Config::taskConfig() and QueueController::index() to use TaskMetadata::fromClass() instead of new $className() for reading task properties and descriptions. Also use is_subclass_of() for interface checks in addJob() to avoid instantiating DI tasks.
c79309d to
d20b759
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the CI failures in dereuromark#470 where tasks with required DI constructor params cause
ArgumentCountErrorwhenConfig::taskConfig(),QueueController::index(), andQueueHelpertry to read metadata vianew $className().TaskMetadataclass that reads property defaults (timeout,retries,rate,costs,unique) viaReflectionProperty::getDefaultValue()anddescription()vianewInstanceWithoutConstructor()— no constructor invocation neededConfig::taskConfig()andQueueController::index()to useTaskMetadata::fromClass()instead of direct instantiationis_subclass_of()for interface checks inQueueController::addJob()to avoid instantiating DI tasksTest plan
TaskMetadataTest— 3 tests covering property defaults, description, and DI constructor tasks