Skip to content

Commit c39178a

Browse files
authored
Merge branch 'main' into fix/check-for-root-earlier
2 parents c91e022 + a9fabc0 commit c39178a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1064
-430
lines changed

.github/workflows/automerge.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ phpcs.xml
1313
composer.lock
1414
.phpunit.result.cache
1515
.phpunit.cache
16+
/build/logs

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
"mustache/mustache": "^2.14.1",
1414
"symfony/finder": ">2.7",
1515
"wp-cli/mustangostang-spyc": "^0.6.3",
16-
"wp-cli/php-cli-tools": "~0.11.2"
16+
"wp-cli/php-cli-tools": "~0.12.4"
1717
},
1818
"require-dev": {
19-
"roave/security-advisories": "dev-latest",
2019
"wp-cli/db-command": "^1.3 || ^2",
2120
"wp-cli/entity-command": "^1.2 || ^2",
2221
"wp-cli/extension-command": "^1.1 || ^2",
2322
"wp-cli/package-command": "^1 || ^2",
24-
"wp-cli/wp-cli-tests": "^4.0.1"
23+
"wp-cli/wp-cli-tests": "^4.3.10"
2524
},
2625
"suggest": {
2726
"ext-readline": "Include for a better --prompt implementation",
@@ -33,7 +32,8 @@
3332
"johnpbloch/wordpress-core-installer": true
3433
},
3534
"process-timeout": 7200,
36-
"sort-packages": true
35+
"sort-packages": true,
36+
"lock": false
3737
},
3838
"extra": {
3939
"branch-alias": {

features/class-wp-cli.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ Feature: Various utilities for WP-CLI commands
1313
| func |
1414
| proc_open |
1515
| proc_close |
16-
17-

features/cli-bash-completion.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Feature: `wp cli completions` tasks
324324
"""
325325
--prompt=
326326
"""
327-
Then STDOUT should not contain:
327+
And STDOUT should not contain:
328328
"""
329329
--path
330330
"""

features/cli-cache.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Feature: CLI Cache
3737
When I run `wp --require=env-var.php core download --path=/tmp/wp-core --version=4.9 --force`
3838
Then STDERR should be empty
3939

40-
4140
Scenario: Remove all but newest files from cache directory
4241
Given an empty cache
4342
And a file-a-12345.tmp cache file:

features/cli-check-update.feature

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
Feature: Check for updates
2+
3+
Scenario: Ignores updates with a higher PHP version requirement
4+
Given that HTTP requests to https://api.github.com/repos/wp-cli/wp-cli/releases?per_page=100 will respond with:
5+
"""
6+
HTTP/1.1 200
7+
Content-Type: application/json
8+
9+
[
10+
{
11+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978",
12+
"assets_url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/assets",
13+
"upload_url": "https://uploads.github.com/repos/wp-cli/wp-cli/releases/169243978/assets{?name,label}",
14+
"html_url": "https://github.com/wp-cli/wp-cli/releases/tag/v999.9.9",
15+
"id": 169243978,
16+
"node_id": "RE_kwDOACQFs84KFnVK",
17+
"tag_name": "v999.9.9",
18+
"target_commitish": "main",
19+
"name": "Version 999.9.9",
20+
"draft": false,
21+
"prerelease": false,
22+
"created_at": "2024-08-08T03:04:55Z",
23+
"published_at": "2024-08-08T03:51:13Z",
24+
"assets": [
25+
{
26+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
27+
"id": 184590231,
28+
"node_id": "RA_kwDOACQFs84LAJ-X",
29+
"name": "wp-cli-999.9.9.phar",
30+
"label": null,
31+
"content_type": "application/octet-stream",
32+
"state": "uploaded",
33+
"size": 7048108,
34+
"download_count": 722639,
35+
"created_at": "2024-08-08T03:51:05Z",
36+
"updated_at": "2024-08-08T03:51:08Z",
37+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.phar"
38+
},
39+
{
40+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
41+
"id": 184590231,
42+
"node_id": "RA_kwDOACQFs84LAJ-X",
43+
"name": "wp-cli-999.9.9.phar",
44+
"label": null,
45+
"content_type": "application/octet-stream",
46+
"state": "uploaded",
47+
"size": 7048108,
48+
"download_count": 722639,
49+
"created_at": "2024-08-08T03:51:05Z",
50+
"updated_at": "2024-08-08T03:51:08Z",
51+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.manifest.json"
52+
}
53+
],
54+
"tarball_url": "https://api.github.com/repos/wp-cli/wp-cli/tarball/v999.9.9",
55+
"zipball_url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/v999.9.9",
56+
"body": "- Allow manually dispatching tests workflow [[#5965](https://github.com/wp-cli/wp-cli/pull/5965)]\r\n- Add fish shell completion [[#5954](https://github.com/wp-cli/wp-cli/pull/5954)]\r\n- Add defaults and accepted values for runcommand() options in doc [[#5953](https://github.com/wp-cli/wp-cli/pull/5953)]\r\n- Address warnings with filenames ending in fullstop on Windows [[#5951](https://github.com/wp-cli/wp-cli/pull/5951)]\r\n- Fix unit tests [[#5950](https://github.com/wp-cli/wp-cli/pull/5950)]\r\n- Update copyright year in license [[#5942](https://github.com/wp-cli/wp-cli/pull/5942)]\r\n- Fix breaking multi-line CSV values on reading [[#5939](https://github.com/wp-cli/wp-cli/pull/5939)]\r\n- Fix broken Gutenberg test [[#5938](https://github.com/wp-cli/wp-cli/pull/5938)]\r\n- Update docker runner to resolve docker path using `/usr/bin/env` [[#5936](https://github.com/wp-cli/wp-cli/pull/5936)]\r\n- Fix `inherit` path in nested directory [[#5930](https://github.com/wp-cli/wp-cli/pull/5930)]\r\n- Minor docblock improvements [[#5929](https://github.com/wp-cli/wp-cli/pull/5929)]\r\n- Add Signup fetcher [[#5926](https://github.com/wp-cli/wp-cli/pull/5926)]\r\n- Ensure the alias has the leading `@` symbol when added [[#5924](https://github.com/wp-cli/wp-cli/pull/5924)]\r\n- Include any non default hook information in CompositeCommand [[#5921](https://github.com/wp-cli/wp-cli/pull/5921)]\r\n- Correct completion case when ends in = [[#5913](https://github.com/wp-cli/wp-cli/pull/5913)]\r\n- Docs: Fixes for inline comments [[#5912](https://github.com/wp-cli/wp-cli/pull/5912)]\r\n- Update Inline comments [[#5910](https://github.com/wp-cli/wp-cli/pull/5910)]\r\n- Add a real-world example for `wp cli has-command` [[#5908](https://github.com/wp-cli/wp-cli/pull/5908)]\r\n- Fix typos [[#5901](https://github.com/wp-cli/wp-cli/pull/5901)]\r\n- Avoid PHP deprecation notices in PHP 8.1.x [[#5899](https://github.com/wp-cli/wp-cli/pull/5899)]",
57+
"reactions": {
58+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/reactions",
59+
"total_count": 9,
60+
"+1": 4,
61+
"-1": 0,
62+
"laugh": 0,
63+
"hooray": 1,
64+
"confused": 0,
65+
"heart": 0,
66+
"rocket": 4,
67+
"eyes": 0
68+
}
69+
},
70+
{
71+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978",
72+
"assets_url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/assets",
73+
"upload_url": "https://uploads.github.com/repos/wp-cli/wp-cli/releases/169243978/assets{?name,label}",
74+
"html_url": "https://github.com/wp-cli/wp-cli/releases/tag/v777.7.7",
75+
"id": 169243978,
76+
"node_id": "RE_kwDOACQFs84KFnVK",
77+
"tag_name": "v777.7.7",
78+
"target_commitish": "main",
79+
"name": "Version 777.7.7",
80+
"draft": false,
81+
"prerelease": false,
82+
"created_at": "2024-08-08T03:04:55Z",
83+
"published_at": "2024-08-08T03:51:13Z",
84+
"assets": [
85+
{
86+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
87+
"id": 184590231,
88+
"node_id": "RA_kwDOACQFs84LAJ-X",
89+
"name": "wp-cli-777.7.7.phar",
90+
"label": null,
91+
"content_type": "application/octet-stream",
92+
"state": "uploaded",
93+
"size": 7048108,
94+
"download_count": 722639,
95+
"created_at": "2024-08-08T03:51:05Z",
96+
"updated_at": "2024-08-08T03:51:08Z",
97+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.phar"
98+
},
99+
{
100+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/assets/184590231",
101+
"id": 184590231,
102+
"node_id": "RA_kwDOACQFs84LAJ-X",
103+
"name": "wp-cli-777.7.7.phar",
104+
"label": null,
105+
"content_type": "application/octet-stream",
106+
"state": "uploaded",
107+
"size": 7048108,
108+
"download_count": 722639,
109+
"created_at": "2024-08-08T03:51:05Z",
110+
"updated_at": "2024-08-08T03:51:08Z",
111+
"browser_download_url": "https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.manifest.json"
112+
}
113+
],
114+
"tarball_url": "https://api.github.com/repos/wp-cli/wp-cli/tarball/v777.7.7",
115+
"zipball_url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/v777.7.7",
116+
"body": "- Allow manually dispatching tests workflow [[#5965](https://github.com/wp-cli/wp-cli/pull/5965)]\r\n- Add fish shell completion [[#5954](https://github.com/wp-cli/wp-cli/pull/5954)]\r\n- Add defaults and accepted values for runcommand() options in doc [[#5953](https://github.com/wp-cli/wp-cli/pull/5953)]\r\n- Address warnings with filenames ending in fullstop on Windows [[#5951](https://github.com/wp-cli/wp-cli/pull/5951)]\r\n- Fix unit tests [[#5950](https://github.com/wp-cli/wp-cli/pull/5950)]\r\n- Update copyright year in license [[#5942](https://github.com/wp-cli/wp-cli/pull/5942)]\r\n- Fix breaking multi-line CSV values on reading [[#5939](https://github.com/wp-cli/wp-cli/pull/5939)]\r\n- Fix broken Gutenberg test [[#5938](https://github.com/wp-cli/wp-cli/pull/5938)]\r\n- Update docker runner to resolve docker path using `/usr/bin/env` [[#5936](https://github.com/wp-cli/wp-cli/pull/5936)]\r\n- Fix `inherit` path in nested directory [[#5930](https://github.com/wp-cli/wp-cli/pull/5930)]\r\n- Minor docblock improvements [[#5929](https://github.com/wp-cli/wp-cli/pull/5929)]\r\n- Add Signup fetcher [[#5926](https://github.com/wp-cli/wp-cli/pull/5926)]\r\n- Ensure the alias has the leading `@` symbol when added [[#5924](https://github.com/wp-cli/wp-cli/pull/5924)]\r\n- Include any non default hook information in CompositeCommand [[#5921](https://github.com/wp-cli/wp-cli/pull/5921)]\r\n- Correct completion case when ends in = [[#5913](https://github.com/wp-cli/wp-cli/pull/5913)]\r\n- Docs: Fixes for inline comments [[#5912](https://github.com/wp-cli/wp-cli/pull/5912)]\r\n- Update Inline comments [[#5910](https://github.com/wp-cli/wp-cli/pull/5910)]\r\n- Add a real-world example for `wp cli has-command` [[#5908](https://github.com/wp-cli/wp-cli/pull/5908)]\r\n- Fix typos [[#5901](https://github.com/wp-cli/wp-cli/pull/5901)]\r\n- Avoid PHP deprecation notices in PHP 8.1.x [[#5899](https://github.com/wp-cli/wp-cli/pull/5899)]",
117+
"reactions": {
118+
"url": "https://api.github.com/repos/wp-cli/wp-cli/releases/169243978/reactions",
119+
"total_count": 9,
120+
"+1": 4,
121+
"-1": 0,
122+
"laugh": 0,
123+
"hooray": 1,
124+
"confused": 0,
125+
"heart": 0,
126+
"rocket": 4,
127+
"eyes": 0
128+
}
129+
}
130+
]
131+
"""
132+
133+
And that HTTP requests to wp-cli-999.9.9.manifest.json will respond with:
134+
"""
135+
HTTP/1.1 200
136+
Content-Type: application/json
137+
138+
{
139+
"requires_php": "123.4.5"
140+
}
141+
"""
142+
143+
And that HTTP requests to wp-cli-777.7.7.manifest.json will respond with:
144+
"""
145+
HTTP/1.1 200
146+
Content-Type: application/json
147+
148+
{
149+
"requires_php": "5.6.0"
150+
}
151+
"""
152+
153+
When I run `wp cli check-update`
154+
Then STDOUT should be a table containing rows:
155+
| version | update_type | package_url | status | requires_php |
156+
| 999.9.9 | major | https://github.com/wp-cli/wp-cli/releases/download/v999.9.9/wp-cli-999.9.9.phar | unavailable | 123.4.5 |
157+
| 777.7.7 | major | https://github.com/wp-cli/wp-cli/releases/download/v777.7.7/wp-cli-777.7.7.phar | available | 5.6.0 |

features/config.feature

Lines changed: 119 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Feature: Have a config file
6565
Scenario: WP in a subdirectory (autodetected)
6666
Given a WP installation in 'foo'
6767

68-
Given an index.php file:
68+
And an index.php file:
6969
"""
7070
require('./foo/wp-blog-header.php');
7171
"""
@@ -239,7 +239,7 @@ Feature: Have a config file
239239
"""
240240

241241
When I run `WP_CLI_CONFIG_PATH=test-dir/config.yml wp help`
242-
Then STDERR should be empty
242+
Then STDERR should be empty
243243

244244
Scenario: Load WordPress with `--debug`
245245
Given a WP installation
@@ -249,7 +249,7 @@ Feature: Have a config file
249249
"""
250250
No readable global config found
251251
"""
252-
Then STDERR should contain:
252+
And STDERR should contain:
253253
"""
254254
No project config found
255255
"""
@@ -276,7 +276,7 @@ Feature: Have a config file
276276
"""
277277
No readable global config found
278278
"""
279-
Then STDERR should contain:
279+
And STDERR should contain:
280280
"""
281281
No project config found
282282
"""
@@ -303,7 +303,7 @@ Feature: Have a config file
303303
"""
304304
No readable global config found
305305
"""
306-
Then STDERR should not contain:
306+
And STDERR should not contain:
307307
"""
308308
No project config found
309309
"""
@@ -625,3 +625,117 @@ Feature: Have a config file
625625
"""
626626
Warning: UTF-8 byte-order mark (BOM) detected in wp-config.php file, stripping it for parsing.
627627
"""
628+
629+
Scenario: Strange wp-config.php file with missing wp-settings.php call
630+
Given a WP installation
631+
And a wp-config.php file:
632+
"""
633+
<?php
634+
define('DB_NAME', '{DB_NAME}');
635+
define('DB_USER', '{DB_USER}');
636+
define('DB_PASSWORD', '{DB_PASSWORD}');
637+
define('DB_HOST', '{DB_HOST}');
638+
define('DB_CHARSET', 'utf8');
639+
define('DB_COLLATE', '');
640+
$table_prefix = 'wp_';
641+
642+
/* That's all, stop editing! Happy publishing. */
643+
"""
644+
645+
When I try `wp core is-installed`
646+
Then STDERR should contain:
647+
"""
648+
Error: Strange wp-config.php file: wp-settings.php is not loaded directly.
649+
"""
650+
651+
Scenario: Strange wp-config.php file with multi-line wp-settings.php call
652+
Given a WP installation
653+
And a wp-config.php file:
654+
"""
655+
<?php
656+
if ( 1 === 1 ) {
657+
require_once ABSPATH . 'some-other-file.php';
658+
}
659+
660+
define('DB_NAME', '{DB_NAME}');
661+
define('DB_USER', '{DB_USER}');
662+
define('DB_PASSWORD', '{DB_PASSWORD}');
663+
define('DB_HOST', '{DB_HOST}');
664+
define('DB_CHARSET', 'utf8');
665+
define('DB_COLLATE', '');
666+
$table_prefix = 'wp_';
667+
668+
/* That's all, stop editing! Happy publishing. */
669+
670+
/** Sets up WordPress vars and included files. */
671+
require_once
672+
ABSPATH . 'wp-settings.php'
673+
;
674+
"""
675+
676+
When I try `wp core is-installed`
677+
Then STDERR should not contain:
678+
"""
679+
Error: Strange wp-config.php file: wp-settings.php is not loaded directly.
680+
"""
681+
682+
Scenario: Code after wp-settings.php call should be loaded
683+
Given a WP installation
684+
And a wp-config.php file:
685+
"""
686+
<?php
687+
if ( 1 === 1 ) {
688+
require_once ABSPATH . 'some-other-file.php';
689+
}
690+
691+
define('DB_NAME', '{DB_NAME}');
692+
define('DB_USER', '{DB_USER}');
693+
define('DB_PASSWORD', '{DB_PASSWORD}');
694+
define('DB_HOST', '{DB_HOST}');
695+
define('DB_CHARSET', 'utf8');
696+
define('DB_COLLATE', '');
697+
$table_prefix = 'wp_';
698+
699+
/* That's all, stop editing! Happy publishing. */
700+
701+
/** Sets up WordPress vars and included files. */
702+
require_once
703+
ABSPATH . 'wp-settings.php'
704+
;
705+
706+
require_once ABSPATH . 'includes-file.php';
707+
"""
708+
And a includes-file.php file:
709+
"""
710+
<?php
711+
define( 'MY_CONSTANT', true );
712+
"""
713+
And a some-other-file.php file:
714+
"""
715+
<?php
716+
define( 'MY_OTHER_CONSTANT', true );
717+
"""
718+
719+
When I try `wp core is-installed`
720+
Then STDERR should not contain:
721+
"""
722+
Error: Strange wp-config.php file: wp-settings.php is not loaded directly.
723+
"""
724+
725+
When I run `wp eval 'var_export( defined("MY_CONSTANT") );'`
726+
Then STDOUT should be:
727+
"""
728+
true
729+
"""
730+
731+
When I run `wp eval 'var_export( defined("MY_OTHER_CONSTANT") );'`
732+
Then STDOUT should be:
733+
"""
734+
true
735+
"""
736+
737+
Scenario: Be able to create a new global config file (including any new parent folders) when one doesn't exist
738+
# Delete this folder or else a rerun of the test will fail since the folder/file now exists
739+
When I run `[ -n "$HOME" ] && rm -rf "$HOME/doesnotexist"`
740+
And I try `WP_CLI_CONFIG_PATH=$HOME/doesnotexist/wp-cli.yml wp cli alias add 1 --debug`
741+
Then STDERR should match #Default global config does not exist, creating one in.+/doesnotexist/wp-cli.yml#

0 commit comments

Comments
 (0)