Skip to content

Commit 2d7ce67

Browse files
committed
adding skip on phpcs incompat as testing shows its safe for PHP5.6 & adding behat tests
1 parent fde70ec commit 2d7ce67

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

features/search-replace.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,28 @@ Feature: Do global search/replace
11061106
a:1:{i:0;O:10:"CornFlakes":0:{}}
11071107
"""
11081108

1109+
# Regression test for https://github.com/wp-cli/search-replace-command/issues/191
1110+
Scenario: Deserialization for empty, type-hinted objects are handled gracefully
1111+
1112+
Given a WP install
1113+
And I run `wp option add cereal_isation 'O:13:"mysqli_result":5:{s:13:"current_field";N;s:11:"field_count";N;s:7:"lengths";N;s:8:"num_rows";N;s:4:"type";N;}'`
1114+
1115+
When I try `wp search-replace current_field current_field1`
1116+
Then STDERR should contain:s
1117+
"""
1118+
Warning: Skipping an inconvertible serialized object: "O:13:"mysqli_result":5:{s:13:"current_field";N;s:11:"field_count";N;s:7:"lengths";N;s:8:"num_rows";N;s:4:"type";N;}", replacements might not be complete.
1119+
"""
1120+
And STDOUT should contain:
1121+
"""
1122+
Success: Made 1 replacement.
1123+
"""
1124+
1125+
When I run `wp option get cereal_isation`
1126+
Then STDOUT should contain:
1127+
"""
1128+
O:13:"mysqli_result":5:{s:13:"current_field1";N;s:11:"field_count";N;s:7:"lengths";N;s:8:"num_rows";N;s:4:"type";N;}
1129+
"""
1130+
11091131
Scenario: Regex search/replace with `--regex-limit=1` option
11101132
Given a WP install
11111133
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`

src/WP_CLI/SearchReplacer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ private function run_recursively( $data, $serialised, $recursion_level = 0, $vis
9090
error_reporting( $error_reporting & ~E_NOTICE & ~E_WARNING );
9191
$unserialized = is_string( $data ) ? @unserialize( $data ) : false;
9292
error_reporting( $error_reporting );
93-
} catch ( \TypeError $e ) {
93+
94+
} catch ( \TypeError $e ) { // phpcs:ignore
9495
// catch incompatible deserialized object type conversions between different PHP versions and skip them
96+
9597
\WP_CLI::warning(
9698
sprintf(
9799
'Skipping an inconvertible serialized object: "%s", replacements might not be complete.',

0 commit comments

Comments
 (0)