#1 2025-03-04 17:59:28

mactelesis
Member
2025-03-04
1

Piwigo 15.4.0 Image Metadata Update Bug Report

## Environment
Piwigo 15.4.0 Check for upgrade
Installed on 24 October 2022, 2 years 4 months 1 week 4 days ago
Operating system: Linux
PHP: 8.1.27 (Show info) [2025-03-04 16:56:33]
MySQL: 10.11.11-MariaDB [2025-03-04 16:56:33]
Graphics Library: ImageMagick ImageMagick 7.1.1-43
Cache size N/A   never calculated Refresh
Activated plugin list0
No plugin activated

## Bug Description
When attempting to update image metadata (title and description) through the Piwigo API for images that already have existing metadata, the API returns a success message (`{"stat":"ok","result":null}`) but fails to actually update the database with the new values. In some cases, this can lead to more serious issues including image deletion.

## Technical Details

### API Behavior
1. The `pwg.images.setInfo` method appears to function correctly when updating images with blank title/description fields.
2. When attempting to update an image that already has values in the title or description fields:
   - The API returns `{"stat":"ok","result":null}` suggesting success
   - Verification via `pwg.images.getInfo` shows the original values remain unchanged
   - In severe cases, the operation can result in image deletion from the database

### Reproduction Steps
1. Upload an image to Piwigo via any method
2. Ensure the image has values in the title and/or description fields
3. Use the API to attempt to update these fields:
```
POST to /piwigo/ws.php?format=json
method=pwg.images.setInfo
image_id=336
name=New Title
comment=New Description
pwg_token=[valid token]
```
4. The API returns success: `{"stat":"ok","result":null}`
5. Verify with `pwg.images.getInfo` - the title and description remain unchanged

### Workaround
A workaround has been identified: if an image's title and description fields are manually cleared in the Piwigo admin interface, a single API update can be successfully applied afterward.

### Database Implications
This suggests a potential issue with how Piwigo handles updates to existing metadata in the database. It may be related to:
1. Improper SQL UPDATE statements in the API implementation
2. Transaction issues when updating existing records
3. Permissions or validation checks that fail silently and return success regardless
4. Potential caching issues where updates are acknowledged but not committed

## Impact
This bug prevents programmatic updating of image metadata through the API, significantly limiting the ability to create custom interfaces for non-technical users. It forces reliance on the Piwigo admin interface for content management.

## Additional Notes
- The admin interface successfully updates images (but is not suitable for non-technical users)
- Security tokens are correctly obtained and validated
- All other API methods appear to function correctly (listing images, albums, etc.)
- In testing, multiple different approaches were attempted with the same result, including direct admin form submission simulation

Offline

 

#2 2025-03-04 20:27:09

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14067

Re: Piwigo 15.4.0 Image Metadata Update Bug Report

Hi mactelesis,

pwg.images.setInfo (POST only / Admin only)

single_value_mode can be "fill_if_empty" (only use the input value if the corresponding values is currently empty) or "replace" (overwrite any existing value) and applies to single values properties like name/author/date_creation/comment.

"fill_if_empty" is the default value if not provided. Try to send single_value_mode=replace and make a new test.

In some cases, this can lead to more serious issues including image deletion.

Wow :-/ Tell us more!

Offline

 

Board footer

Powered by FluxBB