Make WordPress Core

Ticket #34196: 34196.patch

File 34196.patch, 16.9 KB (added by joemcgill, 9 years ago)

Fixes tests

  • src/wp-admin/includes/schema.php

    diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php
    index a5d41cc..219eb0a 100644
    function populate_options() { 
    506506        // 4.3.0
    507507        'finished_splitting_shared_terms' => 1,
    508508        'site_icon' => 0,
     509
     510        // 4.4.0
     511        'medium_large_size_w' => 768,
     512        'medium_large_size_h' => 0,
    509513        );
    510514
    511515        // 3.3
  • src/wp-admin/options.php

    diff --git src/wp-admin/options.php src/wp-admin/options.php
    index ade59cb..df6f0a5 100644
    if ( is_multisite() && ! is_super_admin() && 'update' != $action ) { 
    8484$whitelist_options = array(
    8585        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'timezone_string', 'WPLANG' ),
    8686        'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    87         'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
     87        'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'medium_large_size_w', 'medium_large_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
    8888        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    8989        'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' )
    9090);
  • src/wp-includes/class-wp-image-editor-gd.php

    diff --git src/wp-includes/class-wp-image-editor-gd.php src/wp-includes/class-wp-image-editor-gd.php
    index 9951dba..2093c6b 100644
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    212212         * @access public
    213213         *
    214214         * @param array $sizes {
    215          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     215         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    216216         *
    217217         *     Either a height or width must be provided.
    218218         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-image-editor-imagick.php

    diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php
    index 5833805..a14fa40 100644
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    270270         * @access public
    271271         *
    272272         * @param array $sizes {
    273          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     273         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    274274         *
    275275         *     Either a height or width must be provided.
    276276         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-xmlrpc-server.php

    diff --git src/wp-includes/class-wp-xmlrpc-server.php src/wp-includes/class-wp-xmlrpc-server.php
    index bf6c7b1..08897dc 100644
    class wp_xmlrpc_server extends IXR_Server { 
    513513                                'readonly'      => false,
    514514                                'option'        => 'medium_size_h'
    515515                        ),
     516                        'medium_large_size_w'   => array(
     517                                'desc'          => __( 'Medium-Large size image width' ),
     518                                'readonly'      => false,
     519                                'option'        => 'medium_large_size_w'
     520                        ),
     521                        'medium_large_size_h'   => array(
     522                                'desc'          => __( 'Medium-Large size image height' ),
     523                                'readonly'      => false,
     524                                'option'        => 'medium_large_size_h'
     525                        ),
    516526                        'large_size_w'      => array(
    517527                                'desc'          => __( 'Large size image width' ),
    518528                                'readonly'      => false,
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index 91b3134..7e76953 100644
    function sanitize_option( $option, $value ) { 
    36623662                case 'thumbnail_size_h':
    36633663                case 'medium_size_w':
    36643664                case 'medium_size_h':
     3665                case 'medium_large_size_w':
     3666                case 'medium_large_size_h':
    36653667                case 'large_size_w':
    36663668                case 'large_size_h':
    36673669                case 'mailserver_port':
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index fc69bdc..24ab54d 100644
     
    1414 * The `$size` parameter accepts either an array or a string. The supported string
    1515 * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
    1616 * 128 width and 96 height in pixels. Also supported for the string value is
    17  * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
     17 * 'medium_large', 'medium' and 'full'. The 'full' isn't actually supported, but any value other
    1818 * than the supported will result in the content_width size or 500 if that is
    1919 * not set.
    2020 *
    function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co 
    6060        elseif ( $size == 'medium' ) {
    6161                $max_width = intval(get_option('medium_size_w'));
    6262                $max_height = intval(get_option('medium_size_h'));
     63
    6364                // if no width is set, default to the theme content width if available
    6465        }
     66        elseif ( $size == 'medium_large' ) {
     67                /*
     68                 * We're inserting an Evan-sized image into the editor. If it's a really
     69                 * big image we'll scale it down to fit reasonably within the editor
     70                 * itself, and within the theme's content width if it's known. The user
     71                 * can resize it in the editor if they wish.
     72                 */
     73                $max_width = intval(get_option('medium_large_size_w'));
     74                $max_height = intval(get_option('medium_large_size_h'));
     75
     76                if ( intval($content_width) > 0 ) {
     77                        $max_width = min( intval($content_width), $max_width );
     78                }
     79        }
    6580        elseif ( $size == 'large' ) {
    6681                /*
    6782                 * We're inserting a large size image into the editor. If it's a really
    function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co 
    7186                 */
    7287                $max_width = intval(get_option('large_size_w'));
    7388                $max_height = intval(get_option('large_size_h'));
    74                 if ( intval($content_width) > 0 )
     89                if ( intval($content_width) > 0 ) {
    7590                        $max_width = min( intval($content_width), $max_width );
     91                }
    7692        } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
    7793                $max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
    7894                $max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
    function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) { 
    706722 */
    707723function get_intermediate_image_sizes() {
    708724        global $_wp_additional_image_sizes;
    709         $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     725        $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes
    710726        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
    711727                $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
    712728
    function get_intermediate_image_sizes() { 
    716732         * @since 2.5.0
    717733         *
    718734         * @param array $image_sizes An array of intermediate image sizes. Defaults
    719          *                           are 'thumbnail', 'medium', 'large'.
     735         *                           are 'thumbnail', 'medium', 'medium_large', 'large'.
    720736         */
    721737        return apply_filters( 'intermediate_image_sizes', $image_sizes );
    722738}
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 3a71bd2..26e9d05 100644
    EOF; 
    724724                                return array( 150, 150 );
    725725                        case 'medium':
    726726                                return array( 300, 225 );
     727                        case 'medium_large':
     728                                return array( 768, 576 );
    727729                        case 'large':
    728730                                return array( 1024, 768 );
    729731                        case 'full':
    EOF; 
    746748                                'descriptor' => 'w',
    747749                                'value'      => $image_meta['sizes']['medium']['width'],
    748750                        ),
     751                        array(
     752                                'url'        => 'http://example.org/wp-content/uploads/' . $year_month . '/' . $image_meta['sizes']['medium_large']['file'],
     753                                'descriptor' => 'w',
     754                                'value'      => $image_meta['sizes']['medium_large']['width'],
     755                        ),
    749756                        array(
    750757                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month . '/' . $image_meta['sizes']['large']['file'],
    751758                                'descriptor' => 'w',
    EOF; 
    791798                                'value'      => $image_meta['sizes']['medium']['width'],
    792799                        ),
    793800                        array(
     801                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['medium_large']['file'],
     802                                'descriptor' => 'w',
     803                                'value'      => $image_meta['sizes']['medium_large']['width'],
     804                        ),
     805                        array(
    794806                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file'],
    795807                                'descriptor' => 'w',
    796808                                'value'      => $image_meta['sizes']['large']['width'],
    EOF; 
    803815                );
    804816
    805817                // Set up test cases for all expected size names and a random one.
    806                 $sizes = array( 'medium', 'large', 'full', 'yoav' );
     818                $sizes = array( 'medium', 'large', 'medium_large', 'full', 'yoav' );
    807819
    808820                foreach ( $sizes as $size ) {
    809821                        $size_array = $this->_get_image_size_array_from_name( $size );
    EOF; 
    832844                $filename_base = basename( $image_meta['file'], '.png' );
    833845                $image_meta['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['file'] );
    834846                $image_meta['sizes']['medium']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['medium']['file'] );
     847                $image_meta['sizes']['medium_large']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['medium_large']['file'] );
    835848                $image_meta['sizes']['large']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['large']['file'] );
    836849
    837850                // Calculate a srcset array.
    EOF; 
    883896                $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    884897                        . $image_meta['sizes']['medium']['file'] . ' ' . $image_meta['sizes']['medium']['width'] . 'w, ';
    885898                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
     899                        . $image_meta['sizes']['medium_large']['file'] . ' ' . $image_meta['sizes']['medium_large']['width'] . 'w, ';
     900                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    886901                        . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ';
    887902                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'] . ' ' . $image_meta['width'] .'w';
    888903
    EOF; 
    909924         */
    910925        function test_wp_get_attachment_image_sizes() {
    911926                // Test sizes against the default WP sizes.
    912                 $intermediates = array( 'thumbnail', 'medium', 'large' );
     927                $intermediates = array('thumbnail', 'medium', 'medium_large', 'large');
    913928                $image_meta = wp_get_attachment_metadata( self::$large_id );
    914929
    915930                foreach( $intermediates as $int_size ) {
  • tests/phpunit/tests/post/attachments.php

    diff --git tests/phpunit/tests/post/attachments.php tests/phpunit/tests/post/attachments.php
    index dfe89ea..ccfea3e 100644
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    3535                // intermediate copies should not exist
    3636                $this->assertFalse( image_get_intermediate_size($id, 'thumbnail') );
    3737                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     38                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    3839
    39                 // medium and full size will both point to the original
     40                // medium, medium_large, and full size will both point to the original
    4041                $downsize = image_downsize($id, 'medium');
    4142                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4243                $this->assertEquals( 50, $downsize[1] );
    4344                $this->assertEquals( 50, $downsize[2] );
    4445
     46                $downsize = image_downsize($id, 'medium_large');
     47                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
     48                $this->assertEquals( 50, $downsize[1] );
     49                $this->assertEquals( 50, $downsize[2] );
     50
    4551                $downsize = image_downsize($id, 'full');
    4652                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4753                $this->assertEquals( 50, $downsize[1] );
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    7278                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path']) );
    7379
    7480                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     81                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    7582
    7683                // the thumb url should point to the thumbnail intermediate
    7784                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    8289                $this->assertEquals( 150, $downsize[1] );
    8390                $this->assertEquals( 150, $downsize[2] );
    8491
    85                 // medium and full will both point to the original
     92                // medium, medium_large, and full will both point to the original
    8693                $downsize = image_downsize($id, 'medium');
    8794                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    8895                $this->assertEquals( 400, $downsize[1] );
    8996                $this->assertEquals( 300, $downsize[2] );
    9097
     98                $downsize = image_downsize($id, 'medium_large');
     99                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
     100                $this->assertEquals( 400, $downsize[1] );
     101                $this->assertEquals( 300, $downsize[2] );
     102
    91103                $downsize = image_downsize($id, 'full');
    92104                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    93105                $this->assertEquals( 400, $downsize[1] );
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    95107
    96108        }
    97109
    98         function test_insert_image_medium() {
     110        function test_insert_image_medium_sizes() {
    99111                if ( !function_exists( 'imagejpeg' ) )
    100112                        $this->markTestSkipped( 'jpeg support unavailable' );
    101113
    102114                update_option('medium_size_w', 400);
    103115                update_option('medium_size_h', 0);
    104116
     117                update_option('medium_large_size_w', 600);
     118                update_option('medium_large_size_h', 0);
     119
    105120                $filename = ( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG' );
    106121                $contents = file_get_contents($filename);
    107122
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    120135                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    121136                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    122137
     138                $medium_large = image_get_intermediate_size($id, 'medium_large');
     139                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] );
     140                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     141
    123142                // the thumb url should point to the thumbnail intermediate
    124143                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
    125144
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    134153                $this->assertEquals( 400, $downsize[1] );
    135154                $this->assertEquals( 602, $downsize[2] );
    136155
     156                $downsize = image_downsize($id, 'medium_large');
     157                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', basename($downsize[0]) );
     158                $this->assertEquals( 600, $downsize[1] );
     159                $this->assertEquals( 904, $downsize[2] );
     160
    137161                $downsize = image_downsize($id, 'full');
    138162                $this->assertEquals( '2007-06-17DSC_4173.jpg', basename($downsize[0]) );
    139163                $this->assertEquals( 680, $downsize[1] );
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    148172                update_option('medium_size_w', 400);
    149173                update_option('medium_size_h', 0);
    150174
     175                update_option('medium_large_size_w', 600);
     176                update_option('medium_large_size_h', 0);
     177
    151178                $filename = ( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG' );
    152179                $contents = file_get_contents($filename);
    153180
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    166193                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    167194                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    168195
     196                $medium_large = image_get_intermediate_size($id, 'medium_large');
     197                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] );
     198                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     199
    169200                $meta = wp_get_attachment_metadata($id);
    170201                $original = $meta['file'];
    171202                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $original) );
    class Tests_Post_Attachments extends WP_UnitTestCase { 
    175206
    176207                $this->assertFalse( is_file($thumb['path']) );
    177208                $this->assertFalse( is_file($medium['path']) );
     209                $this->assertFalse( is_file($medium_large['path']) );
    178210                $this->assertFalse( is_file($original) );
    179211        }
    180212