-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bedrock Installation Paths with WP-CLI Adapter #590
Comments
To assist in replicating the issue, an example Docker environment has been created This is configured with a working configuration using the |
Damn, I just filled an exact similar issue here #591 Sorry about that. I started writing it yesterday and yours was not here. |
@nlemoine Ha! It's pretty remarkable how close our issue postings are. |
Indeed! |
And they are both terrific. I'll take the time to dive-in asap. |
Further reading maybe related #479 |
For sure related reading #513 |
I've noticed something during a first investigation: taking techical notes and thoughts. I feel that we have a liar method which is working behind the scenes: https://github.com/welaika/wordmove/blob/master/lib/wordmove/wordpress_directory.rb#L33-L40 What I see is that custom paths are accepted in a relative format (e.g.: What we'd need there should be something like
thus a resolved path. Moreover Wordmove should take in consideration if the custom paths are absolute or relative and control the subsequent behaviours (maybe always resolving to an absolute path?). Maybe in https://github.com/welaika/wordmove/blob/master/lib/wordmove/deployer/ssh.rb#L98-L105 we should not always pass Another issue to work on, as pointed out in this bug report, could be to remove the hardcoded So I'd like to deepen a "bit" - read it: a lot - more on this one. |
@pioneerskies That sounds like a good start. I think in an effort to avoid duplicate configurations (ie: configuring WP CLI in both movefile.yml as well as wp-cli.yml), would it be possible to perform a preliminary file existence check for wp-cli.yml at Specifically in Bedrock, I know that I typically keep movefile.yml right next to wp-cli.yml, so WP CLI shouldn't have a problem autodetecting it if --path is left out in the case that wp-cli.yml passes the existence check. In this case, we could theoretically point As far as paths go, it sounds like using Ruby to first expand relative paths to absolute would be the best and least error-prone approach. The only idea I have in this regard is that you would probably want to expand only in cases where you know that a given path is relative vs absolute. We know that If supporting both, is it as simple as checking each path's first character to determine absolute vs relative? ie: If the first character of a path is a slash, it's considered absolute? If enforcing absolute/relative-only paths, I don't know if that would be considered a BC break. Not sure how hardcore you are about sticking to semver, but it's something to consider. These are just some thoughts. Unfortunately, I don't know Ruby well enough to be able to contribute to the codebase, but hopefully some of this makes sense and wouldn't be too terribly difficult to implement. If there are challenges around any of this, let me know. I'm happy to at least try and help think through this. |
@pioneerskies I decided to try my hand at a draft PR anyway despite having no background in Ruby. It should cover at least for the wp-cli.yml check. I'll do some digging to see if I can create another PR to cover for the relative vs absolute conundrum, but it's likely that I'll either take too long, or my inexperience with Ruby will lead to a less optimal or naive solution. |
@pioneerskies It looks like Is it as simple as adjusting the |
I would also go that way first, before making too much changes. Check the presence of a WP-CLI will also work fine without
|
Keep on annotating things:
This is eversimplistic: firstly wodmove accepts arbitrary config paths through command line options, so
Fortunately we have {
"php_binary_path": "/usr/local/Cellar/php@7.2/7.2.28/bin/php",
"global_config_path": false,
"project_config_path": "/Users/fuzzy/dev/sshwordmove/wp-cli.yml",
"wp_cli_dir_path": "phar://wp-cli.phar/vendor/wp-cli/wp-cli",
"wp_cli_packages_dir_path": "/Users/fuzzy/.wp-cli/packages/",
"wp_cli_version": "2.4.0",
"system_os": "Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64",
"shell": "/usr/local/bin/fish"
} avoiding us the responsibility to search for Going further, having this path: /foo/bar we can also use this one other command to do the magic: {
"path": {
"runtime": "=<path>",
"file": "<path>",
"synopsis": "",
"default": null,
"multiple": false,
"desc": "Path to the WordPress files.",
"current": "\/foo\/bar" // <---- here we are!
}
} |
When Wordmove was wrote was probably unrealistic to think about setup with the core in a different directory tree than the rest of the "components" (I mean upoads, plugins, etc.). So yes: these days the documentation itself sounds unclear; actually, given the code we have in current stable, we should state to use relative paths and implement a |
I'd say |
Both your point are invalidated if you run |
@pioneerskies
You raise an interesting point. Because WP CLI uses the CWD by default, that changes its behavior and whether or not it can find a Since we're already planning on expanding the wp-cli.yml existence check to determine both that the file exists and that the That should fix the CWD problem, and we will know that --path will always be set. No Does that work? |
What's the difference between parsing the file and set the BTW I left some examples in the PR |
@pioneerskies Your code examples offered some insight into an approach that I think would ultimately yield the same result I was looking for. Conceptually, I was planning on using I'll use your examples and try to expand on my logic in my PR to support that approach. Thank you for all your ideas! |
Using the latest version of Wordmove with Bedrock, there appears to be a strange conflict between how Wordmove resolves its paths and how paths are being sent to WP CLI to determine the Core Wordpress installation.
After some experimentation, I've narrowed down this behavior to a few scenarios specific to Bedrock that might be worth looking into.
For reference, the basic directory structure of Bedrock can be represented as follows:
Scenario 1 - Uploads Push/Pull
All commands are executed using
wordmove pull -e dev -u
Configuration Test 1: Absolute paths and Wordpress root - Fails
When using this type of configuration against a Bedrock installation, no uploads are recognized and the command completes without downloading images.
Configuration Test 2: Relative paths and Wordpress root - Fails
A similar setup using relative paths also completes without downloading images:
Configuration Test 3: Relative paths and Document root - Succeeds
When pointing the wordpress_path one level back to Document root however, the following setup succeeds and all images are downloaded without issue
Scenario 2 - Database Push/Pull
All commands are executed using
wordmove pull -e dev -d
Configuration Test 1: Absolute paths and Wordpress root - Fails
Ordinarily I would expect this to succeed, but the SQL Dump execution fails due to the Wordpress path being concatenated with the wp_content path, resulting in an error:
Can't create/write to file '/var/www/html/web/wp/var/www/html/web/wp/wp-content/local-backup-1587063366.sql'
Configuration Test 2: Relative paths and Wordpress root - Succeeds
This command succeeds without issue. It is understood that the wp_content path can be left out in this case, as this is the default value of this path.
Configuration Test 3: Relative paths and Document root - Fails
This is where SQL Dump will succeed, but WP CLI fails with the following error:
Error: This does not seem to be a WordPress installation.
Pass --path=
path/to/wordpress
or runwp core download
The Problem
Running either
wordmove pull -e dev -d
orwordmove pull -e dev -u
in isolation each has a working configuration when WP CLI is the selected adapter.Unfortunately, no combination of settings would allow us to run the following command with success:
wordmove pull -e dev -du
Absolute paths against Wordpress root fails in both scenarios.
Relative paths against Wordpress root fails in Scenario 1 and succeeds in Scenario 2
Relative paths against Document root succeeds in Scenario 1 and fails in Scenario 2
The only way around this at the moment is to use the
default
adapter and use relative paths against Document root. I would prefer to avoid this if I can.The Solution
I'm not sure how paths are being resolved, but the SQL Dump output path should probably have a check to determine whether or not absolute vs relative is used, and concatenate only when relative paths are specified.
When it comes to path resolution for rsync, neither absolute paths nor relative paths appear to be honored properly if the wordpress_path setting is one level deeper than the rest of the paths. I'm not even sure that wordpress_path should even have a role in determining the path for uploads, themes, plugins, or languages, but I can't be certain since I don't know what code is driving this behavior.
Lastly, it looks as if WP CLI will fail no matter what if wordpress_path is not pointing to a Wordpress instance. That means that even if we have a wp-cli.yml file in our project root to tell it where Wordpress actually is, it's being ignored in favor of the --path flag and we still see the This does not seem to be a WordPress installation error.
Let me know if any of this is unclear or if you need me to test anything further. Myself and my team have been using Wordmove for years and love everything about it!
Environment
The text was updated successfully, but these errors were encountered: