User agent too long when opening share link in Facebook Messenger (MySQL error) share album #2128

Open
opened 2026-10-05 01:07:09 +02:00 by adam · 1 comment
Owner

When someone opens a Piwigo ShareAlbum link in the Facebook Messenger in-app browser, Piwigo throws a fatal error:

mysqli_sql_exception: Data too long for column 'user_agent'

This happens because the Facebook/Messenger in-app browser sends extremely long user-agent strings (sometimes >500 characters), while the database column user_agent in table piwigo_sharealbum_users is defined as VARCHAR(255).

Steps to reproduce

  1. Create a share link in Piwigo using ShareAlbum.

  2. Send the link to someone via Facebook Messenger.

  3. Open the link inside the Messenger in-app browser.

  4. Fatal error appears instead of loading the gallery.

When someone opens a Piwigo ShareAlbum link in the Facebook Messenger in-app browser, Piwigo throws a fatal error: mysqli_sql_exception: Data too long for column 'user_agent' This happens because the Facebook/Messenger in-app browser sends extremely long user-agent strings (sometimes >500 characters), while the database column user_agent in table piwigo_sharealbum_users is defined as VARCHAR(255). Steps to reproduce 1. Create a share link in Piwigo using ShareAlbum. 2. Send the link to someone via Facebook Messenger. 3. Open the link inside the Messenger in-app browser. 4. Fatal error appears instead of loading the gallery. <!-- github-sync-id:3640306738 -->
Author
Owner

When using the ShareAlbum plugin (v15.1) on Piwigo 16.0.0rc3, opening a shared album link inside certain mobile app browsers causes Piwigo to throw a fatal database error:

Uncaught mysqli_sql_exception: Data too long for column 'user_agent'

This happens when opening the shared album URL inside:

Facebook Messenger

Instagram's in-app browser

TikTok in-app browser

Some versions of WhatsApp Web / LinkedIn WebView

These apps send extremely long User-Agent strings (often 600–1500+ characters), which exceed the size of the database column created by earlier versions of ShareAlbum.

Troubleshooting we performed

We spent extensive time investigating this issue and verified the following:

ShareAlbum 15.1 does NOT insert or handle the user_agent field anywhere.

We searched the entire plugin folder for:

HTTP_USER_AGENT

user_agent

INSERT INTO

No references exist in any plugin file.

The plugin only logs: cat_id, ip, and visit_d.

However, the table piwigo_sharealbum_log in the database contains a user_agent column.

This column exists from older versions of ShareAlbum.

The column type is VARCHAR(255).

Piwigo core automatically injects $_SERVER['HTTP_USER_AGENT'] into this column, even though the plugin does not insert it.

This appears to happen inside Piwigo’s DB layer, not the plugin.

Piwigo automatically fills extra table fields when the INSERT statement omits them.

Because the user-agent sent by Messenger/Instagram/TikTok is much longer than 255 characters, MariaDB rejects the insert.

This causes the fatal SQL exception shown above.

This is reproducible 100% of the time by opening a ShareAlbum URL inside Facebook Messenger.

Workaround tested:
Increasing the user_agent column size fixes the issue:

ALTER TABLE piwigo_sharealbum_log
MODIFY user_agent TEXT;

After this change, ShareAlbum links work correctly again in all app browsers.

Expected Behavior

Piwigo should not automatically inject metadata (such as user_agent) into plugin tables unless the plugin explicitly requests it.

Alternatively, Piwigo should provide a way for plugin authors or admins to disable this auto-injection.

Or Piwigo should apply truncation to avoid strict-mode SQL crashes.

Actual Behavior

Piwigo auto-fills the user_agent column with a very long user-agent from mobile apps.

The column overflows (varchar(255)), causing MariaDB strict mode errors.

ShareAlbum links break for users opening them in Messenger/Instagram/TikTok.

Steps to Reproduce

Install Piwigo 16.0.0rc3

Install ShareAlbum 15.1

Share an album link

Open the link inside Facebook Messenger

Observe fatal SQL error:

Uncaught mysqli_sql_exception: Data too long for column 'user_agent'

Why this is a core issue (not plugin-related)

The plugin does not read, store, or reference user_agent anywhere in its PHP code.

Only Piwigo core is responsible for populating this column implicitly.

Therefore this behavior should be reviewed and possibly changed in Piwigo core.

Suggested Fixes

Any of the following would resolve this permanently:

Stop auto-injecting user_agent into plugin tables.

Allow plugin authors/admins to disable this behavior.

Automatically truncate user_agent before insertion.

Recommend DB migration to TEXT for long fields.

Add detection for excessively long user-agent strings.

Environment

Piwigo version: 16.0.0rc3

ShareAlbum plugin version: 15.1

Database: MariaDB 10.x

PHP: 8.x

Error occurs in: Mobile app browsers (Messenger, Instagram, TikTok)

When using the ShareAlbum plugin (v15.1) on Piwigo 16.0.0rc3, opening a shared album link inside certain mobile app browsers causes Piwigo to throw a fatal database error: Uncaught mysqli_sql_exception: Data too long for column 'user_agent' This happens when opening the shared album URL inside: Facebook Messenger Instagram's in-app browser TikTok in-app browser Some versions of WhatsApp Web / LinkedIn WebView These apps send extremely long User-Agent strings (often 600–1500+ characters), which exceed the size of the database column created by earlier versions of ShareAlbum. Troubleshooting we performed We spent extensive time investigating this issue and verified the following: ShareAlbum 15.1 does NOT insert or handle the user_agent field anywhere. We searched the entire plugin folder for: HTTP_USER_AGENT user_agent INSERT INTO No references exist in any plugin file. The plugin only logs: cat_id, ip, and visit_d. However, the table piwigo_sharealbum_log in the database contains a user_agent column. This column exists from older versions of ShareAlbum. The column type is VARCHAR(255). Piwigo core automatically injects $_SERVER['HTTP_USER_AGENT'] into this column, even though the plugin does not insert it. This appears to happen inside Piwigo’s DB layer, not the plugin. Piwigo automatically fills extra table fields when the INSERT statement omits them. Because the user-agent sent by Messenger/Instagram/TikTok is much longer than 255 characters, MariaDB rejects the insert. This causes the fatal SQL exception shown above. This is reproducible 100% of the time by opening a ShareAlbum URL inside Facebook Messenger. Workaround tested: Increasing the user_agent column size fixes the issue: ALTER TABLE piwigo_sharealbum_log MODIFY user_agent TEXT; After this change, ShareAlbum links work correctly again in all app browsers. Expected Behavior Piwigo should not automatically inject metadata (such as user_agent) into plugin tables unless the plugin explicitly requests it. Alternatively, Piwigo should provide a way for plugin authors or admins to disable this auto-injection. Or Piwigo should apply truncation to avoid strict-mode SQL crashes. Actual Behavior Piwigo auto-fills the user_agent column with a very long user-agent from mobile apps. The column overflows (varchar(255)), causing MariaDB strict mode errors. ShareAlbum links break for users opening them in Messenger/Instagram/TikTok. Steps to Reproduce Install Piwigo 16.0.0rc3 Install ShareAlbum 15.1 Share an album link Open the link inside Facebook Messenger Observe fatal SQL error: Uncaught mysqli_sql_exception: Data too long for column 'user_agent' Why this is a core issue (not plugin-related) The plugin does not read, store, or reference user_agent anywhere in its PHP code. Only Piwigo core is responsible for populating this column implicitly. Therefore this behavior should be reviewed and possibly changed in Piwigo core. Suggested Fixes Any of the following would resolve this permanently: Stop auto-injecting user_agent into plugin tables. Allow plugin authors/admins to disable this behavior. Automatically truncate user_agent before insertion. Recommend DB migration to TEXT for long fields. Add detection for excessively long user-agent strings. Environment Piwigo version: 16.0.0rc3 ShareAlbum plugin version: 15.1 Database: MariaDB 10.x PHP: 8.x Error occurs in: Mobile app browsers (Messenger, Instagram, TikTok) <!-- github-comment-id:3552407835 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2128