Skip to content

Commit ac1ae3b

Browse files
committed
catch errors in unsafe php objects as they are iterated on
1 parent d6437f2 commit ac1ae3b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/WP_CLI/SearchReplacer.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,19 @@ private function run_recursively( $data, $serialised, $recursion_level = 0, $vis
119119
)
120120
);
121121
} else {
122-
foreach ( $data as $key => $value ) {
123-
$data->$key = $this->run_recursively( $value, false, $recursion_level + 1, $visited_data );
122+
try {
123+
foreach ( $data as $key => $value ) {
124+
$data->$key = $this->run_recursively( $value, false, $recursion_level + 1, $visited_data );
125+
}
126+
} catch ( \Error $e ) {
127+
\WP_CLI::warning(
128+
sprintf(
129+
'Skipping an inconvertible serialized object: "%s", replacements might not be complete.',
130+
$data
131+
)
132+
);
133+
134+
throw new Exception();
124135
}
125136
}
126137
} elseif ( is_string( $data ) ) {

0 commit comments

Comments
 (0)