Add clause to `CustomMetaDataStore::get_meta_keys` query to exclude empty order meta keys (#46476)

* Add clause to query in `CustomMetaDataStore::get_meta_keys` to exclude metas where the key is ''.

* Addressing linter error. Removed unnecessary prepare.
This commit is contained in:
And Finally 2024-04-11 17:24:35 +01:00 committed by GitHub
parent c6048b5c49
commit 63443b502d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -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 ''.

View File

@ -250,7 +250,9 @@ abstract class CustomMetaDataStore {
$query = "SELECT DISTINCT meta_key FROM {$db_info['table']} "; $query = "SELECT DISTINCT meta_key FROM {$db_info['table']} ";
if ( ! $include_private ) { 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'; $order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';