Make WordPress Core

Ticket #31071: 31071b.diff

File 31071b.diff, 1.1 KB (added by philipjohn, 9 years ago)

Fix the mime type queries

  • wp-includes/media.php

     
    31603160                }
    31613161        }
    31623162
     3163        // Get mime types
     3164        $mime_types = wp_get_mime_types();
     3165
     3166        // Get audio mime types and query for them
     3167        $audio_mime_types = preg_grep( 'audio*', $mime_types );
     3168        $audio_mime_types = array_values( $audio_mime_types );
    31633169        $has_audio = $wpdb->get_var( "
    31643170                SELECT ID
    31653171                FROM $wpdb->posts
    31663172                WHERE post_type = 'attachment'
    3167                 AND post_mime_type LIKE 'audio%'
     3173                AND post_mime_type IN ($audio_mime_types)
    31683174                LIMIT 1
    31693175        " );
     3176
     3177        // Get video mime types and query for them
     3178        $video_mime_types = preg_grep( 'video*', $mime_types );
     3179        $video_mime_types = array_values($video_mime_types);
    31703180        $has_video = $wpdb->get_var( "
    31713181                SELECT ID
    31723182                FROM $wpdb->posts
    31733183                WHERE post_type = 'attachment'
    3174                 AND post_mime_type LIKE 'video%'
     3184                AND post_mime_type IN ($video_mime_types)
    31753185                LIMIT 1
    31763186        " );
     3187
    31773188        $months = $wpdb->get_results( $wpdb->prepare( "
    31783189                SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    31793190                FROM $wpdb->posts