WordPress.org

Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 13 months ago

#50573 closed defect (bug) (duplicate)

ImageMagick PDF test failures

Reported by: SergeyBiryukov Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Media Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Background: #48145, #50466.

After [48329], there are test failures on Travis that appear to be unrelated to the commit:

There was 1 error:

1) Tests_Image_Functions::test_pdf_preview_doesnt_overwrite_existing_jpeg
Undefined index: sizes

/var/www/tests/phpunit/tests/image/functions.php:620

--

There were 3 failures:
1) Tests_Image_Functions::test_wp_generate_attachment_metadata_pdf
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 (
-    'sizes' => Array &1 (
-        'full' => Array &2 (
-            'file' => 'wordpress-gsoc-flyer-pdf.jpg'
-            'width' => 1088
-            'height' => 1408
-            'mime-type' => 'image/jpeg'
-        )
-        'medium' => Array &3 (
-            'file' => 'wordpress-gsoc-flyer-pdf-232x300.jpg'
-            'width' => 232
-            'height' => 300
-            'mime-type' => 'image/jpeg'
-        )
-        'large' => Array &4 (
-            'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg'
-            'width' => 791
-            'height' => 1024
-            'mime-type' => 'image/jpeg'
-        )
-        'thumbnail' => Array &5 (
-            'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg'
-            'width' => 116
-            'height' => 150
-            'mime-type' => 'image/jpeg'
-        )
-    )
-)
+Array &0 ()

/var/www/tests/phpunit/tests/image/functions.php:466

2) Tests_Image_Functions::test_crop_setting_for_pdf
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 (
-    'sizes' => Array &1 (
-        'full' => Array &2 (
-            'file' => 'wordpress-gsoc-flyer-pdf.jpg'
-            'width' => 1088
-            'height' => 1408
-            'mime-type' => 'image/jpeg'
-        )
-        'medium' => Array &3 (
-            'file' => 'wordpress-gsoc-flyer-pdf-300x300.jpg'
-            'width' => 300
-            'height' => 300
-            'mime-type' => 'image/jpeg'
-        )
-        'large' => Array &4 (
-            'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg'
-            'width' => 791
-            'height' => 1024
-            'mime-type' => 'image/jpeg'
-        )
-        'thumbnail' => Array &5 (
-            'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg'
-            'width' => 116
-            'height' => 150
-            'mime-type' => 'image/jpeg'
-        )
-    )
-)
+Array &0 ()

/var/www/tests/phpunit/tests/image/functions.php:531

3) Tests_Image_Functions::test_fallback_intermediate_image_sizes
The `test-size` was not added to the metadata.
Failed asserting that false is true.

/var/www/tests/phpunit/tests/image/functions.php:572

This appears to be caused by wp_generate_attachment_metadata() failing to generate the metadata for PDF files, due to wp_get_image_editor() returning a WP_Error object:

 ["errors"]=>
  array(1) {
    ["invalid_image"]=>
    array(1) {
      [0]=>
      string(115) "attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408"
    }
  }
  ["error_data"]=>
  array(1) {
    ["invalid_image"]=>
    string(29) "/tmp/wordpress-gsoc-flyer.pdf"
  }
}

It's not quite clear why this suddenly started failing now, I guess something has changed in the environment recently.

Props @enrico.sorcinelli for helping with debugging here.

Change History (24)

#1 @SergeyBiryukov
17 months ago

  • Description modified (diff)

#2 @SergeyBiryukov
17 months ago

In 48338:

Tests: Add some assertions to PDF tests for better debugging.

Props enrico.sorcinelli.
See #50573.

#3 @SergeyBiryukov
17 months ago

It's interesting that the tests fail on PHP 7.1+ and pass on 5.6 and 7.0.

Last edited 17 months ago by SergeyBiryukov (previous) (diff)

#4 follow-up: @azaozz
17 months ago

Seems caused by upgraded ImageMagick or Postscript on the server. Given the very last moment these errors appeared, thinking the tests can be bypassed for now. Then get them fixed (if at all possible) and enabled for beta-2.

#5 @SergeyBiryukov
17 months ago

In 48341:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

See #50573.

#6 @SergeyBiryukov
17 months ago

  • Summary changed from Random PHP test failures, take 3 to ImageMagick PDF test failures

#7 @SergeyBiryukov
17 months ago

In 48366:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 5.4 branch.

See #50573.

This ticket was mentioned in Slack in #core by sergey. View the logs.


17 months ago

#9 in reply to: ↑ 4 @mikeschroder
17 months ago

Replying to azaozz:

Seems caused by upgraded ImageMagick or Postscript on the server.

<snip>

I agree -- probably ImageMagick.
I suspect that it is due to #45813, and we should be able to work around it by writing our own policy.xml.

As mentioned in the other ticket, it's probably also worthwhile to find out whether we can get the entry removed from the Ubuntu package now that the security issue has, as far as I'm aware, been resolved.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


17 months ago

#11 @SergeyBiryukov
17 months ago

In 48483:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 5.3 branch.

See #50573.

#12 @SergeyBiryukov
17 months ago

In 48484:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 5.2 branch.

See #50573.

#13 @SergeyBiryukov
17 months ago

In 48485:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 5.1 branch.

See #50573.

#14 @SergeyBiryukov
17 months ago

In 48486:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 5.0 branch.

See #50573.

#15 @SergeyBiryukov
17 months ago

In 48487:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 4.9 branch.

See #50573.

#16 @SergeyBiryukov
17 months ago

In 48488:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 4.8 branch.

See #50573.

#17 @SergeyBiryukov
17 months ago

In 48489:

Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.

Merges [48338], [48341] to the 4.7 branch.

See #50573.

#18 @SergeyBiryukov
17 months ago

  • Milestone 5.5 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing in favor of #45813, let's continue there.

#19 @mikeschroder
17 months ago

I'm questioning whether this should be part of #45813, since it'd be good for core to be running Imagick tests whether or not the default settings are fixed upstream.

#20 @desrosj
13 months ago

It looks like the last chunk of [48489] has the incorrect variable. I'll be correcting this and backporting to the 4.7 branch as it blocks the progress of #48301.

#21 @desrosj
13 months ago

  • Milestone set to 5.5

#22 @desrosj
13 months ago

In 49523:

Tests: Fix an incorrect variable name in PDF tests.

This causes a PHP error when running the test suite with PDF rendering supported.

See #50573, #48301.

#23 @desrosj
13 months ago

In 49524:

Tests: Fix an incorrect variable name in PDF tests.

This causes a PHP error when running the test suite with PDF rendering supported.

Merges [49523] to the 4.9 branch.
See #50573, #48301.

#24 @desrosj
13 months ago

In 49526:

Tests: Fix an incorrect variable name in PDF tests.

This causes a PHP error when running the test suite with PDF rendering supported.

Merges [49523] to the 4.7 branch.
See #50573, #48301.

Note: See TracTickets for help on using tickets.