Extra safety

This commit is contained in:
claudiulodro 2018-09-21 12:24:13 -07:00
parent c9c12c2518
commit d1e9e85cbb
1 changed files with 3 additions and 3 deletions

View File

@ -541,13 +541,13 @@ function wc_create_attribute( $args ) {
$metadatas = $wpdb->get_results( $metadatas = $wpdb->get_results(
$wpdb->prepare( $wpdb->prepare(
"SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_product_attributes' AND meta_value LIKE %s", "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_product_attributes' AND meta_value LIKE %s",
'%' . $old_taxonomy_name . '%' '%' . $wpdb->esc_like( $old_taxonomy_name ) . '%'
), ),
ARRAY_A ); ARRAY_A );
foreach ( $metadatas as $metadata ) { foreach ( $metadatas as $metadata ) {
$product_id = $metadata['post_id']; $product_id = $metadata['post_id'];
$unserialized_data = @unserialize( $metadata['meta_value'] ); $unserialized_data = maybe_unserialize( $metadata['meta_value'] );
if ( ! $unserialized_data || ! isset( $unserialized_data[ $old_taxonomy_name ] ) ) { if ( ! $unserialized_data || ! is_array( $unserialized_data ) || ! isset( $unserialized_data[ $old_taxonomy_name ] ) ) {
continue; continue;
} }