gregstoll / gallery2

A fork of the Gallery project (galleryproject.org) that supports PHP 8
GNU General Public License v2.0
44 stars 24 forks source link

Adding items fails after upgrade from php 8.0 to php 8.1 #123

Closed kaeni1Ohkohd closed 1 year ago

kaeni1Ohkohd commented 1 year ago

Attempting to add a new item into an album gives the trace output below:

Error (ERROR_OBSOLETE_DATA) : UPDATE g2_Entity SET g_serialNumber=? WHERE g_id=? AND g_serialNumber=? (2|18472|1)

in modules/core/classes/GalleryStorage/GalleryStorageExtras.class at line 362 (GalleryCoreApi::error)
in modules/core/classes/GalleryStorage.class at line 325 (GalleryStorageExtras::saveEntity)
in modules/core/classes/GalleryEntity.class at line 294 (GalleryStorage::saveEntity)
in modules/core/classes/GalleryDerivative.class at line 239 (GalleryEntity::save)
in modules/core/classes/helpers/GalleryDerivativeHelper_advanced.class at line 850 (GalleryDerivative::save)
in modules/core/classes/GalleryCoreApi.class at line 997 (GalleryDerivativeHelper_advanced::rebuildCache)
in modules/core/classes/helpers/GalleryDerivativeHelper_simple.class at line 50 (GalleryCoreApi::rebuildDerivativeCache)
in modules/core/classes/GalleryCoreApi.class at line 984 (GalleryDerivativeHelper_simple::rebuildCacheIfNotCurrent)
in modules/core/CreateThumbnailOption.inc at line 66 (GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent)
in modules/core/ItemAdd.inc at line 363 (CreateThumbnailOption::handleRequestAfterAdd)
in modules/core/ItemAdd.inc at line 179 (ItemAddController::postprocessItems)
in modules/core/classes/GalleryTemplateAdapter.class at line 1095 (ItemAddController::handleRequestWithProgressBar)
in /usr/local/gallery2/g2data/smarty/templates_c/%%1975211924/matrix/%%3A^3A8^3A818B59%%theme.tpl.php at line 75 (GalleryTemplateAdapter::trailer)
in lib/smarty/Smarty.class.php at line 1255
in modules/core/classes/GallerySmarty.class at line 58 (Smarty::fetch)
in modules/core/classes/GalleryTemplate.class at line 241 (GallerySmarty::fetch)
in main.php at line 506 (GalleryTemplate::display)
in main.php at line 104
in main.php at line 88

It looks like the SQL query somehow is run twice with the same values. A query in the database table shows that the row was successfully updated the first time.

Adding the item on FreeBSD 12.3 with PostgreSQL 12.13 and php 8.0.26 works without any problem but it fails on FreeBSD 12.3 with PostgreSQL 12.13 and php 8.1.13.

gregstoll commented 1 year ago

That's interesting. I found this report from the Gallery website a long time ago - does the name of the item or album have any accented characters?

kaeni1Ohkohd commented 1 year ago

No, no "fancy" characters at all. Both the album name (testalbum) and the item name (DSC_3149.jpg) will fit into US7ASCII.

kaeni1Ohkohd commented 1 year ago

To verify my suspicion that the issue is caused by the ancient adodb (version V4.98 13 Feb 2008) included in Gallery2 I replaced that adodb version in gallery2/lib/adodb with the latest (v5.22.4 2022-10-28) and that solves the issue when using PostgreSQL as database. The catch is that it breaks at least the imageblock module due to a stricter syntax check.

I haven't done any tests with other databases than PostgreSQL but I suspect the probability for at least something being broken after an upgrade of adodb is 100% considering how much that have been changed in adodb in almost 15 years.

Upgrading adodb is a major step but imho it is the only viable solution in the long run to keep Gallery2 supportable going forward.

I will continue to work on this as time permits since it is a showstopper for upgrading from php 8.0 to php 8.1 when using PostgreSQL as the database.

gregstoll commented 1 year ago

I messed up the branching again but this has been applied in commit 0dfe2be. Closing.