Make WordPress Core

Opened 3 weeks ago

Last modified 92 minutes ago

#41973 assigned defect (bug)

HTTP Error when uploading images on PHP 7.1.9

Reported by: robhindle Owned by: joemcgill
Milestone: 4.9.1 Priority: high
Severity: normal Version: 4.8.2
Component: Media Keywords: reporter-feedback
Focuses: Cc:


I experienced a problem with image upload, looks like a problem with image.php and/or upload.php

Reverting to a prior version of PHP resolved it for now.

For a more detailed explanation of the problem and my actions see https://wordpress.org/support/topic/http-error-115/#post-9524067

Change History (18)

#1 @SergeyBiryukov
3 weeks ago

  • Summary changed from php 7.1.9 to HTTP Error when uploading images on PHP 7.1.9

#2 @joemcgill
3 weeks ago

Hi @robhindle,

Can you check to see if you are using a compatible version of ImageMagick + the right Imagick PHP extension for that version, and/or a compatible version of GD?

#3 @robhindle
3 weeks ago

with PHP 7.0.23 imagick module version is V3.4.1
ImageMagick library vsn: ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org

with PHP 7.1.9 module version is V3.4.3 RC1
ImageMagick library vsn: 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org

#4 @WraithKenny
3 weeks ago

Might be related to a PHP 7.1 change: http://php.net/manual/en/migration71.incompatible.php#migration71.incompatible.empty-string-index-operator

"Applying the empty index operator to a string (e.g. $str[] = $x) throws a fatal error instead of converting silently to array."

In PHP < 7.1, you could have

$variable = ''; // say, from an empty return on `get_post_meta()`
$variable['key'] = 'anything';

This will turn into a fatal error on PHP >= 7.1

I believe there are probably a few places in core where this is happening, as well as countless plugins. (#41496 possibly related).

Last edited 3 weeks ago by WraithKenny (previous) (diff)

#5 @dd32
3 weeks ago

  • Keywords reporter-feedback added

Hey @robhindle

Would you be able to check your PHP errors for the exact error which PHP is encountering?
Were you able to attempt deactivating plugins to see if that helped?

I've just tested WordPress trunk & 4.8 on PHP 7.1.9 with (and without) ImageMagick 3.4.3 (lib 6.7.2-7) and I don't see any issues immediately.

as @WraithKenny says, this could quite possibly be due to a plugin with code incompatible with PHP 7.1, although I'm not aware of any locations in core which would be affected by the stated change.

#6 @robhindle
3 weeks ago

Errors from log file are:
[Sat Sep 23 16:04:32.736522 2017] [proxy_fcgi:error] [pid 27185:tid 140636833384192] (104)Connection reset by peer: [client] AH01075: Error dispatching request to :, referer: https://pdmhs.co.uk/wp-admin/upload.php

[Sat Sep 23 16:14:56.993005 2017] [proxy_fcgi:error] [pid 27188:tid 140636883740416] [client] AH01071: Got error ‘PHP message: PHP Warning: Illegal string offset ‘width’ in /var/www/vhosts/pdmhs.co.uk/httpdocs/wp-content/themes/twentyeleven/image.php on line 34\nPHP message: PHP Warning: Illegal string offset ‘height’ in /var/www/vhosts/pdmhs.co.uk/httpdocs/wp-content/themes/twentyeleven/image.php on line 35\n’, referer: https://pdmhs.co.uk/wp-admin/upload.php?item=2482

I was reluctant to deactivate plugins as without them the site's a mess but I summoned the courage, switched to PHP 7.1.9 then progressively re-enabled, testing image upload as I went along. Now I am confused, when I'd finished adding them all back image upload was still working. I rechecked imagemagick version in case of update at the server - no change.

#7 @dd32
3 weeks ago

@robhindle Thanks, but unfortunately neither of those are very useful. I was hopeful that there'd be something labeled a PHP Fatal Error available

The first is PHP-fpm's internal error, not the actual fatal error from the PHP worker, which doesn't reveal anything. It's simply saying PHP didn't return it any data, most likely due to it hitting a fatal error.

The second is from the theme (on another HTTP request, ~10 minutes later), which doesn't impact the upload screen, it's saying that for some reason the images metadata in the database is corrupt/incomplete, most likely due to the upload fatal error being hit.

Last edited 3 weeks ago by dd32 (previous) (diff)

#8 @tr1988
3 weeks ago

Exactly the same issue here too with WordPress 4.8.2. Switching PHP from v7.1.9 to v7.0.23 fixes the problem for me.

Also getting the same "Connection reset by peer" error in the PHP logs, but nothing else relevant.

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

3 weeks ago

#10 @joemcgill
3 weeks ago

Generally, when we see this error it's a misconfiguration with the Imagick PHP extension, so that's where I'd check first. On a broken environment, you can try switching to GD as the image handler to see if that, in fact, is the culprit.

This filter will reprioritize GD as the default image editor used by WordPress:

add_filter( 'wp_image_editors', 'change_graphic_lib' );
function change_graphic_lib() {
    return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );

#11 @joemcgill
3 weeks ago

  • Owner set to joemcgill
  • Priority changed from normal to high
  • Status changed from new to assigned

#12 @joemcgill
3 weeks ago

  • Milestone changed from Awaiting Review to 4.9

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

3 weeks ago

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

2 weeks ago

#15 @mikeschroder
13 days ago

I was not able to reproduce this on a PHP 7.1.9 install with the following configuration/versions of related libraries (retrieved via Debug Media plugin):

Active Editor	WP_Image_Editor_Imagick
Imagick Module Number	1655
ImageMagick Version	ImageMagick 6.7.7-10 2017-07-15 Q16 http://www.imagemagick.org
GD Version	bundled (2.1.0 compatible)
Ghostscript Version	9.05
Memory Limit	128M
Max Execution Time	30
Max Input Time	-1
Upload Max Filesize	64M
Post Max Size	65M

Imagick Resource Limits
Imagick area limit	2 GB
Imagick disk limit	-1
Imagick file limit	6000
Imagick map limit	2 GB
Imagick memory limit	1,000 MB
Imagick thread limit	Not Available

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

7 days ago

#17 @joemcgill
12 hours ago

For the purposes of 4.9, I don't see this currently being a blocker, and is probably an ImageMagick/Imagick server level issue and not a core issue based on observations so far, but I want to keep this open through the release so it stays front of mind.

#18 @SergeyBiryukov
92 minutes ago

  • Milestone changed from 4.9 to 4.9.1

Looks like there are no actionable items for 4.9 here. 4.9-beta3 is in a few hours, so I'm punting.

Note: See TracTickets for help on using tickets.