Skip to content

Add migration status tracking, PHPCS, CI, and replace AJAX with REST#1

Merged
mrabbani merged 9 commits intomainfrom
feature/migration-status
Feb 26, 2026
Merged

Add migration status tracking, PHPCS, CI, and replace AJAX with REST#1
mrabbani merged 9 commits intomainfrom
feature/migration-status

Conversation

@mrabbani
Copy link
Member

@mrabbani mrabbani commented Feb 26, 2026

Summary

  • PHPCS: Add WordPress Coding Standards config (phpcs.xml.dist) and CI lint workflow
  • CI: Add GitHub Actions workflow for PHPUnit tests across PHP 7.4–8.3
  • Migration Status: Add MigrationStatus class for tracking per-migration execution state (pending, running, completed, failed) with summary, log, and timing
  • Background Process Progress: Add progress tracking (get_progress()) to BackgroundProcess with total/processed/percentage
  • Migration REST Controller: Dedicated MigrationRESTController with GET /migration/status and POST /migration/upgrade endpoints
  • AJAX → REST: Replace all wp_ajax_ hooks with REST API endpoints across the package
    • Remove DismissalHandler — dismiss endpoint merged into NoticeRESTController (POST /notices/dismiss)
    • Extract migration REST from MigrationHooks into MigrationRESTController
    • Rename NotificationHelper::ajax_action()rest_action()
  • Tests: 206 tests passing with full coverage for new classes

Test plan

  • All 206 PHPUnit tests pass
  • grep -r 'wp_ajax\|check_ajax_referer\|ajax_action\|ajax_data\|wp_send_json' src/ returns no matches
  • Verify CI workflows run on GitHub
  • Integration test with example plugin (wpkit-task-manager)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • REST endpoints for migration status, upgrades, and admin-notice dismissal; migration lifecycle logging and runtime progress reporting.
  • Documentation

    • Developer guide updated with REST endpoint specs, progress/status introspection, and new tracking keys.
  • Tests

    • Added/updated tests for REST controllers, migration status, background progress, and notification flows.
  • Chores

    • CI workflows for PHP linting and multi-version unit testing; coding-standard configuration and dev tooling added.
  • Breaking Changes

    • AJAX-based dismissal and upgrade flows removed; some return-type/signature tightening.

mrabbani and others added 4 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>
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaced AJAX admin flows with REST endpoints for migrations and notices; added MigrationRESTController, MigrationStatus, migration logging and progress tracking; removed DismissalHandler and AJAX upgrade hook; updated NotificationHelper to rest_action; added PHPCS and PHPUnit CI workflows, PHPCS config, and corresponding tests/bootstrap updates.

Changes

Cohort / File(s) Summary
CI Workflows
.github/workflows/php-lint.yml, .github/workflows/php-test.yml
Add PHPCS lint workflow and PHPUnit matrix workflow (multiple PHP versions), concurrency, path filters, and cs2pr reporting.
Composer & PHPCS config
composer.json, phpcs.xml.dist
Add PHPCS/WPCS/PHPCompatibility dev deps, allow-plugins config and composer scripts (phpcs, phpcbf, lint); new phpcs ruleset targeting src with WP & PHPCompatibility rules and specific exclusions.
Migration REST & Services
src/Migration/MigrationRESTController.php, src/Migration/MigrationManager.php, src/Migration/MigrationStatus.php, src/Migration/MigrationRegistry.php
New MigrationRESTController with status/upgrade routes; MigrationManager adds logging helpers and accessors; new MigrationStatus read-only service; MigrationRegistry gains constructor; REST permission checks added.
Background processing
src/Migration/BackgroundProcess.php, src/Migration/MigrationHooks.php
Add total-item tracking, get_progress() API, and total-key cleanup; remove AJAX upgrade handler and its wp_ajax registration; MigrationHooks obtains constructor.
Admin notifications (REST) & helper
src/AdminNotification/NoticeRESTController.php, src/AdminNotification/NotificationHelper.php, src/AdminNotification/DismissalHandler.php
Delete AJAX DismissalHandler; NoticeRESTController adds dismiss_notice REST route and permission checks; NotificationHelper::ajax_action → rest_action signature and payload shape changed (endpoint, method, rest_data nonce).
Models / Query types
src/DataLayer/Model/BaseModel.php, src/DataLayer/QueryResult.php
Narrowed factory/ finder return types staticself for find() and from_array(), and added pagination metadata to QueryResult.
DataStore / SQL / Docs
src/DataLayer/DataStore/BaseDataStore.php, src/DataLayer/DataStore/SqlQuery.php, various docblock-only files (src/...)
Docblock additions across many files; BaseDataStore: minor prefix check change (strpos !== 0) and added exception/cache invalidation notes; SqlQuery and many classes get header/constructor docblocks.
Cache & Contracts docblocks
src/Cache/*, src/DataLayer/Contracts/*
Added file-level PHPDoc headers to cache and data-layer contract files; no signature changes.
Tests & test bootstrap
tests/bootstrap.php, tests/phpunit/tests/...
Add REST stubs in bootstrap; remove DismissalHandler tests; add/update tests for NoticeRESTController, MigrationRESTController, MigrationStatus, MigrationManager, BackgroundProcess (total counter), NotificationHelper (rest_action).
Docs
docs/developer-guide.md
Document new REST routes (migration/status, migration/upgrade, notices/admin, notices/dismiss), migration logging/progress option keys, and removal of AJAX dismissal flow.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(220,240,255,0.5)
    participant Client as "Client (Admin UI)"
    participant REST as "WP REST API"
    participant MigrationCtrl as "MigrationRESTController"
    participant Manager as "MigrationManager"
    participant Status as "MigrationStatus"
    end

    Client->>REST: GET /migration/status
    REST->>MigrationCtrl: get_status(request)
    MigrationCtrl->>Manager: get_status()
    Manager->>Status: build summary & log
    Status-->>Manager: summary + log
    Manager-->>MigrationCtrl: status data
    MigrationCtrl-->>REST: 200 {status}
    REST-->>Client: 200 {status}
Loading
sequenceDiagram
    rect rgba(230,255,230,0.5)
    participant AdminUI as "Admin UI"
    participant REST as "WP REST API"
    participant NoticeCtrl as "NoticeRESTController"
    participant Options as "Options Store"
    end

    AdminUI->>REST: POST /notices/dismiss {key, nonce}
    REST->>NoticeCtrl: dismiss_notice(request)
    NoticeCtrl->>Options: get_option({prefix}_dismissed_notices)
    Options-->>NoticeCtrl: [keys]
    NoticeCtrl->>Options: update_option({prefix}_dismissed_notices)
    Options-->>NoticeCtrl: OK
    NoticeCtrl-->>REST: 200 {success:true}
    REST-->>AdminUI: 200 {success:true}
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 I hopped from AJAX into REST,

I logged each step and did my best,
Counters ticking, progress bright,
Tests and lints keep burrow tight,
Carrots, code, and peaceful night.


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.

mrabbani and others added 5 commits February 26, 2026 14:46
…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>
@mrabbani mrabbani merged commit a98fd08 into main Feb 26, 2026
14 checks passed
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.

1 participant