Skip to content

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

@priethor

Description

@priethor

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 <id> --from=<value> --to=<value>
    • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions