|
9 | 9 | die( -1 ); |
10 | 10 | } |
11 | 11 |
|
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 ); |
16 | | - |
17 | 12 | // Store the filesystem path for `Utils\phar_safe_path()` function. |
18 | 13 | // Using Phar::running(false) returns just the filesystem path without phar:// protocol. |
| 14 | +// This prevents phar_safe_path() from attempting to replace "phar://phar://..." incorrectly. |
19 | 15 | define( 'WP_CLI_PHAR_PATH', Phar::running( false ) ); |
20 | 16 |
|
21 | | -// Determine WP_CLI_ROOT dynamically based on the actual phar stream path |
22 | | -// instead of hardcoding 'phar://wp-cli.phar' to handle renamed phars. |
23 | | -if ( file_exists( $wp_cli_phar_path . '/php/wp-cli.php' ) ) { |
24 | | - define( 'WP_CLI_ROOT', $wp_cli_phar_path ); |
| 17 | +// Use the phar alias 'wp-cli.phar' which is set during phar creation and works |
| 18 | +// regardless of the actual filename. This ensures template paths resolve correctly. |
| 19 | +if ( file_exists( 'phar://wp-cli.phar/php/wp-cli.php' ) ) { |
| 20 | + define( 'WP_CLI_ROOT', 'phar://wp-cli.phar' ); |
25 | 21 | include WP_CLI_ROOT . '/php/wp-cli.php'; |
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' ); |
| 22 | +} elseif ( file_exists( 'phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php' ) ) { |
| 23 | + define( 'WP_CLI_ROOT', 'phar://wp-cli.phar/vendor/wp-cli/wp-cli' ); |
28 | 24 | include WP_CLI_ROOT . '/php/wp-cli.php'; |
29 | 25 | } else { |
30 | 26 | echo "Couldn't find 'php/wp-cli.php'. Was this Phar built correctly?"; |
|
0 commit comments