Skip to content

[Push] Serve every push request without loading WordPress#378

Open
adamziel wants to merge 1 commit into
trunkfrom
adamziel/push-no-boot-recovery
Open

[Push] Serve every push request without loading WordPress#378
adamziel wants to merge 1 commit into
trunkfrom
adamziel/push-no-boot-recovery

Conversation

@adamziel

@adamziel adamziel commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

All files-push requests now use a PHP route that does not boot WordPress, so a new push can replace files which broke WordPress startup.

Background

A push can install a plugin which throws while WordPress starts. If push_create goes through WordPress, the next push cannot start and replace that plugin.

This change

Create, upload, status, commit, and remove now use one push URL. The WordPress route serves pull requests only and rejects every push_* request.

push_create uses the connection token. It returns a random secret for that push session. The other four operations use the session secret at the same URL.

There is still one implementation of each push operation. Site_Export_HTTP_Server::serve_push() authenticates the request and dispatches it to the existing Site_Export_Push_Endpoints methods. The old WordPress-side push setup and dispatch are removed.

The bundled URL ends in:

/wp-content/plugins/reprint-exporter/push.php

The Reprint Exporter settings screen shows the exact URL. Pass it to files-push instead of ?reprint-api:

php reprint.phar files-push "https://example.com/wp-content/plugins/reprint-exporter/push.php" \
  --state-dir="/path/to/reprint-state" \
  --fs-root="/path/to/local-tree" \
  --secret="the-target-connection-token"

The bundled route reads DOCUMENT_ROOT, uses its private sibling reprint directory, and excludes its own plugin directory from push.

Enabling push writes the connection token to the mode-0600 <reprint-directory>/.reprint/push-config.php. The file returns a PHP array and prints nothing. Each push session keeps its secret and policy in a mode-0600 push-metadata.php, which also returns an array without printing it. Removing push-config.php blocks new sessions without breaking a session already in progress.

Some hosts block direct PHP below wp-content/plugins, or use different server-owned paths. Those hosts must expose another PHP URL which does not load WordPress:

require_once '/srv/reprint-exporter/vendor/autoload.php';

$connection_secret = ($_GET['endpoint'] ?? null) === 'push_create'
    ? Site_Export_HTTP_Server::load_push_connection_secret('/srv/reprint/push-config.php')
    : null;

Site_Export_HTTP_Server::serve_push([
    'connection_secret' => $connection_secret,
    'docroot' => '/srv/www/public',
    'reprint_directory' => '/srv/reprint',
    'excluded_paths' => ['reprint-push.php'],
]);

Give that URL directly to files-push. The WordPress site_export_api_options filter no longer configures push.

Testing

Push a plugin which makes the WordPress route return HTTP 500. Replace the local plugin with a safe version and run files-push again with the same state directory. Confirm that the second run creates a new push session and repairs the site through push.php.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Pull pipeline performance — large-directory

Site: large-directory · 2,000+ plus targeted file-transfer scenarios files · 10,000 posts · 25,000 postmeta · PHP 8.5.8

Stage PR trunk Δ Status Details
playground-sqlite-db-pull 9.88 s 9.52 s ⚪ +359 ms (+3.8%) condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
trunk: condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
playground-sqlite-db-apply 3.60 s 3.58 s ⚪ +25 ms (+0.7%) condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
trunk: condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
Total 13.48 s 13.10 s ⚪ +384 ms (+2.9%)

Numbers carry runner noise; treat single-run deltas as directional, not authoritative.

📈 Trunk performance history — commit-by-commit timeline.

@adamziel
adamziel force-pushed the adamziel/push-no-boot-recovery branch from e7cc342 to 9ce62b0 Compare July 20, 2026 19:05
@adamziel
adamziel changed the base branch from adamziel/push-journal-clear-planning to trunk July 20, 2026 19:05
@adamziel
adamziel force-pushed the adamziel/push-no-boot-recovery branch 2 times, most recently from c08131b to 5767c1b Compare July 20, 2026 21:17
@adamziel adamziel changed the title [Push] Resume document-root commits without WordPress boot [Push] Route push session work outside WordPress Jul 20, 2026
@adamziel
adamziel force-pushed the adamziel/push-no-boot-recovery branch 3 times, most recently from 16ea739 to 40c8d42 Compare July 20, 2026 23:52
@adamziel
adamziel force-pushed the adamziel/push-no-boot-recovery branch from 40c8d42 to cb8dff1 Compare July 21, 2026 01:20
@adamziel adamziel changed the title [Push] Route push session work outside WordPress [Push] Serve every push request without loading WordPress Jul 21, 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.

1 participant