Moodle
  1. Moodle
  2. MDL-14628

Logging database error to the Apache error log

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.5, 1.9, 2.0
    • Fix Version/s: 1.8.6, 1.9.1, 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      PostgreSQL, Oracle
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      37029

      Description

      Here's a very small patch which helped greatly while I was debugging Oracle connection problems for a client.

      It outputs the DB error message to the Apache error log.

      Does it make sense to apply it to 1.8, 1.9 and HEAD ?

        Activity

        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi,

        just guessing if, from a Moodle perspective, it has more sense to use debugging($error, DEBUG_MINIMAL) that will control web output or forwarding it to a nice trigger_error() call.

        Good idea, anyway!

        Show
        Eloy Lafuente (stronk7) added a comment - Hi, just guessing if, from a Moodle perspective, it has more sense to use debugging($error, DEBUG_MINIMAL) that will control web output or forwarding it to a nice trigger_error() call. Good idea, anyway!
        Hide
        Francois Marier added a comment -

        Well, in this case, error reporting is disabled just above so using the "debugging()" function has no effect at all. This is what appears just before the connection to the DB is attempted:

        error_reporting(0); // Hide errors

        I can see why errors are temporarily disabled. We don't want to display those on the site itself (there may be security implications too), but I would argue that the error message needs to show up in the logs to allow admins to debug the database connection.

        Show
        Francois Marier added a comment - Well, in this case, error reporting is disabled just above so using the "debugging()" function has no effect at all. This is what appears just before the connection to the DB is attempted: error_reporting(0); // Hide errors I can see why errors are temporarily disabled. We don't want to display those on the site itself (there may be security implications too), but I would argue that the error message needs to show up in the logs to allow admins to debug the database connection.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        grrr. agree 100%. I didn't see it. +1 for it. I'd add this bug number as a comment to have it present when implementing new dmllib stuff for 2.0.

        Thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - grrr. agree 100%. I didn't see it. +1 for it. I'd add this bug number as a comment to have it present when implementing new dmllib stuff for 2.0. Thanks!
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Ah, was assigned to me, hehe. Feel free to commit it yourself (although you'll have to wait until Wednesday - today is review day). It's highly possible that I won't be connected next days.

        TIA!

        Show
        Eloy Lafuente (stronk7) added a comment - Ah, was assigned to me, hehe. Feel free to commit it yourself (although you'll have to wait until Wednesday - today is review day). It's highly possible that I won't be connected next days. TIA!
        Hide
        Petr Škoda added a comment -

        reviewed, closing

        Show
        Petr Škoda added a comment - reviewed, closing

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: