Skip to content

Feature/migration status#2

Closed
Shamim-97 wants to merge 10 commits intomainfrom
feature/migration-status
Closed

Feature/migration status#2
Shamim-97 wants to merge 10 commits intomainfrom
feature/migration-status

Conversation

@Shamim-97
Copy link

@Shamim-97 Shamim-97 commented Mar 3, 2026

Summary by CodeRabbit

  • New Features

    • Migration status and upgrade operations are now accessible via REST API endpoints for enhanced integration capabilities.
    • Admin notice dismissal has been updated to use REST API instead of AJAX.
    • Background process progress tracking is now available to monitor long-running operations.
  • Documentation

    • Added installation instructions to README with guidance for setting up the package via Composer.

mrabbani and others added 10 commits February 26, 2026 12:29
Adds phpcs.xml.dist configuration, GitHub Actions workflow for
PHP linting, and PHPCS dev dependencies in composer.json.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add MigrationStatus class for querying per-migration execution history
- Log migration start/complete/failed in MigrationManager::do_upgrade()
- Add get_progress() to BackgroundProcess for completion ratio tracking
- Add REST endpoint GET {prefix}/v1/migration/status
- Update developer guide with status API and progress documentation
- Add comprehensive tests for all new functionality

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove DismissalHandler (AJAX dismissal) and merge dismiss endpoint
  into NoticeRESTController as POST /notices/dismiss
- Extract migration REST endpoints from MigrationHooks into dedicated
  MigrationRESTController with GET /migration/status and POST
  /migration/upgrade
- Rename NotificationHelper::ajax_action() to rest_action() with
  REST-oriented signature (endpoint, method, nonce)
- Add WP REST class stubs to test bootstrap for Brain\Monkey compat
- Update tests and developer guide to reflect all changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…er config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `static` return type requires PHP 8.0+ but the package supports
PHP 7.4+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
str_starts_with() requires PHP 8.0+ but the package supports PHP 7.4+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add file-level doc comments with @Package tags to all source files
- Add missing short descriptions to constructor doc blocks
- Add missing @param and @throws tags to method doc blocks
- Fix Yoda conditions and replace short ternaries
- Fix multi-line function call formatting in QueryResult
- Suppress DirectDatabaseQuery/PreparedSQL rules for query builder files
  in phpcs.xml.dist (false positives for internal $wpdb->prepare usage)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix equals sign alignment in SqlQuery, BaseDataStore, and BaseModel
- Suppress reserved keyword parameter name warnings (namespace, object,
  class are valid names in this context)
- Suppress unused function parameter warnings (required by WP filter
  callbacks and REST handler signatures)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between a98fd08 and 447e49b.

📒 Files selected for processing (43)
  • .github/workflows/php-lint.yml
  • .github/workflows/php-test.yml
  • README.md
  • composer.json
  • docs/developer-guide.md
  • phpcs.xml.dist
  • src/AdminNotification/Contracts/NoticeProviderInterface.php
  • src/AdminNotification/DismissalHandler.php
  • src/AdminNotification/Notice.php
  • src/AdminNotification/NoticeManager.php
  • src/AdminNotification/NoticeRESTController.php
  • src/AdminNotification/NotificationHelper.php
  • src/Cache/CacheNameSpaceTrait.php
  • src/Cache/Contracts/CacheEngineInterface.php
  • src/Cache/ObjectCache.php
  • src/Cache/WPCacheEngine.php
  • src/DataLayer/Bridge/WCDataStoreBridge.php
  • src/DataLayer/Bridge/WCModelAdapter.php
  • src/DataLayer/Contracts/DataStoreInterface.php
  • src/DataLayer/Contracts/ModelInterface.php
  • src/DataLayer/DataLayerFactory.php
  • src/DataLayer/DataStore/BaseDataStore.php
  • src/DataLayer/DataStore/SqlQuery.php
  • src/DataLayer/DateTime.php
  • src/DataLayer/Model/BaseModel.php
  • src/DataLayer/QueryResult.php
  • src/Migration/BackgroundProcess.php
  • src/Migration/BaseMigration.php
  • src/Migration/Contracts/MigrationInterface.php
  • src/Migration/MigrationHooks.php
  • src/Migration/MigrationManager.php
  • src/Migration/MigrationRESTController.php
  • src/Migration/MigrationRegistry.php
  • src/Migration/MigrationStatus.php
  • src/Migration/Schema.php
  • tests/bootstrap.php
  • tests/phpunit/tests/AdminNotification/DismissalHandlerTest.php
  • tests/phpunit/tests/AdminNotification/NoticeRESTControllerTest.php
  • tests/phpunit/tests/AdminNotification/NotificationHelperTest.php
  • tests/phpunit/tests/Migration/BackgroundProcessTest.php
  • tests/phpunit/tests/Migration/MigrationManagerTest.php
  • tests/phpunit/tests/Migration/MigrationRESTControllerTest.php
  • tests/phpunit/tests/Migration/MigrationStatusTest.php
💤 Files with no reviewable changes (2)
  • tests/phpunit/tests/AdminNotification/DismissalHandlerTest.php
  • src/AdminNotification/DismissalHandler.php

📝 Walkthrough

Walkthrough

This pull request introduces CI/CD workflows for linting and testing, establishes a REST-based migration system with progress tracking and logging, refactors admin notification dismissal from AJAX to REST endpoints, adds extensive PHPDoc documentation across the codebase, and removes the legacy AJAX-based DismissalHandler class in favor of REST endpoints.

Changes

Cohort / File(s) Summary
CI/CD Workflows
.github/workflows/php-lint.yml, .github/workflows/php-test.yml
Added GitHub Actions workflows: php-lint.yml triggers PHPCS linting on code changes with cs2pr integration; php-test.yml runs PHPUnit tests across PHP 7.4–8.4 with dependency management and concurrency control.
Linting Configuration
phpcs.xml.dist, composer.json, README.md
Added PHPCS ruleset targeting src/ with WordPress Coding Standards, PHP 7.4+ compatibility checks, and specific exclusions; added linting dev dependencies (squizlabs/php_codesniffer, wpcs, phpcompatibility-wp); added installation documentation and lint scripts to composer.json.
Admin Notification REST Migration
src/AdminNotification/DismissalHandler.php, src/AdminNotification/NoticeRESTController.php, src/AdminNotification/NotificationHelper.php, src/AdminNotification/Notice.php, src/AdminNotification/NoticeManager.php, src/AdminNotification/Contracts/NoticeProviderInterface.php
Removed AJAX-based DismissalHandler; added REST endpoint (/notices/dismiss) in NoticeRESTController; converted NotificationHelper from ajax_action to rest_action with endpoint/method parameters; added comprehensive PHPDoc blocks across AdminNotification classes.
Migration REST API
src/Migration/MigrationRESTController.php, src/Migration/MigrationStatus.php, src/Migration/MigrationManager.php, src/Migration/MigrationHooks.php
Introduced MigrationRESTController with GET status and POST upgrade endpoints; added MigrationStatus reader class for log/summary queries; enhanced MigrationManager with constructor, logging helpers (log_migration_start/complete/failed), get_status() and get_log_option_key() methods; removed AJAX upgrade handler from MigrationHooks.
Background Process Progress Tracking
src/Migration/BackgroundProcess.php
Added progress tracking via total item counts in options; introduced get_progress() exposing is_processing, total, completed, remaining, percentage; added get_total_key() for option key management; tracks progress across queue push, completion, and cancellation.
Data Layer Documentation & Enhancement
src/DataLayer/BaseDataStore.php, src/DataLayer/DataStore/SqlQuery.php, src/DataLayer/Model/BaseModel.php, src/DataLayer/QueryResult.php, src/DataLayer/DataLayerFactory.php, src/DataLayer/Bridge/WCDataStoreBridge.php, src/DataLayer/Bridge/WCModelAdapter.php, src/DataLayer/Contracts/..., src/DataLayer/DateTime.php
Added constructor to SqlQuery for context initialization; changed BaseModel::find return type from ?static to ?self; changed QueryResult::from_array return type from static to self; added comprehensive PHPDoc blocks for parameters and exceptions; modified table prefix check from str_starts_with to strpos; added PHPDoc headers to interfaces and utilities.
Cache Layer Documentation
src/Cache/WPCacheEngine.php, src/Cache/ObjectCache.php, src/Cache/CacheNameSpaceTrait.php, src/Cache/Contracts/CacheEngineInterface.php
Added constructor to WPCacheEngine accepting prefix parameter; added PHPDoc blocks documenting methods and parameters across cache classes and interfaces; no functional changes to behavior.
Migration Documentation & Configuration
src/Migration/BaseMigration.php, src/Migration/Contracts/MigrationInterface.php, src/Migration/MigrationRegistry.php, src/Migration/Schema.php, docs/developer-guide.md
Added constructor to MigrationRegistry; added PHPDoc headers to interfaces and schema utilities; updated developer guide to document new REST endpoints (/migration/status, /migration/upgrade), MigrationStatus usage, and REST-based progress monitoring replacing AJAX patterns.
Test Infrastructure & REST Stubs
tests/bootstrap.php
Added fallback class definitions for WP_REST_Server, WP_REST_Request, and WP_REST_Response to enable testing without WordPress environment.
Admin Notification Tests
tests/phpunit/tests/AdminNotification/DismissalHandlerTest.php, tests/phpunit/tests/AdminNotification/NoticeRESTControllerTest.php, tests/phpunit/tests/AdminNotification/NotificationHelperTest.php
Removed DismissalHandlerTest (113 lines); added NoticeRESTControllerTest covering route registration, get_admin_notices with scope filtering, dismiss_notice with key/duplicate handling, and permission checks; updated NotificationHelperTest to test rest_action instead of ajax_action with endpoint/method parameters.
Migration Tests
tests/phpunit/tests/Migration/BackgroundProcessTest.php, tests/phpunit/tests/Migration/MigrationManagerTest.php, tests/phpunit/tests/Migration/MigrationRESTControllerTest.php, tests/phpunit/tests/Migration/MigrationStatusTest.php
Enhanced BackgroundProcessTest with progress tracking assertions; expanded MigrationManagerTest with logging lifecycle tests; added MigrationRESTControllerTest covering status/upgrade endpoints and permission enforcement; added comprehensive MigrationStatusTest for log retrieval, summary aggregation, and is_running detection.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MigrationRESTController
    participant MigrationManager
    participant MigrationStatus
    participant WordPress Options

    Client->>MigrationRESTController: GET /migration/status
    MigrationRESTController->>MigrationManager: get_status()
    MigrationManager->>MigrationStatus: __construct(manager)
    MigrationStatus->>WordPress Options: get_option(migration_log)
    WordPress Options-->>MigrationStatus: log array
    MigrationStatus->>MigrationStatus: get_summary()
    MigrationStatus-->>MigrationManager: summary data
    MigrationManager-->>MigrationRESTController: MigrationStatus instance
    MigrationRESTController-->>Client: WP_REST_Response (status 200)

    Client->>MigrationRESTController: POST /migration/upgrade
    rect rgba(100, 150, 255, 0.5)
        MigrationRESTController->>MigrationManager: check upgrade required
    end
    MigrationRESTController->>MigrationManager: do_upgrade()
    MigrationManager->>WordPress Options: update_option(log_running)
    MigrationManager->>MigrationManager: run migrations
    MigrationManager->>WordPress Options: update_option(log_completed)
    MigrationManager-->>MigrationRESTController: success/error
    MigrationRESTController-->>Client: WP_REST_Response (status 201 or 400)
Loading
sequenceDiagram
    participant Client
    participant NoticeRESTController
    participant WordPress Options
    participant Cache/Memory

    Client->>NoticeRESTController: POST /notices/dismiss
    NoticeRESTController->>WordPress Options: get_option(dismissed_notices)
    WordPress Options-->>NoticeRESTController: dismissed array
    NoticeRESTController->>NoticeRESTController: add key to array
    rect rgba(100, 150, 255, 0.5)
        NoticeRESTController->>WordPress Options: update_option(dismissed_notices)
    end
    WordPress Options-->>NoticeRESTController: updated
    NoticeRESTController-->>Client: WP_REST_Response (success)

    Client->>NoticeRESTController: GET /notices
    NoticeRESTController->>Cache/Memory: get_notices(scope)
    Cache/Memory-->>NoticeRESTController: notices array
    NoticeRESTController-->>Client: WP_REST_Response (notices)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

This PR involves substantial architectural changes across multiple systems: a new REST-based migration framework with logging and progress tracking, refactoring of admin notifications from AJAX to REST patterns, extensive PHPDoc documentation additions, removal of legacy classes, and comprehensive test coverage. While individual changes are largely consistent patterns, the heterogeneity of affected subsystems (migrations, admin notifications, data layer, cache layer), introduction of new public APIs and classes, and logic density in the migration status/logging system necessitate careful review of control flow, error handling, and integration points.

Poem

🐰 A REST-ful migration hops along,
No AJAX tricks to lead us wrong,
With progress tracked through ev'ry bound,
And logs so crisp, both safe and sound!
CodeSniffer checks our code with care,
A code review beyond compare!

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Shamim-97 Shamim-97 closed this Mar 3, 2026
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