Skip to content
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

Path::get_root is broken using wp-cli if wordpress installation has a different site and home url, w #1162

Open
duritong opened this issue Jan 19, 2017 · 0 comments

Comments

@duritong
Copy link
Contributor

Description of issue

Running backupwordpress through wp-cli, on an installation that has a different home and site url, always failed with: "Invalid root path"

Using --root on the cli works around this problem.

Details

I tracked this down to https://github.com/humanmade/backupwordpress/blob/master/classes/class-backupwordpress-wp-cli-command.php#L68-L70

Which ends up in Path::get_home_path through Path::get_root and Path::get_calculated_root. In Path::get_home_path a check is being made, whether the siteurl and home are the same.

https://github.com/humanmade/backupwordpress/blob/master/classes/class-path.php#L110

In a case where the installation has a different home than siteurl, this enters this branch, and then it is tried to set the home_path based on the SCRIPT_FILENAME.

https://github.com/humanmade/backupwordpress/blob/master/classes/class-path.php#L113

However, if backupwordpress is used through wp-cli, the SCRIPT_FILENAME for example is the phar file of wp-cli, (e.g. /usr/libexec/wp-cli/wp-cli.phar) and so everything breaks and home is set to an empty string in the end, meaning root is an empty string and so the above error is fired.

When we pass --root=/foo on the cli to the backup command, everything works, as Path::get_calculated_root returns the manually set root-directory.

As I don't fully understand the reasoning behind the branch in Path::get_home_path and the tricks behind using SCRIPT_FILENAME, I'm not really able to say how it should be fixed and I guess somebody with more experience behind this particular code has to look into it.

duritong added a commit to duritong/puppet-wordpress that referenced this issue Jan 19, 2017
This is mainly to work around a bug in backupwordpress if home and
siteurl are not the same.

See xibodevelopment/backupwordpress#1162 for
technical details
@katmoody katmoody self-assigned this Jan 19, 2017
@katmoody katmoody added the Bug label Jul 18, 2017
@roborourke roborourke added the P2 label Sep 7, 2017
@katmoody katmoody removed their assignment Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants