Make the WP-CLI adapter work against real remote hosts#41
Merged
Conversation
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.
6db7217 to
05337ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two things kept the
wp-cli-sshadapter 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--pathdoesn't follow a symlinkedwp-load.php. Some hosts keep WordPress core in a separate directory and symlinkwp-load.phpinto 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 (cdover SSH,cwdlocally) resolves it, the way you'd run wp-cli by hand.export_postsalso ranwp eval-file lib/export-posts.phpon 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 beforeeval-file(and cleaned up afterward).I verified both against a live managed-WordPress test site: with
wp_pathset to the site root (the exact value--pathrejected),list_categoriesand 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— greenruff check lib/ tests/— clean