Skip to content

Commit f81af96

Browse files
authored
Merge branch 'main' into copilot/add-progress-bar-indicator
2 parents 9a2facf + 2f5c5be commit f81af96

7 files changed

Lines changed: 34 additions & 22 deletions

File tree

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ on:
99
paths:
1010
- .github/workflows/copilot-setup-steps.yml
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
copilot-setup-steps:
17+
name: Setup environment
1418
runs-on: ubuntu-latest
1519
permissions:
1620
contents: read
1721

1822
steps:
1923
- name: Checkout code
2024
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
25+
with:
26+
persist-credentials: false
2127

2228
- name: Check existence of composer.json file
2329
id: check_composer_file
2430
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2531

2632
- name: Set up PHP environment
2733
if: steps.check_composer_file.outputs.files_exists == 'true'
28-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
34+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
2935
with:
3036
php-version: 'latest'
3137
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -36,9 +42,6 @@ jobs:
3642

3743
- name: Install Composer dependencies & cache dependencies
3844
if: steps.check_composer_file.outputs.files_exists == 'true'
39-
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v3
45+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4046
env:
4147
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
42-
with:
43-
# Bust the cache at least once a month - output format: YYYY-MM.
44-
custom-cache-suffix: $(date -u "+%Y-%m")

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ wp-cli/search-replace-command
33

44
Searches/replaces strings in the database.
55

6-
[![Testing](https://github.com/wp-cli/search-replace-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/search-replace-command/actions/workflows/testing.yml)
6+
[![Testing](https://github.com/wp-cli/search-replace-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/search-replace-command/actions/workflows/testing.yml) [![Code Coverage](https://codecov.io/gh/wp-cli/search-replace-command/branch/main/graph/badge.svg)](https://codecov.io/gh/wp-cli/search-replace-command/tree/main)
77

88
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)
99

‎codecov.yml‎

Whitespace-only changes.

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.12"
15+
"wp-cli/wp-cli": "^2.13"
1616
},
1717
"require-dev": {
1818
"wp-cli/db-command": "^1.3 || ^2",

‎features/search-replace.feature‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ Feature: Do global search/replace
222222
"""
223223

224224
# See https://github.com/wp-cli/search-replace-command/issues/190
225-
@skip-sqlite
226225
Scenario: Regex search/replace
227226
Given a WP install
228227
When I run `wp search-replace '(Hello)\s(world)' '$2, $1' --regex`
@@ -962,6 +961,8 @@ Feature: Do global search/replace
962961
And STDERR should be empty
963962

964963
# See https://github.com/wp-cli/search-replace-command/issues/190
964+
# SQLite: regex backreference replacement produces different results due to
965+
# LIKE case-sensitivity differences. Requires further investigation.
965966
@skip-sqlite
966967
Scenario: Logging with regex replace
967968
Given a WP install
@@ -1326,7 +1327,6 @@ Feature: Do global search/replace
13261327
"""
13271328

13281329
# See https://github.com/wp-cli/search-replace-command/issues/190
1329-
@skip-sqlite
13301330
Scenario: Regex search/replace with `--regex-limit=1` option
13311331
Given a WP install
13321332
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
@@ -1338,7 +1338,6 @@ Feature: Do global search/replace
13381338
"""
13391339

13401340
# See https://github.com/wp-cli/search-replace-command/issues/190
1341-
@skip-sqlite
13421341
Scenario: Regex search/replace with `--regex-limit=2` option
13431342
Given a WP install
13441343
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
@@ -1350,7 +1349,6 @@ Feature: Do global search/replace
13501349
"""
13511350

13521351
# See https://github.com/wp-cli/search-replace-command/issues/190
1353-
@skip-sqlite
13541352
Scenario: Regex search/replace with incorrect or default `--regex-limit`
13551353
Given a WP install
13561354
When I try `wp search-replace '(Hello)\s(world)' '$2, $1' --regex --regex-limit=asdf`

‎phpcs.xml.dist‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<!--
66
#############################################################################
77
COMMAND LINE ARGUMENTS
8-
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9-
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
8+
For help understanding this file: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9+
For help using PHPCS: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage
1010
#############################################################################
1111
-->
1212

‎src/Search_Replace_Command.php‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,16 @@ public function __invoke( $args, $assoc_args ) {
480480
$tables = Utils\wp_get_table_names( $args, $assoc_args );
481481

482482
// Identify views so they can be skipped; views are dynamic and cannot be directly modified.
483-
$views_args = $assoc_args;
484-
$views_args['views-only'] = true;
485-
$views = Utils\wp_get_table_names( [], $views_args );
486-
$view_set = array_flip( array_intersect( $views, $tables ) );
483+
// The SQLite integration drop-in does not support SHOW FULL TABLES and WordPress
484+
// on SQLite does not use views, so skip the views query entirely.
485+
if ( 'sqlite' === Utils\get_db_type() ) {
486+
$view_set = array();
487+
} else {
488+
$views_args = $assoc_args;
489+
$views_args['views-only'] = true;
490+
$views = Utils\wp_get_table_names( [], $views_args );
491+
$view_set = array_flip( array_intersect( $views, $tables ) );
492+
}
487493

488494
foreach ( $tables as $table ) {
489495
foreach ( $this->skip_tables as $skip_table ) {
@@ -555,12 +561,17 @@ public function __invoke( $args, $assoc_args ) {
555561
$col_sql = self::esc_sql_ident( $col );
556562
$wpdb->last_error = '';
557563

558-
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
559-
$serial_row = $wpdb->get_row( "SELECT * FROM $table_sql WHERE $col_sql REGEXP '^[aiO]:[1-9]' LIMIT 1" );
560-
561-
// When the regex triggers an error, we should fall back to PHP
562-
if ( false !== strpos( $wpdb->last_error, 'ERROR 1139' ) ) {
564+
if ( 'sqlite' === Utils\get_db_type() ) {
565+
// SQLite does not support REGEXP by default, fall back to PHP processing.
563566
$serial_row = true;
567+
} else {
568+
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
569+
$serial_row = $wpdb->get_row( "SELECT * FROM $table_sql WHERE $col_sql REGEXP '^[aiO]:[1-9]' LIMIT 1" );
570+
571+
// When the regex triggers an error, we should fall back to PHP
572+
if ( false !== strpos( $wpdb->last_error, 'ERROR 1139' ) ) {
573+
$serial_row = true;
574+
}
564575
}
565576
}
566577

0 commit comments

Comments
 (0)