Skip to content

Commit 586522b

Browse files
committed
Add clarifying comment about type error
1 parent d6430f9 commit 586522b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WP_CLI/SearchReplacer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ private function run_recursively( $data, $serialised, $recursion_level = 0, $vis
9292
error_reporting( $error_reporting );
9393

9494
} catch ( \TypeError $exception ) { // phpcs:ignore PHPCompatibility.Classes.NewClasses.typeerrorFound
95+
// This type error is thrown when trying to unserialize a string that does not fit the
96+
// type declarations of the properties it is supposed to fill.
97+
// This type checking was introduced with PHP 8.1.
98+
// See https://github.com/wp-cli/search-replace-command/issues/191
9599
\WP_CLI::warning(
96100
sprintf(
97101
'Skipping an inconvertible serialized object: "%s", replacements might not be complete. Reason: %s.',
@@ -100,7 +104,7 @@ private function run_recursively( $data, $serialised, $recursion_level = 0, $vis
100104
)
101105
);
102106

103-
throw new Exception();
107+
throw new Exception( $exception->getMessage(), $exception->getCode(), $exception );
104108
}
105109

106110
if ( false !== $unserialized ) {

0 commit comments

Comments
 (0)