Problem/Motivation

After updating to PHP 8, we have an error saving images.

exif_read_data(): Argument #1 ($file) cannot be empty

Comments

xpersonas created an issue. See original summary.

xpersonas’s picture

Issue summary: View changes
StatusFileSize
new883 bytes
xpersonas’s picture

Issue summary: View changes
manishsaharan’s picture

Status: Active » Needs review

I had also faced the same issue, but applying patch #2 resolved my issue

sagesolutions’s picture

Status: Needs review » Reviewed & tested by the community

Can confirm patch #2 fixes the PHP 8.1 error

solideogloria’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

The patches fixes the error for me as well.

However, false should be in all caps, FALSE, to conform to Drupal's coding standards.

solideogloria’s picture

StatusFileSize
new969 bytes

Here's a Drupal 7 patch that also includes the patch for #3263166: Allow other mime types.

The section they patch are the same, so there are patch conflicts without manual adjustments. This should make that easier.

solideogloria’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

Here's a patch for Drupal 8+ that fixes both this issue and #3263166: Allow other mime types. (Again because of patch conflicts.)

I also used short array syntax.

joelpittet’s picture

This looks great back to RTBC

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
sokru’s picture

solideogloria’s picture

Status: Reviewed & tested by the community » Needs work

The patches all replaced @exif_read_data with exif_read_data. I now get warnings when using a PNG file (#3263166: Allow other mime types).

@exif_read_data should be used.

Warning: exif_read_data(future-8-4-23.png): File not supported in _exif_orientation_rotate() (line 68 of /var/www/html/web/modules/contrib/exif_orientation/exif_orientation.module)
#0 /var/www/html/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /var/www/html/web/modules/contrib/exif_orientation/exif_orientation.module(68): exif_read_data()
#3 /var/www/html/web/modules/contrib/exif_orientation/exif_orientation.module(17): _exif_orientation_rotate()
#4 [internal function]: exif_orientation_file_presave()

solideogloria’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

Drupal 8+ patch, same as before except I added @

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

That's fair though strange we explicitly check for png mime type, does it sometimes work?

solideogloria’s picture

It works, but it just shows a warning.

Errors of level E_WARNING and/or E_NOTICE may be raised for unsupported tags or other potential error conditions, but the function still tries to read all comprehensible information.

https://www.php.net/manual/en/function.exif-read-data.php

  • heddn committed dabc2dd7 on 8.x-1.x authored by solideogloria
    Issue #3220370 by solideogloria, joelpittet, heddn: exif_read_data():...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.