Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
mjau-mjau
X3 Wizard
Topic Author
Posts: 13993
Joined: 30 Sep 2006, 03:37

:warning: PHP 7.3 Critical Bug Warning + X3.27.2

09 Feb 2019, 05:50

Hi folks. After testing X3 on latest PHP 7.3, I discovered a PHP-7.3 bug which affects X3. The PHP bug may potentially corrupt JPG images when using the iptcembed() function, which is used in X3 when saving data (titles, descriptions etc) into images from the X3 control panel. The PHP bug is officially reported on 30. Jan 2019:
https://bugs.php.net/bug.php?id=77546

The bug affects PHP versions 7.3.0, 7.3.1 and 7.3.2, and will be fixed in PHP 7.3.3 according to official comments.

How is the bug produced?
If A) your server is using PHP 7.3, and B ) you are editing image data (titles, descriptions etc) [screenshot], and C) you have Settings > Advanced > "Store image settings in image as IPTC" enabled (enabled by default) [screenshot], you are in risk that PHP iptcembed() function will corrupt the images you are editing. The error does not always happen, and is related to the amount of characters in total across the image data input fields. Once an image gets corrupted, there will be ERRORS on the X3 page that contains the images, and the affected image will become irreversibly corrupted ... If this happens, you would have to DELETE the affected image(s), and re-upload.

Solutions
Follow ONE (or more) of the options below to remain safe.
  • Update to latest X3.27.2 *See note below
  • Or don't use PHP 7.3 yet (7.2 and lower is safe, and the issue will be fixed in PHP 7.3.3).
  • Or disable Settings > Advanced > "Store image settings in image as IPTC" [screenshot] (while using PHP 7.3).
  • Or don't edit image data (titles, descriptions etc) [screenshot] (while using PHP 7.3).
* X3.27.2 PATCH
Even after updating to X3.27.2, the bug (which is native to PHP 7.3) will still remain, but is BYPASSED in X3 by validating the image stream before attempting to write new IPTC data into the image. This will prevent errors, and protect your images from becoming corrupted, although it might also block IPTC data from being stored into the image (if the edited image data is detected as corrupt). This itself is not a critical issue, because X3 will still store all your image data in the page.json data file, but the data will not inherit if you MOVE or COPY images.
Code
// PHP 7.3 bug https://bugs.php.net/bug.php?id=77546
// detect if image is corrupt before writing
if(version_compare(PHP_VERSION, '7.3') >= 0 && version_compare(PHP_VERSION, '7.3.3') < 0 && !@getimagesizefromstring($content)) return;
Just to be clear, as long as you are using PHP 7.3, even if you have bypassed the bug by updating to X3.27.2 (or disabled Settings > Advanced > "Store image settings in image as IPTC"), X3 may not be able to store all image data inside the image as IPTC. This means that if you move or copy images into new locations, the stored image data will not be moved with the image. Therefore, you may want to consider solution #2 also.

X3.26 / X3.27 Release
On a related note, we are very much looking forward to official release post (coming soon) for combined release of X3.26 [panorama plugin] and X3.27  :punch:
 
User avatar
mjau-mjau
X3 Wizard
Topic Author
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: :warning: PHP 7.3 Critical Bug Warning + X3.27.2

14 Feb 2019, 09:47

X3.27.3 was released, with more fixes for IPTC.
 
User avatar
mjau-mjau
X3 Wizard
Topic Author
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: :warning: PHP 7.3 Critical Bug Warning + X3.27.2

09 Mar 2019, 04:08

This bug was fixed in PHP 7.3.3 released a couple of days ago, 07 March 2019.

If you were on the affected PHP 7.3 branch, most servers automatically update their PHP to latest minor version.