@@ -172,10 +172,6 @@ public function __invoke( $args, $assoc_args ) {
172
172
$ this ->recurse_objects = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'recurse-objects ' , true );
173
173
$ this ->verbose = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'verbose ' );
174
174
$ this ->format = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'format ' );
175
- $ this ->regex_limit = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'regex-limit ' , -1 );
176
- if ( 0 === intval ( $ this ->regex_limit ) ) {
177
- WP_CLI ::error ( '`--regex-limit` expects integer. ' );
178
- }
179
175
180
176
if ( ( $ this ->regex = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'regex ' , false ) ) ) {
181
177
$ this ->regex_flags = \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'regex-flags ' , false );
@@ -204,6 +200,12 @@ public function __invoke( $args, $assoc_args ) {
204
200
}
205
201
WP_CLI ::error ( $ msg );
206
202
}
203
+ if ( ( $ regex_limit = (int ) \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'regex-limit ' , - 1 ) ) > - 1 ) {
204
+ if ( ! preg_match ( '/^[0-9]+$/ ' , $ regex_limit ) ) {
205
+ WP_CLI ::error ( '`--regex-limit` expects a positive integer. ' );
206
+ }
207
+ $ this ->regex_limit = $ regex_limit ;
208
+ }
207
209
}
208
210
209
211
$ this ->skip_columns = explode ( ', ' , \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'skip-columns ' ) );
0 commit comments