Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion features/comment-recount.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ Feature: Recount comments on a post
3
"""

When I run `wp eval 'global $wpdb; $wpdb->update( $wpdb->posts, array( "comment_count" => 1 ), array( "ID" => 1 ) ); clean_post_cache( 1 );'`
Given a recount-comments.php file:
"""
<?php
global $wpdb;
$wpdb->update( $wpdb->posts, array( "comment_count" => 1 ), array( "ID" => 1 ) );
clean_post_cache( 1 );
"""
When I run `wp eval-file recount-comments.php`
And I run `wp post get 1 --field=comment_count`
Then STDOUT should be:
"""
Expand Down
3 changes: 3 additions & 0 deletions features/comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ Feature: Manage WordPress comments
"""
And the return code should be 0

@skip-windows
Scenario: Approving/unapproving comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID)`
And I run `wp comment generate --count=10 --quiet`
Expand Down Expand Up @@ -343,6 +344,7 @@ Feature: Manage WordPress comments
"""
And the return code should be 0

@skip-windows
Scenario: Spam/unspam comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID)`
And I run `wp comment generate --count=10 --quiet`
Expand Down Expand Up @@ -392,6 +394,7 @@ Feature: Manage WordPress comments
"""
And the return code should be 0

@skip-windows
Scenario: Trash/untrash comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID) --force`
And I run `wp comment generate --count=10 --quiet`
Expand Down
290 changes: 185 additions & 105 deletions features/post-block.feature

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion features/post-meta.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Feature: Manage post custom fields

# Windows likes to include the quotes of the `"via STDIN"` string.
@skip-windows
Scenario: Postmeta CRUD
Given a WP install

Expand Down Expand Up @@ -34,7 +36,7 @@ Feature: Manage post custom fields
["1","2"]
"""

When I run `echo 'via STDIN' | wp post-meta set 1 foo`
When I run `echo "via STDIN" | wp post-meta set 1 foo`
And I run `wp post-meta get 1 foo`
Then STDOUT should be:
"""
Expand Down
8 changes: 4 additions & 4 deletions features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Feature: Manage WordPress posts
"""
And a create-post.sh file:
"""
cat content.html | wp post create --post_title='Test post' --post_excerpt="A multiline
cat content.html | wp post create --post_title="Test post" --post_excerpt="A multiline
excerpt" --porcelain -
"""

Expand Down Expand Up @@ -265,14 +265,14 @@ Feature: Manage WordPress posts
}
"""

When I try `EDITOR='ex -i NONE -c q!' wp post edit {POST_ID}`
When I try `EDITOR="ex -i NONE -c q!" wp post edit {POST_ID}`
Then STDERR should contain:
"""
No change made to post content.
"""
And the return code should be 0

When I run `EDITOR='ex -i NONE -c %s/content/bunkum -c wq' wp post edit {POST_ID}`
When I run `EDITOR="ex -i NONE -c %s/content/bunkum -c wq" wp post edit {POST_ID}`
Then STDERR should be empty
And STDOUT should contain:
"""
Expand Down Expand Up @@ -473,7 +473,7 @@ Feature: Manage WordPress posts
My\Post
"""

When I run `wp post update {POST_ID} --post_content='var isEmailValid = /^\S+@\S+.\S+$/.test(email);'`
When I run `wp post update {POST_ID} --post_content="var isEmailValid = /^\S+@\S+.\S+$/.test(email);"`
Then STDOUT should not be empty

When I run `wp post get {POST_ID} --field=content`
Expand Down
3 changes: 3 additions & 0 deletions features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Feature: Manage sites in a multisite installation
http://first.example.com
"""

@skip-windows
Scenario: Delete a site by id
Given a WP multisite subdirectory install

Expand Down Expand Up @@ -77,6 +78,7 @@ Feature: Manage sites in a multisite installation
When I try the previous command again
Then the return code should be 1

@skip-windows
Scenario: Filter site list
Given a WP multisite install

Expand Down Expand Up @@ -212,6 +214,7 @@ Feature: Manage sites in a multisite installation
"""
And the return code should be 1

@skip-windows
Scenario: Get site info
Given a WP multisite install

Expand Down
9 changes: 8 additions & 1 deletion features/term-recount.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ Feature: Recount terms on a taxonomy
"""
1
"""
When I run `wp eval 'global $wpdb; $wpdb->update( $wpdb->term_taxonomy, array( "count" => 3 ), array( "term_id" => {TERM_ID} ) ); clean_term_cache( {TERM_ID}, "category" );'`
Given a recount-terms.php file:
"""
<?php
global $wpdb;
$wpdb->update( $wpdb->term_taxonomy, array( "count" => 3 ), array( "term_id" => {TERM_ID} ) );
clean_term_cache( {TERM_ID}, "category" );
"""
When I run `wp eval-file recount-terms.php`
And I run `wp term get category {TERM_ID} --field=count`
Then STDOUT should be:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/term.feature
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Feature: Manage WordPress terms
My\Term\Description
"""

When I run `wp term update category {TERM_ID} --name='My\New\Term' --description='var isEmailValid = /^\S+@\S+.\S+$/.test(email);'`
When I run `wp term update category {TERM_ID} --name="My\New\Term" --description="var isEmailValid = /^\S+@\S+.\S+$/.test(email);"`
Then STDOUT should not be empty

When I run `wp term get category {TERM_ID} --field=name`
Expand Down
18 changes: 14 additions & 4 deletions features/user-application-password.feature
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,15 @@ Feature: Manage user custom fields
When I run `wp user application-password list {USER_ID} --name=someapp --field=uuid`
Then save STDOUT as {UUID}

When I run `wp user application-password get {USER_ID} {UUID} --field=password | sed 's/\$/\\\$/g'`
When I run `wp user application-password get {USER_ID} {UUID} --field=password`
Then save STDOUT as {HASH}

When I run `wp eval "var_export( wp_check_password( '{PASSWORD}', '{HASH}', {USER_ID} ) );"`
Given a check-password.php file:
"""
<?php
var_export( wp_check_password( '{PASSWORD}', '{HASH}', {USER_ID} ) );
"""
When I run `wp eval-file check-password.php`
Then STDOUT should contain:
"""
true
Expand All @@ -297,10 +302,15 @@ Feature: Manage user custom fields
When I run `wp user application-password list {USER_ID} --name=someapp --field=uuid`
Then save STDOUT as {UUID}

When I run `wp user application-password get {USER_ID} {UUID} --field=password | sed 's/\$/\\\$/g'`
When I run `wp user application-password get {USER_ID} {UUID} --field=password`
Then save STDOUT as {HASH}

When I run `wp eval "var_export( wp_verify_fast_hash( '{PASSWORD}', '{HASH}', {USER_ID} ) );"`
Given a verify-fast-hash.php file:
"""
<?php
var_export( wp_verify_fast_hash( '{PASSWORD}', '{HASH}', {USER_ID} ) );
"""
When I run `wp eval-file verify-fast-hash.php`
Then STDOUT should contain:
"""
true
Expand Down
1 change: 1 addition & 0 deletions features/user-import-csv.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Feature: Import users from CSV
}
"""

@skip-windows
Scenario: Import users from a CSV file generated by `wp user list`
Given a WP install

Expand Down
3 changes: 2 additions & 1 deletion src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ public function empty_( $args, $assoc_args ) {
foreach ( $files as $fileinfo ) {
$realpath = $fileinfo->getRealPath();
// Don't clobber subsites when operating on the main site
if ( $is_main_site && false !== stripos( $realpath, '/sites/' ) ) {
$normalized_realpath = str_replace( '\\', '/', $realpath );
if ( $is_main_site && false !== stripos( $normalized_realpath, '/sites/' ) ) {
continue;
Comment on lines 248 to 252
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SplFileInfo::getRealPath() can return false. Passing that into str_replace() / stripos() will throw a TypeError in PHP 8+ and abort wp site empty --uploads. Add a guard (e.g. if ( false === $realpath ) { continue; }) or fall back to $fileinfo->getPathname() before normalizing/searching.

Copilot uses AI. Check for mistakes.
}
if ( $fileinfo->isDir() ) {
Expand Down
Loading