diff --git a/plugins/woocommerce/changelog/update-custom-meta-data-store-get-meta-keys b/plugins/woocommerce/changelog/update-custom-meta-data-store-get-meta-keys new file mode 100644 index 00000000000..e71864b4b3d --- /dev/null +++ b/plugins/woocommerce/changelog/update-custom-meta-data-store-get-meta-keys @@ -0,0 +1,5 @@ +Significance: patch +Type: tweak +Comment: Added clause to query in CustomMetaDataStore::get_meta_keys to exclude metas where the key is ''. + + diff --git a/plugins/woocommerce/src/Internal/DataStores/CustomMetaDataStore.php b/plugins/woocommerce/src/Internal/DataStores/CustomMetaDataStore.php index 06cca2d7da7..5b6c52c219a 100644 --- a/plugins/woocommerce/src/Internal/DataStores/CustomMetaDataStore.php +++ b/plugins/woocommerce/src/Internal/DataStores/CustomMetaDataStore.php @@ -250,7 +250,9 @@ abstract class CustomMetaDataStore { $query = "SELECT DISTINCT meta_key FROM {$db_info['table']} "; if ( ! $include_private ) { - $query .= $wpdb->prepare( 'WHERE meta_key NOT LIKE %s ', $wpdb->esc_like( '_' ) . '%' ); + $query .= $wpdb->prepare( 'WHERE meta_key != \'\' AND meta_key NOT LIKE %s ', $wpdb->esc_like( '_' ) . '%' ); + } else { + $query .= "WHERE meta_key != '' "; } $order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';