From a38680afdb89cc509fff0ea53c5269877d4ba13d Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Fri, 4 Oct 2019 14:17:45 -0500 Subject: [PATCH 1/2] Ensure object is a post before proceeding --- packages/sync/src/modules/Posts.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/sync/src/modules/Posts.php b/packages/sync/src/modules/Posts.php index 516a630e212bd..a5e7a79dfd703 100644 --- a/packages/sync/src/modules/Posts.php +++ b/packages/sync/src/modules/Posts.php @@ -317,6 +317,11 @@ public function is_whitelisted_post_meta( $meta_key ) { */ public function is_post_type_allowed( $post_id ) { $post = get_post( intval( $post_id ) ); + + if ( ! $post || ! is_a( $post, '/WP_Post' ) ) { + return false; + } + if ( $post->post_type ) { return ! in_array( $post->post_type, Settings::get_setting( 'post_types_blacklist' ), true ); } From a61e2a5ac53def4bc526450a6df363b0442e9751 Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Fri, 4 Oct 2019 14:19:44 -0500 Subject: [PATCH 2/2] Pass through variable (reported by PHPCS) --- packages/sync/src/modules/Posts.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/sync/src/modules/Posts.php b/packages/sync/src/modules/Posts.php index a5e7a79dfd703..14d1c0b78e8af 100644 --- a/packages/sync/src/modules/Posts.php +++ b/packages/sync/src/modules/Posts.php @@ -318,11 +318,7 @@ public function is_whitelisted_post_meta( $meta_key ) { public function is_post_type_allowed( $post_id ) { $post = get_post( intval( $post_id ) ); - if ( ! $post || ! is_a( $post, '/WP_Post' ) ) { - return false; - } - - if ( $post->post_type ) { + if ( isset( $post->post_type ) ) { return ! in_array( $post->post_type, Settings::get_setting( 'post_types_blacklist' ), true ); } return false; @@ -670,6 +666,6 @@ public function expand_post_ids( $args ) { * @return array|bool An array of min and max ids for each batch. FALSE if no table can be found. */ public function get_min_max_object_ids_for_batches( $batch_size, $where_sql = false ) { - return parent::get_min_max_object_ids_for_batches( $batch_size, $this->get_where_sql( false ) ); + return parent::get_min_max_object_ids_for_batches( $batch_size, $this->get_where_sql( $where_sql ) ); } }