-
Notifications
You must be signed in to change notification settings - Fork 268
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
If PHP installation is missing PostgreSQL support, the error message is not clear #875
Comments
Yes that makes sense, I'll look into it |
@wesyah234 I'll need you to provide a bit more context on that one. In particular, what do you mean exactly by server was missing PostgreSQL support, and what code did you run to get this -24 error message ? I tried to reproduce this on my dev box, by disabling the pgsql extension and trying to connect. $db = NewADOConnection('pgsql');
$db->debug=true;
$res = $db->connect($host, $user, $password, $database);
var_dump($res); // false
echo "{$db->ErrorMsg()} ({$db->ErrorNo()})\n"; // Database connection failed (-1) If you use exceptions, the connect() statement will throw
If not, with debug mode ADOdb prints
Considering the error's severity, maybe it would make sense to display the error also when debug mode is false. But in any case, connect() returns false - are you not checking that in your code ? You should. If you continue anyway after the failed connect statement and try to execute a query, PHP chokes with
Which IMO makes the problem quite obvious. With regards to the |
@wesyah234 any feedback ? |
Yes, sorry, I was putting together some tests. Here are my comments so far: I'm not using exceptions (as the code is pretty old and was written before php had exception support), so as you said, I would not have seen the "missing extension" message unless I turned on debug mode. And I agree with you, it would be great to have that message emitted somehow even without debug on. I am checking the connect return value, and then going after the db error number and error message, which are "-1" and "database connection failed" the first time, but then my code automatically tries a few more times, and repeated connection attempts then emit the -24 error code, so that is a bit weird that it changes... I might consider switching over to exception handling... In the meantime, for code not using exceptions, would you consider:
Thanks for the quick and detailed response! |
I agree that it's weird, we should have consistent behavior. Could you provide a code snippets to reproduce what you do in the tries a few more times bit, leading to the error number changing from -1 to -24 ? Because when I retry the connect(), I still get -1... $res = $db->connect($host, $user, $password, $database);
echo "{$db->ErrorMsg()} ({$db->ErrorNo()})\n"; // Database connection failed (-1)
$res = $db->connect($host, $user, $password, $database);
echo "{$db->ErrorMsg()} ({$db->ErrorNo()})\n"; // Database connection failed (-1) <- not -24
Yes, definitely. In fact, I think it even makes sense to just die() in this case, as clearly the code cannot continue.
That might be a bit complicated to implement, need to check. |
Hi on a fresh postgresql 13 nginx and php 8 on a redhat 8 i got the same issue when trying to installing a mantis the -24 error |
As there has been no additional feedback or discussion on this i'm closing this as ''wontfix'' |
We moved code to a new server, and the PHP on that server was missing PostgreSQL support. The error number we received was -24 and the error message was also -24. Is there anything else we could be doing to make troubleshooting more efficient? We didn't immediately think "oh, the PostgreSQL support is missing", rather we were looking at the database, the firewall, etc wondering why it would not connect.
The text was updated successfully, but these errors were encountered: