Make WordPress Core


Ignore:
Timestamp:
08/16/2020 01:31:57 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Introduce is_gd_image() to check for PHP 8 GdImage object instances.

In PHP 8, the GD extension uses GdImage objects instead of resources for its underlying data structures.

This updates the existing is_resource() calls for image resources in core to accomodate for GdImage instances as well.

Props ayeshrajans, jrf.
Fixes #50833.

File:
1 edited

Legend:

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

    r48464 r48798  
    124124        }
    125125
     126
     127        /**
     128         * @ticket 50833
     129         */
     130        function test_is_gd_image_invalid_types() {
     131                $this->assertFalse( is_gd_image( new stdClass() ) );
     132                $this->assertFalse( is_gd_image( array() ) );
     133                $this->assertFalse( is_gd_image( null ) );
     134
     135                $handle = fopen( __FILE__, 'r' );
     136                $this->assertFalse( is_gd_image( $handle ) );
     137                fclose( $handle );
     138        }
     139
     140        /**
     141         * @ticket 50833
     142         * @requires extension gd
     143         */
     144        function test_is_gd_image_valid_types() {
     145                $this->assertTrue( is_gd_image( imagecreate( 5, 5 ) ) );
     146        }
     147
    126148        /**
    127149         * Test save image file and mime_types
Note: See TracChangeset for help on using the changeset viewer.