Skip to content

Conversation

@Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Nov 14, 2025

Description

Fixes #(issue number)
Explain how this code impacts users.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).
  • Sub-task of #(issue number)
  • Chore
  • Release

Detailed scenario

What was tested

Describe the scenarios that you tested, and specify if it is automated or manual. For manual scenarios, provide a screenshot of the results.

How to test

Describe how the PR can be tested so that the validator can be autonomous: environment, dependencies, specific setup, steps to perform, API requests, etc.

Technical description

Documentation

Explain how this code works. Diagrams & drawings are welcome.

New dependencies

List any new dependencies that are required for this change.

Risks

List possible performance & security issues or risks, and explain how they have been mitigated.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

If some mandatory items are not relevant, explain why in this section.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

- Extract shared functionality from ActionScheduler_Abstract_QueueRunner
- Add abstract methods for queue group, cron hook, and schedule
- Use wpm_apply_filters_typed for type-safe filter handling
- Provide foundation for feature-specific queue runners

Refs: #7894
- Remove duplicate code by extending AbstractQueueRunner instead of ActionScheduler_Abstract_QueueRunner
- Maintain 60-second processing intervals for backward compatibility
- Keep 'rocket-rucss' queue group for proper isolation
- Preserve all existing RUCSS functionality unchanged

Refs: #7894
- Extend AbstractQueueRunner for shared functionality
- Process Rocket Insights jobs every 30 seconds instead of 60
- Use 'rocket-insights' queue group for complete isolation from RUCSS
- Follow singleton pattern consistent with existing architecture

Refs: #7894
- Add 'ri_queue_runner' service registration to container
- Enable dependency injection for the queue runner
- Support clean initialization through service provider pattern

Refs: #7894
- Add 'initialize_ri_queue_runner' hook to properly initialize queue runner
- Remove unused queue_runner property (uses singleton pattern instead)
- Ensure queue runner is initialized when Rocket Insights is active

Refs: #7894
Copilot AI review requested due to automatic review settings November 14, 2025 07:00
@Miraeld Miraeld marked this pull request as draft November 14, 2025 07:01
Copilot finished reviewing on behalf of Miraeld November 14, 2025 07:03
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 refactors the queue runner implementation by extracting common functionality from RUCSSQueueRunner into a new AbstractQueueRunner base class. This enables code reuse across multiple queue runners (RUCSS and Rocket Insights).

  • Introduces AbstractQueueRunner abstract class with common queue processing logic
  • Refactors RUCSSQueueRunner to extend the new abstract class, removing ~200 lines of duplicate code
  • Adds new QueueRunner for Rocket Insights with a 30-second schedule interval
  • Implements initialization for Rocket Insights queue runner in the subscriber

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
inc/Engine/Common/Queue/AbstractQueueRunner.php New abstract base class providing common queue runner functionality including initialization, batch processing, cache management, and abstract methods for child classes to define their specific configuration
inc/Engine/Common/Queue/RUCSSQueueRunner.php Refactored to extend AbstractQueueRunner, removing duplicate code and implementing only the configuration methods (cron schedule, hook name, and queue group)
inc/Engine/Admin/RocketInsights/Queue/QueueRunner.php New queue runner implementation for Rocket Insights extending AbstractQueueRunner with a 30-second schedule interval
inc/Engine/Admin/RocketInsights/Subscriber.php Added initialization method for Rocket Insights queue runner hooked to admin_init
inc/Engine/Admin/RocketInsights/ServiceProvider.php Minor whitespace/formatting adjustment to comment placement

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

@codacy-production
Copy link

codacy-production bot commented Nov 14, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for be7fb391 29.52% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (be7fb39) Report Missing Report Missing Report Missing
Head commit (64ea97d) 41803 18772 44.91%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7905) 105 31 29.52%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

- Create abstract base class extending ActionScheduler_Abstract_QueueRunner
- Provides common functionality for RUCSS and Rocket Insights queue runners
- Implements shared init(), run(), and do_batch() methods
- Abstract methods for queue-specific configuration (group, schedule, cron hook)
- Enables creation of separate queue runners with different intervals

Part of queue runner refactoring for issue #7894
- Extend AbstractQueueRunner instead of ActionScheduler_Abstract_QueueRunner
- Maintains 60-second processing interval (every_minute schedule)
- Uses 'rocket-rucss' queue group for RUCSS jobs only
- Preserves existing RUCSS functionality and behavior
- Singleton pattern with instance() method

Part of queue runner refactoring for issue #7894
- Create new QueueRunner extending AbstractQueueRunner for Rocket Insights
- Processes jobs every 30 seconds (every_thirty_seconds schedule) vs 60s for RUCSS
- Uses 'rocket-insights' queue group for complete separation from RUCSS
- Singleton pattern with instance() method for consistency
- Dedicated cron hook 'action_scheduler_run_queue_rocket_insights'

Addresses issue #7894 requirement for faster RI processing
- Add dynamic queue group assignment based on optimization_type
- Add factory methods: for_rucss() and for_rocket_insights()
- Fix critical bug where RI jobs were incorrectly assigned to 'rocket-rucss' group
- Enable proper queue separation for different optimization types
- Modify process_pending_jobs() to use Queue factory methods
- Ensure jobs are processed by correct queue runners based on optimization_type
- Fix routing of jobs to appropriate queue groups (rucss vs rocket-insights)
- Complete the queue separation implementation
- Remove queue parameter from JobProcessor constructor and registration
- Remove unused queue property from JobProcessor class
- PHPStan compliance fix for unused written property
- Implement full do_batch logic since parent abstract class has no such method
- Fix method parameter contravariance in run() method signature
- Remove duplicate PHPDoc comments causing parsing issues
- Complete ActionScheduler integration with proper claim handling
- PHPStan compliance achieved
@Miraeld Miraeld requested a review from Copilot November 14, 2025 08:11
Copilot finished reviewing on behalf of Miraeld November 14, 2025 08:12
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.


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

- Add exception handling with try/catch/finally in AbstractQueueRunner::do_batch()
- Add clear_caches() call after releasing claim to prevent memory issues
- Remove unnecessary do_batch overrides from RUCSSQueueRunner and RocketInsightsQueueRunner
- Fix spelling typo: 'identifer' -> 'identifier' in docblocks
- Clean up excessive whitespace in ServiceProvider comment
- Add missing @throws tag in do_batch() docblock
- Fix inline comment punctuation (must end with periods)
- Add 'ri_queue_runner' to provides array for container registration
- Register RIQueueRunner as shared service in container
- Enable dependency injection for the queue runner service

Addresses GitHub feedback about missing service registration
- Clean up queue runner cron when Rocket Insights is disabled
- Add cleanup_queue_runner_cron() method for deactivation cleanup
- Follow same pattern as other scheduling methods in codebase
- Ensure cron events are properly removed when feature is disabled

Addresses GitHub feedback about missing cleanup when disabled
- Add 'action_scheduler_run_queue_rocket_insights' to events cleanup list
- Ensure queue runner cron is properly removed on plugin uninstall
- Maintain consistency with RUCSS queue runner cleanup pattern

Addresses GitHub feedback about missing uninstall cleanup
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