Skip to content

Make the WP-CLI adapter work against real remote hosts#41

Merged
jeherve merged 1 commit into
m:mainfrom
jeherve:fix/wp-cli-remote-host-compat
Jun 3, 2026
Merged

Make the WP-CLI adapter work against real remote hosts#41
jeherve merged 1 commit into
m:mainfrom
jeherve:fix/wp-cli-remote-host-compat

Conversation

@jeherve

@jeherve jeherve commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Two things kept the wp-cli-ssh adapter from working on some managed WordPress hosts, both found while testing against a real site.

The adapter passed --path=<wp_path> to every command, but wp-cli's --path doesn't follow a symlinked wp-load.php. Some hosts keep WordPress core in a separate directory and symlink wp-load.php into the docroot, so every command failed with "This does not seem to be a WordPress installation" even though the install was right there. Running wp from the WP directory instead (cd over SSH, cwd locally) resolves it, the way you'd run wp-cli by hand.

export_posts also ran wp eval-file lib/export-posts.php on the remote, which assumed this repo's PHP script already lived on the server. It doesn't, so the export failed before it started. Now the script is referenced by absolute path locally, and uploaded to a temp path on the remote before eval-file (and cleaned up afterward).

I verified both against a live managed-WordPress test site: with wp_path set to the site root (the exact value --path rejected), list_categories and a full 9,072-post export both came back clean. I added regression tests for the run-from-directory behavior and the script upload.

Testing

  • python3 -m unittest discover tests — green
  • ruff check lib/ tests/ — clean

@jeherve jeherve self-assigned this Jun 3, 2026
Two issues kept the wp-cli-ssh adapter from running on some managed hosts:

- It passed --path=<wp_path>, but wp-cli's --path does not follow a
  symlinked wp-load.php (some hosts keep core in a separate directory and
  symlink wp-load.php into the docroot), so every command failed with
  'This does not seem to be a WordPress installation'. Run wp from the WP
  directory instead (cd over SSH, cwd locally), which resolves the install
  regardless of symlinks.

- export_posts ran 'wp eval-file lib/export-posts.php' on the remote,
  assuming the repo's PHP script already lived on the server. Reference the
  script by absolute path locally, and upload it to a temp path on the
  remote before eval-file (cleaning it up afterward).

Verified live against a real managed-WordPress test site: list_categories
and a 9,072-post export both succeed with wp_path set to the site root (the
value --path previously rejected). Add regression tests for the
run-location and script-upload behavior.
@jeherve jeherve force-pushed the fix/wp-cli-remote-host-compat branch from 6db7217 to 05337ba Compare June 3, 2026 07:47
@jeherve jeherve merged commit 60348e7 into m:main Jun 3, 2026
3 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