Make WordPress Core

Ticket #41148: 41148.patch

File 41148.patch, 927 bytes (added by schlessera, 7 years ago)

Check for valid $metadata array before accessing it

  • tests/phpunit/tests/image/functions.php

    diff --git tests/phpunit/tests/image/functions.php tests/phpunit/tests/image/functions.php
    index 27bdbf3181..a2a509b74d 100644
    class Tests_Image_Functions extends WP_UnitTestCase { 
    487487                ) );
    488488
    489489                $metadata = wp_generate_attachment_metadata( $attachment_id, $pdf_path );
     490
     491                // Make sure we have valid data to run the actual test.
     492                $failure_message = 'Could not generate proper PDF attachment metadata to run test.';
     493                $this->assertInternalType( 'array', $metadata, $failure_message );
     494                $this->assertArrayHasKey( 'sizes', $metadata, $failure_message );
     495                $this->assertArrayHasKey( 'full', $metadata['sizes'], $failure_message );
     496                $this->assertArrayHasKey( 'file', $metadata['full'], $failure_message );
     497
    490498                $preview_path = '/tmp/' . $metadata['sizes']['full']['file'];
    491499
    492500                // PDF preview didn't overwrite PDF.