WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/26/2019 12:43:50 AM (3 years ago)
Author:
pento
Message:

Media: Revert [44947].

get_available_post_mime_types() uses a query that's extremely slow on sites with lots of posts. The original fix can be revisited after those performance issues are tackled.

See #43658.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r44947 r45270  
    464464        $this->assertInternalType( 'array', $mimes );
    465465        $this->assertNotEmpty( $mimes );
    466     }
    467 
    468     /**
    469      * Test that the media grid uses the correct available single media type.
    470      * @ticket 43658
    471      */
    472     function test_wp_enqueue_media_single_mime_type() {
    473         $filename      = DIR_TESTDATA . '/images/test-image.jpg';
    474         $contents      = file_get_contents( $filename );
    475         $upload        = wp_upload_bits( basename( $filename ), null, $contents );
    476         $attachment_id = $this->_make_attachment( $upload );
    477 
    478         add_filter(
    479             'media_view_settings',
    480             function( $settings ) {
    481                 $this->assertEquals( array( 'image' ), array_keys( $settings['mimeTypes'] ) );
    482                 return $settings;
    483             }
    484         );
    485         wp_enqueue_media();
    486         remove_all_filters( 'media_view_settings' );
    487     }
    488 
    489     /**
    490      * Test that the media grid uses the correct available multiple media types.
    491      * @ticket 43658
    492      */
    493     function test_wp_enqueue_media_multiple_mime_types() {
    494         $filename      = DIR_TESTDATA . '/images/test-image.jpg';
    495         $contents      = file_get_contents( $filename );
    496         $upload        = wp_upload_bits( basename( $filename ), null, $contents );
    497         $attachment_id = $this->_make_attachment( $upload );
    498 
    499         $filename      = DIR_TESTDATA . '/uploads/small-audio.mp3';
    500         $contents      = file_get_contents( $filename );
    501         $upload        = wp_upload_bits( basename( $filename ), null, $contents );
    502         $attachment_id = $this->_make_attachment( $upload );
    503 
    504         add_filter(
    505             'media_view_settings',
    506             function( $settings ) {
    507                 $this->assertEquals( array( 'image', 'audio' ), array_keys( $settings['mimeTypes'] ) );
    508                 return $settings;
    509             }
    510         );
    511         wp_enqueue_media();
    512         remove_all_filters( 'media_view_settings' );
    513466    }
    514467
Note: See TracChangeset for help on using the changeset viewer.