Skip to content

Commit

Permalink
Adds argument validations
Browse files Browse the repository at this point in the history
  • Loading branch information
pschoffer committed Feb 17, 2021
1 parent e5ffc06 commit 5fc54c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion search/includes/classes/class-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static function validate_index_posts_count( $options = array() ) {
*
* @return array Array containing counts and ids of posts with inconsistent content
*/
public static function validate_index_posts_content( $start_post_id = 1, $last_post_id = null, $batch_size, $max_diff_size, $silent, $inspect = false, $do_not_heal = false ) {
public static function validate_index_posts_content( $start_post_id, $last_post_id, $batch_size, $max_diff_size, $silent, $inspect, $do_not_heal ) {
// If batch size value NOT a numeric value over 0 but less than or equal to PHP_INT_MAX, reset to default
// Otherwise, turn it into an int
if ( ! is_numeric( $batch_size ) || 0 >= $batch_size || $batch_size > PHP_INT_MAX ) {
Expand Down
10 changes: 9 additions & 1 deletion search/includes/classes/commands/class-healthcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,15 @@ private function render_results( array $results ) {
* @subcommand validate-contents
*/
public function validate_contents( $args, $assoc_args ) {
$results = \Automattic\VIP\Search\Health::validate_index_posts_content( $assoc_args['start_post_id'], $assoc_args['last_post_id'], $assoc_args['batch_size'], $assoc_args['max_diff_size'], isset( $assoc_args['silent'] ), isset( $assoc_args['inspect'] ), isset( $assoc_args['do-not-heal'] ) );
$results = \Automattic\VIP\Search\Health::validate_index_posts_content(
$assoc_args['start_post_id'] ?? 1,
$assoc_args['last_post_id'] ?? null,
$assoc_args['batch_size'] ?? null,
$assoc_args['max_diff_size'] ?? null,
isset( $assoc_args['silent'] ),
isset( $assoc_args['inspect'] ),
isset( $assoc_args['do-not-heal'] )
);

if ( is_wp_error( $results ) ) {
$diff = $results->get_error_data( 'diff' );
Expand Down

0 comments on commit 5fc54c8

Please sign in to comment.