Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-10057

More informative reporting of errors when database connection fails for Firebird and PostgreSQL.

    Details

      Description

      An example for postgres:

      1. When pgsql extension is missing, @pg_connect would silently abort execution. Check for pg_connect existence before calling it, same with pg_pconnect.

      2. When connection fails, the error reported by php is discarded. User is shown the failure message without the reason for failure, making debugging difficult. Collect the error (if any) via a temporarily installed error handler, and display it if connection failed.

      With the exception of mssqlnative, no dbal checks for the presence of its extension's functions before calling them. This manifests in white pages when people, for example, move from one host to another and the available mysql extension changes from mysqli to mysql.

        Issue Links

          Activity

          Hide
          naderman Nils Adermann added a comment -

          I agree that we should find some better mechanism than @. We could do what it does internally (I think) and just outputbuffer the call and then log that result later. Not sure if that's better or wose than a separate error_handler.

          Show
          naderman Nils Adermann added a comment - I agree that we should find some better mechanism than @. We could do what it does internally (I think) and just outputbuffer the call and then log that result later. Not sure if that's better or wose than a separate error_handler.
          Hide
          Oleg Oleg [X] (Inactive) added a comment -

          (22:21:26) nn-: feedback on http://tracker.phpbb.com/browse/PHPBB3-10057 would be nice
          (22:21:41) nn-: i expect the error collection to be useful for email debugging as well
          (22:23:28) naderman: nn-: commented
          (22:24:15) AZora: Well I think the include() methodology hides too many errors in general
          (22:24:45) AZora: if we want to hide the error messages that PHP generates, that's easily done through the php.ini
          (22:24:58) AZora: errors regarding included files that is
          (22:25:26) AZora: if we switch to require_once() that entire problem, and the need for this code change, would go away as well.
          (22:25:52) naderman: AZora: that's not what this is about
          (22:26:03) naderman: it's about using @ to suppress errors on function calls
          (22:27:33) AZora: i realize that the idea is to display information about repressed errors :/
          (22:30:36) AZora: the code is elegant, but I might suggest something like: function pg_pconnect does not exist, please confirm mod_postgres is installed
          (22:30:52) AZora: that way your 'typical user' can figure out issue
          (22:31:21) nn-1: naderman: i cannot imagine that output buffering would be more elegant
          (22:31:32) nn-1: and i wanted to use the word elegant before AZora did :P
          (22:31:43) nn-1: error handler receives error message separately from file/line info
          (22:31:55) nn-1: we don't want to expose the latter unconditionally
          (22:32:56) naderman: nn-: well error_handler is rather odd too ;-)
          (22:33:03) nn-1: naderman: why?
          (22:33:17) naderman: hmm actually, ours is, not a generally true statement
          (22:33:18) naderman: :D
          (22:33:28) naderman: so yeah I guess error handler is fine with me
          

          Show
          Oleg Oleg [X] (Inactive) added a comment - (22:21:26) nn-: feedback on http://tracker.phpbb.com/browse/PHPBB3-10057 would be nice (22:21:41) nn-: i expect the error collection to be useful for email debugging as well (22:23:28) naderman: nn-: commented (22:24:15) AZora: Well I think the include() methodology hides too many errors in general (22:24:45) AZora: if we want to hide the error messages that PHP generates, that's easily done through the php.ini (22:24:58) AZora: errors regarding included files that is (22:25:26) AZora: if we switch to require_once() that entire problem, and the need for this code change, would go away as well. (22:25:52) naderman: AZora: that's not what this is about (22:26:03) naderman: it's about using @ to suppress errors on function calls (22:27:33) AZora: i realize that the idea is to display information about repressed errors :/ (22:30:36) AZora: the code is elegant, but I might suggest something like: function pg_pconnect does not exist, please confirm mod_postgres is installed (22:30:52) AZora: that way your 'typical user' can figure out issue (22:31:21) nn-1: naderman: i cannot imagine that output buffering would be more elegant (22:31:32) nn-1: and i wanted to use the word elegant before AZora did :P (22:31:43) nn-1: error handler receives error message separately from file/line info (22:31:55) nn-1: we don't want to expose the latter unconditionally (22:32:56) naderman: nn-: well error_handler is rather odd too ;-) (22:33:03) nn-1: naderman: why? (22:33:17) naderman: hmm actually, ours is, not a generally true statement (22:33:18) naderman: :D (22:33:28) naderman: so yeah I guess error handler is fine with me
          Hide
          Oleg Oleg [X] (Inactive) added a comment -

          Note to self to add language strings for missing function messages.

          Show
          Oleg Oleg [X] (Inactive) added a comment - Note to self to add language strings for missing function messages.
          Hide
          Paul Paul Sohier added a comment -

          Should this not be fixed for mysql etc as well?

          Show
          Paul Paul Sohier added a comment - Should this not be fixed for mysql etc as well?
          Hide
          Oleg Oleg [X] (Inactive) added a comment - - edited

          This ticket turned out to be a lot more popular than I expected. #phpbb-dev requested the changes to postgres/firebird applied to other dbmses.

          Show
          Oleg Oleg [X] (Inactive) added a comment - - edited This ticket turned out to be a lot more popular than I expected. #phpbb-dev requested the changes to postgres/firebird applied to other dbmses.

            People

            • Assignee:
              Oleg Oleg [X] (Inactive)
              Reporter:
              Oleg Oleg [X] (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development