From e7cdd8a87fdf6cb1af0a79b8e61f9f115a9411aa Mon Sep 17 00:00:00 2001 From: Jorge M Date: Mon, 15 Apr 2024 13:00:19 +0200 Subject: [PATCH] Delete unused methods --- src/DB/ProductMetaQueryHelper.php | 69 ------------------------------- 1 file changed, 69 deletions(-) diff --git a/src/DB/ProductMetaQueryHelper.php b/src/DB/ProductMetaQueryHelper.php index 31007df211..9a82404781 100644 --- a/src/DB/ProductMetaQueryHelper.php +++ b/src/DB/ProductMetaQueryHelper.php @@ -76,75 +76,6 @@ public function delete_all_values( string $meta_key ) { $this->wpdb->query( $this->wpdb->prepare( $query, $meta_key ) ); } - /** - * Insert a meta value for multiple posts. - * - * @param string $meta_key The meta value to insert. - * @param array $meta_values Array of [post_id=>meta_value,…]. - * - * @throws InvalidMeta If the meta key isn't valid. - */ - public function batch_insert_values( string $meta_key, array $meta_values ) { - if ( empty( $meta_values ) ) { - return; - } - - self::validate_meta_key( $meta_key ); - $meta_key = $this->prefix_meta_key( $meta_key ); - - foreach ( array_chunk( $meta_values, self::BATCH_SIZE, true ) as $meta_values_chunk ) { - $values = []; - $place_holders = []; - foreach ( $meta_values_chunk as $post_id => $meta_value ) { - $place_holders[] = '(%s, %s, %s)'; - $values[] = $meta_key; - $values[] = $post_id; - $values[] = $meta_value; - } - $query = "INSERT INTO {$this->wpdb->postmeta} (`meta_key`, `post_id`, `meta_value` ) VALUES "; - $query .= implode( ', ', $place_holders ); - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared - if ( false === $this->wpdb->query( $this->wpdb->prepare( $query, $values ) ) ) { - do_action( - 'woocommerce_gla_debug_message', - sprintf( 'Error batch inserting "%s" meta values.', $meta_key ), - __METHOD__ - ); - } - } - } - - /** - * Update a meta value for multiple posts. - * - * @param string $meta_key The meta value to update. - * @param mixed $meta_value The new meta value. - * @param array $post_ids Post IDs to update. - * - * @throws InvalidMeta If the meta key isn't valid. - */ - public function batch_update_values( string $meta_key, $meta_value, array $post_ids ) { - if ( empty( $post_ids ) ) { - return; - } - - self::validate_meta_key( $meta_key ); - $meta_key = $this->prefix_meta_key( $meta_key ); - - foreach ( array_chunk( $post_ids, self::BATCH_SIZE ) as $post_ids_chunk ) { - $query = "UPDATE {$this->wpdb->postmeta} SET `meta_value` = %s WHERE `meta_key` = %s AND `post_id` IN (%d" . str_repeat( ', %d', count( $post_ids_chunk ) - 1 ) . ')'; - array_unshift( $post_ids_chunk, $meta_value, $meta_key ); - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared - if ( false === $this->wpdb->query( $this->wpdb->prepare( $query, $post_ids_chunk ) ) ) { - do_action( - 'woocommerce_gla_debug_message', - sprintf( 'Error batch updating "%s" meta values.', $meta_key ), - __METHOD__ - ); - } - } - } - /** * @param string $meta_key The meta key to validate *