Automattic / Automattic/cortext

Cap bulk REST operations and add the WP-CLI escape hatch

Open
#175 0 comments 0 reactions 0 assignees View on GitHub
area: performance priority: medium
Dominant language
JavaScript
Stars
51
Forks
2
Avg merge
3h 12m
Merged PRs (30d)
8

Description

## Goal

Bulk REST operations run synchronously today. Large collections can time out or run out of memory. Cap REST requests and send larger jobs through WP-CLI instead.

## Scope

* Cap REST bulk operations at 1000 affected rows.
* For `migrate_rows`, count rows that hold the source value.
* For `delete_dependent_rollups_for_field`, count rows across every rollup that depends on the deleted field.
* Over the cap, return HTTP 400 with `cortext_bulk_op_requires_cli` and a message containing the exact CLI command to run.
* Add uncapped WP-CLI commands with progress and resume:
* `wp cortext migrate-field --from= --to=`
* `wp cortext rebuild-dependent-rollups`
* Add `Cortext\Background\BulkRunner` with a sync implementation so an async runner can be added later without changing callers.

## Acceptance criteria

* `FieldsController::migrate_rows` and `delete_dependent_rollups_for_field` return 400 with the CLI command when the request is above the cap.
* Both CLI commands complete on a large dataset with a progress bar.
* Under-cap behavior is unchanged.

Contributor guide

Open the contributing guide

Research direction

Start by reading FieldsController::migrate_rows and delete_dependent_rollups_for_field, then inspect the existing WP-CLI command structure and bulk-operation callers. Verify the two REST entry points enforce the 1000-row cap and return the exact CLI command, while migrate-field and rebuild-dependent-rollups handle large datasets with progress and resume; under-cap behavior must remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
wordpress
Domain
api, backend, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.