friends-of-contao / contao.wtf

Contao What's the failure - An collection of common contao failures
4 stars 0 forks source link

The X coordinate plus the width must not be greater than 1 #13

Open fritzmg opened 3 years ago

fritzmg commented 3 years ago

Error message

Internal Server Error: The X coordinate plus the width must not be greater than 1

Versions

Location

Link to forum thread

https://community.contao.org/de/showthread.php?75740-Dateiverwaltung-funktioniert-nach-Update-auf-Contao-4-8-nicht-mehr

fritzmg commented 3 years ago

Cause

Starting with Contao 4.8 (or may be one or two minor versions sooner) Contao is storing the important part of images in a relative format, i.e. with floating point numbers between 0 and 1, instead of absolute numbers in integers, representing the amount of pixels in either direction of the image dimensions.

Therefore a migration is done to convert the existing absolute integer values to relative float values. However, this migration might fail for individual images under certain circumstances, some of which are still unknown.

One instance where it might happen: if you have defined the important part of an image in Contao 4.4 and then replaced the image with a smaller version in Contao 4.4 (either via SFTP or via the back end), the important part info isn't automatically updated and thus might already contain invalid values. The important part values of this image then cannot be transformed into the new format any more.

There are also reports of instances where this always happens with SVG images when updating from 4.4 to 4.9 for example.

fritzmg commented 3 years ago

Workaround

In order to find the images in Contao 4.9+ with invalid important parts, you can use the following SQL query:

SELECT * FROM tl_files WHERE importantPartX + importantPartWidth > 1 OR importantPartY + importantPartHeight > 1;

This allows you to keep a note of the affected images somewhere, so that you can reset the important part now and afterwards define the important part again in the back end. Use the following SQL query to reset the important part on the affected images:

UPDATE tl_files SET importantPartX = 0, importantPartY = 0, importantPartWidth = 0, importantPartHeight = 0 WHERE importantPartX + importantPartWidth > 1 OR importantPartY + importantPartHeight > 1;
fritzmg commented 3 years ago

This should not be an issue any more. See https://github.com/contao/contao/pull/2884