Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-34309

Fix core_adodb_testcase::test_read_table for postgresql sockets connection

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide

      1/ break your pg setup in config.php by giving invalid socket
      2/ run unittests

      Show
      1/ break your pg setup in config.php by giving invalid socket 2/ run unittests
    • Workaround:
      Hide

      Workaround is to fix broken legacy postgresql socket value in config.php.

      Show
      Workaround is to fix broken legacy postgresql socket value in config.php.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE

      Description

      The core_adodb_testcase::test_read_table attempts to configure the external database enrolment plugin with the database details from $CFG->db* settings. However, it fails to replicate the settings properly when Moodle is configured with $CFG->dbhost = 'localhost' and $CFG->dboptions['dbsocket'] = 1 with postgres. This is because it sets enrol_database.dbhost to '1' rather than blank. To properly mirror the settings, it should leave dbhost blank if sockets are on and the dbhost doesn't contain a slash (see code in pgsql_native_moodle_database::connect()).

      Here is the failed test output:

      $ phpunit core_adodb_testcase enrol/database/tests/adodb_test.php
      PHPUnit 3.6.11 by Sebastian Bergmann.
       
      Configuration read from /git/hosted/phpunit.xml
       
      E
       
      Time: 3 seconds, Memory: 51.25Mb
       
      There was 1 error:
       
      1) core_adodb_testcase::test_read_table
      pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Invalid argument
      	Is the server running on host "1" (0.0.0.1) and accepting
      	TCP/IP connections on port 5432?

      I've linked a patch which fixes this.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/12