wp-cli/find-command

Wordpress installation detection doesn't work on Windows

Vincent-HD opened this issue · 0 comments

Hi,
When you are on windows running the command seems to ignore wordpress installations.

The output of the command is completly empty even with many working wordpress installations in the folder:

php wp-cli.phar find "C:\laragon\www" --max_depth=4
+--------------+---------+-------+-------+
| version_path | version | depth | alias |
+--------------+---------+-------+-------+
+--------------+---------+-------+-------+

I checked a little bit in the code and it seems that the code does not support the directory separator difference between Linux and Windows.
I just added the constant DIRECTORY_SEPARATOR in the condition DIRECTORY_SEPARATOR . 'wp-includes/' === substr( $path, -13 ) when trying to detect if it's a Wordpress installations

Now the output seems to be working as expected:

php wp-cli.phar find "C:\laragon\www" --max_depth=4
+--------------------------------------------------------+---------+-------+-------+
| version_path                                           | version | depth | alias |
+--------------------------------------------------------+---------+-------+-------+
| C:\laragon\www\xxxxx\wp-includes/version.php             | 5.9      | 1     |       |
| C:\laragon\www\xxxxx\wp-includes/version.php             | 5.9      | 1     |       |
| C:\laragon\www\xxxxx\wp-includes/version.php             | 5.8.2   | 1     |       |
| C:\laragon\www\xxxxx\wp-includes/version.php             | 5.8.1   | 1     |       |
| C:\laragon\www\xxxxx\wp-includes/version.php             | 5.9      | 1     |       |
+--------------------------------------------------------+---------+-------+-------+

I didn't check the code more in-depth so I don't know if there would be side effect, I will eventually make a pull request