s9y / Serendipity

A PHP blog software
https://s9y.org
BSD 3-Clause "New" or "Revised" License
209 stars 88 forks source link

PostgreSQL: WITH OIDs no longer supported #774

Open titanofold opened 2 years ago

titanofold commented 2 years ago

My site is no longer loading with a recent upgrade for PostgreSQL.

WITH OIDs has actually been deprecated since 2005. There was a mailing list announcement from 2018 that has some details: https://www.postgresql.org/message-id/E1gPG3j-0003cy-03%40gemulon.postgresql.org

== ERROR-REPORT (DEBUGGING ENABLED) ==
== (When you copy this debug output to a forum or other places, make sure to remove your username/passwords, as they may be contained within function calls) ==

#0  errorToExceptionHandler(2, pg_query(): Query failed: ERROR:  tables declared WITH OIDS are not supported, /srv/www/serendipity/include/db/postgres.inc.php, 224)
#1  pg_query(Resource id #21, SET default_with_oids = true) called at [/srv/www/serendipity/include/db/postgres.inc.php:224]
#2  serendipity_db_query(SET default_with_oids = true, 1, both, , , , 1) called at [/srv/www/serendipity/include/db/postgres.inc.php:218]
#3  serendipity_db_query(SELECT name, value
                                        FROM serendipity_config
                                        WHERE authorid = 0) called at [/srv/www/serendipity/include/functions_config.inc.php:314]
#4  serendipity_load_configuration() called at [/srv/www/serendipity/serendipity_config.inc.php:339]
#5  include(/srv/www/serendipity/serendipity_config.inc.php) called at [/srv/www/serendipity/serendipity_admin.php:9]

Warning: pg_query(): Query failed: ERROR: tables declared WITH OIDS are not supported in /srv/www/serendipity/include/db/postgres.inc.php on line 224.

 == ERROR-REPORT (DEBUGGING ENABLED) == 

 == (When you copy this debug output to a forum or other places, make sure to remove your username/passwords, as they may be contained within function calls) == 

#0  errorToExceptionHandler(1, Uncaught ErrorException: Warning: pg_query(): Query failed: ERROR:  tables declared WITH OIDS are not supported in /srv/www/serendipity/include/db/postgres.inc.php:224
Stack trace:
#0 [internal function]: errorToExceptionHandler()
#1 /srv/www/serendipity/include/db/postgres.inc.php(224): pg_query()
#2 /srv/www/serendipity/include/db/postgres.inc.php(218): serendipity_db_query()
#3 /srv/www/serendipity/include/functions_config.inc.php(314): serendipity_db_query()
#4 /srv/www/serendipity/serendipity_config.inc.php(339): serendipity_load_configuration()
#5 /srv/www/serendipity/serendipity_admin.php(9): include('...')
#6 {main}
  thrown, /srv/www/serendipity/include/db/postgres.inc.php, 224) called at [/srv/www/serendipity/include/compat.inc.php:254]
#1  fatalErrorShutdownHandler()

Fatal Error: Uncaught ErrorException: Warning: pg_query(): Query failed: ERROR:  tables declared WITH OIDS are not supported in /srv/www/serendipity/include/db/postgres.inc.php:224
Stack trace:
#0 [internal function]: errorToExceptionHandler()
#1 /srv/www/serendipity/include/db/postgres.inc.php(224): pg_query()
#2 /srv/www/serendipity/include/db/postgres.inc.php(218): serendipity_db_query()
#3 /srv/www/serendipity/include/functions_config.inc.php(314): serendipity_db_query()
#4 /srv/www/serendipity/serendipity_config.inc.php(339): serendipity_load_configuration()
#5 /srv/www/serendipity/serendipity_admin.php(9): include('...')
#6 {main}
  thrown in /srv/www/serendipity/include/db/postgres.inc.php on line 224.
onli commented 2 years ago

@titanofold I can have a look at whether my test environment supports PostgreSQL, but am not sure how to fix this. Do you have a recommendation, ideally: Could you submit a Pull Request for this?

Zugschlus commented 1 year ago

Is there a workaround around this? I have been bitten when upgrading Serendipity almost two years after this issue stalled. How would I get my blog back up?

If it is only the test environment that is missing, I can provide a VM with Debian stable/testing/unstable (your choice), a PostgreSQL database, apache, PHP (what ever is part of the Debian you chose) and root.

onli commented 1 year ago

@Zugschlus Could you try a fix for me?

In include/db/postgres.inc.php, there is this code in line 218:

@serendipity_db_query('SET default_with_oids = true', true, 'both', false, false, false, true);

Does the blog work if you remove that line?

If I read the stacktrace correctly this is where the error is coming from, it's also the only place in the core where default_with_oids is set. Removing it could make everything work directly.

Zugschlus commented 1 year ago

I'm going to try that in the next few days. Since i have rolled back the machine to the last working state in the mean time, I need to build a reference box. Thanks for helping!