-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: pg_escape_string() in serendipity_db_escape_string() works again #855
base: master
Are you sure you want to change the base?
Conversation
Great :)
It would be nice to support older PHP versions. It makes upgrades for old blogs a lot easier, and so far we were still compatible I think. |
Checked after the commit. Correction: PHP 8.1 is still supported by security updates. My own agenda is to move into PHP 8.2. When stable status reached, then bump into 8.3 to see what breaks. |
include/db/postgres.inc.php
Outdated
if (PHP_MAJOR_VERSION < 8 || (PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION < 1)) | ||
# Last supported version is PHP 8.0 | ||
return pg_escape_string($string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this instead (untested)?
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
# Versions before 8.1 give the connection by default
return pg_escape_string($string);
}
That's how the core would usually express that if, and I think it's a bit clearer, isn't it?
Hi :) I did not see the progress here, sorry. Thank you for changing it to But now there are some additional commits in this branch that probably ended up here by accident, like 5c75b73. Could you separate that, so we can merge this PR first? You could either rebase the branch to pick only the commits we need here or just open a new PR, whatever is easier. The other commits could then in a PHP 8.2 fixes PR. Those I could actually test, and then we can pinpoint better if something broke. |
Docs: https://www.php.net/manual/en/function.pg-escape-string.php
In PHP 8.1+ there is no default connection. A mandatory connection must be given as a parameter. This PR restores PostgreSQL support for S9y.
Not sure if PHP <8.1 must be supported. If yes, PHP_MAJOR_VERSION and PHP_MINOR_VERSION could be checked to determine which interface of
pg_escape_string()
needs to be used.