|
9 | 9 | die( -1 ); |
10 | 10 | } |
11 | 11 |
|
12 | | -// Store the path to the Phar early on for `Utils\phar-safe-path()` function. |
13 | | -define( 'WP_CLI_PHAR_PATH', Phar::running( true ) ); |
| 12 | +// Store the phar stream path for use in determining WP_CLI_ROOT. |
| 13 | +// Using Phar::running(true) returns the phar:// stream wrapper path (e.g., phar:///path/to/file.phar) |
| 14 | +// which ensures consistent path resolution when the phar is renamed. |
| 15 | +$wp_cli_phar_path = Phar::running( true ); |
14 | 16 |
|
15 | | -// Determine WP_CLI_ROOT dynamically based on the actual phar path |
| 17 | +// Store the filesystem path for `Utils\phar_safe_path()` function. |
| 18 | +// Using Phar::running(false) returns just the filesystem path without phar:// protocol. |
| 19 | +define( 'WP_CLI_PHAR_PATH', Phar::running( false ) ); |
| 20 | + |
| 21 | +// Determine WP_CLI_ROOT dynamically based on the actual phar stream path |
16 | 22 | // instead of hardcoding 'phar://wp-cli.phar' to handle renamed phars. |
17 | | -// Use Phar::running(false) to get the phar stream path (e.g., phar:///path/to/file.phar) |
18 | | -// instead of the filesystem path, ensuring consistency when the phar is renamed. |
19 | | -if ( file_exists( Phar::running( false ) . '/php/wp-cli.php' ) ) { |
20 | | - define( 'WP_CLI_ROOT', Phar::running( false ) ); |
| 23 | +if ( file_exists( $wp_cli_phar_path . '/php/wp-cli.php' ) ) { |
| 24 | + define( 'WP_CLI_ROOT', $wp_cli_phar_path ); |
21 | 25 | include WP_CLI_ROOT . '/php/wp-cli.php'; |
22 | | -} elseif ( file_exists( Phar::running( false ) . '/vendor/wp-cli/wp-cli/php/wp-cli.php' ) ) { |
23 | | - define( 'WP_CLI_ROOT', Phar::running( false ) . '/vendor/wp-cli/wp-cli' ); |
| 26 | +} elseif ( file_exists( $wp_cli_phar_path . '/vendor/wp-cli/wp-cli/php/wp-cli.php' ) ) { |
| 27 | + define( 'WP_CLI_ROOT', $wp_cli_phar_path . '/vendor/wp-cli/wp-cli' ); |
24 | 28 | include WP_CLI_ROOT . '/php/wp-cli.php'; |
25 | 29 | } else { |
26 | 30 | echo "Couldn't find 'php/wp-cli.php'. Was this Phar built correctly?"; |
|
0 commit comments