Serendipity: Error when uploading a file to media store

s9y version: 2.3-beta PHP version: 7.3.4 (debian buster package) Postgres version: 11.2 (debian buster package)

When I upload a file to the media store, I get the following error site displayed:

== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: pg_query(): Query failed: ERROR: value too long for type character varying(5) in <...>web/include/db/postgres.inc.php on line 222.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.



Fatal error:  Uncaught ErrorException: Warning: pg_query(): Query failed: ERROR:  value too long for type character varying(5) in <...>web/include/db/postgres.inc.php:222
Stack trace:
#0 [internal function]: errorToExceptionHandler(2, 'pg_query(): Que...', '/data/www/<...>...', 222, Array)
#1 <...>web/include/db/postgres.inc.php(222): pg_query(Resource id #1, 'INSERT INTO ser...')
#2 <...>web/include/functions_images.inc.php(633): serendipity_db_query('INSERT INTO ser...')
#3 <...>web/include/functions_images.inc.php(1631): serendipity_insertImageInDatabase('header1.pngt134...', '') 
#4 <...>web/include/functions_images.inc.php(3697): serendipity_displayImageList(1, 2, true, NULL, false, NULL, Array)
#5 <...>web/include/admin/images.inc.php(424): showMediaLibrary(true)
#6 <...>web/serendipity_admin.php(109): include('/data/w in <...>web/include/db/postgres.inc.php on line 222 

 == ERROR-REPORT (BETA/ALPHA-BUILDS) ==  

Fatal Error: Uncaught ErrorException: Warning: pg_query(): Query failed: ERROR:  value too long for type character varying(5) in <...>web/include/db/postgres.inc.php:222
Stack trace:
#0 [internal function]: errorToExceptionHandler(2, 'pg_query(): Que...', '/data/www/<...>...', 222, Array)
#1 <...>web/include/db/postgres.inc.php(222): pg_query(Resource id #1, 'INSERT INTO ser...')
#2 <...>web/include/functions_images.inc.php(633): serendipity_db_query('INSERT INTO ser...')
#3 <...>web/include/functions_images.inc.php(1631): serendipity_insertImageInDatabase('header1.pngt134...', '') 
#4 <...>web/include/functions_images.inc.php(3697): serendipity_displayImageList(1, 2, true, NULL, false, NULL, Array)
#5 <...>web/include/admin/images.inc.php(424): showMediaLibrary(true)
#6 <...>web/serendipity_admin.php(109): include('/data/w in <...>web/include/db/postgres.inc.php on line 222.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.



Fatal error:  Uncaught ErrorException: Fatal Error: Uncaught ErrorException: Warning: pg_query(): Query failed: ERROR:  value too long for type character varying(5) in <...>web/include/db/po
Stack trace:
#0 [internal function]: errorToExceptionHandler(2, 'pg_query(): Que...', '/data/www/<...>...', 222, Array)
#1 <...>web/include/db/postgres.inc.php(222): pg_query(Resource id #1, 'INSERT INTO ser...')
#2 <...>web/include/functions_images.inc.php(633): serendipity_db_query('INSERT INTO ser...')
#3 <...>web/include/functions_images.inc.php(1631): serendipity_insertImageInDatabase('header1.pngt134...', '') 
#4 <...>web/include/functions_images.inc.php(3697): serendipity_displayImageList(1, 2, true, NULL, false, NULL, Array)
#5 <...>web/include/admin/images.inc.php(424): showMediaLibrary(true)
#6 <...>web/serend in <...>web/include/db/postgres.inc.php on line 222

This is not the case for every picture, but for many (I didn’t found a pattern).

Putting $serendipity['production'] = 'debug' in the config does not help, since then no error is shown at all.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm that the installation where the error occurs has multiple files with weird file extensions.

Examples:

  • [...].serendipityThumb.jpgresize4202C420
  • [...].jpgw300
  • header1.pngt1348323194

Since I host this installation for someone else I can’t reconstruct how and when they appeared.

Now I wonder where the file comes from in the first place, why it has this strange suffix, and why it’s added to the db when we’re just trying to list images?!?

At least figured out this part: I manually entered test.jpg1234 in the Save the file as input field while testing uploading an image. 😊

There don’t seem to be any checks on allowed extensions when uploading (which is okay, I guess). The file is uploaded correctly.

But then when trying to add the image to the DB, an error occurs. I guess the MIME type check correctly identifies the file as an image, regardless of the file extension.

The same thing happens when opening the media library: The routine I quoted above looks for files/images that are missing from the DB and tries to add them -> same error.

Thumbnail creation fails for such oddly named images, too.

In the original issue, there seems to be a file called header1.pngt134, and this is causing the error.

So, to sum it up: It’s not a problem with PostgreSQL (IMHO), but with how S9y handles odd file extension for images and MIME type detection.