Moodle
  1. Moodle
  2. MDL-44862

Postgres dbport is discarded when dbsocket is used, it should not

    Details

      Description

      It seems that current connection in the postgresql driver is unable to handle both dbsocket and dbport at the same time.

      And this is needed if you run a postgres instance, accepting socket connections in an non-standard port, because the socket file is named, always:

      dbsocket/.s.PGSQL.dbport

      So it works perfectly if using the standard 5432 port, because php find the file, but not if the port is different, because we don't pass the " port=5433" to the connection when using dbsockets.

      I discovered this while creating different postgresql instances to run by CI servers. There I performed multiple "initdb" executions, every one using a different port 5432, 5433... and in every case, the socket became named as specified above.

      I know that I could be using -h 127.0.0.1 -p 5433, but in this case I prefer to keep any "host" connection rejected and only enable sockets.

      I think this is easy to fix and will allow those non-standard port sites using sockets to work without a problem, straight from config.php, without having to be forced to use host access.

      Note this is not a problem with mysql because we pass the socket file to the connection. Problem in postgresql is that we pass the directory and the port and php / postgres uses both to determine the socket file. I know it's idiot to mix sockets and ports but php / postgres does it for naming purposes and I've not been able to find a way to specify the socket file, it's always directory and port (initdb, psql, php's->connect()...).

      Ciao

        Gliffy Diagrams

          Activity

          Hide
          Petr Skoda added a comment -

          Confirming, the patch finally fixes the sockets when using non-standard ports in my Macports PostgreSQLs, yay!

          Show
          Petr Skoda added a comment - Confirming, the patch finally fixes the sockets when using non-standard ports in my Macports PostgreSQLs, yay!
          Hide
          Petr Skoda added a comment - - edited

          The only problem is if somebody was running PG with sockets and included invalid port in moodle config.php, after this change their connection would stop working...

          Show
          Petr Skoda added a comment - - edited The only problem is if somebody was running PG with sockets and included invalid port in moodle config.php, after this change their connection would stop working...
          Hide
          CiBoT added a comment -
          Show
          CiBoT added a comment - Results for MDL-44862 Remote repository: https://github.com/skodak/moodle.git Remote branch W14_ MDL-44862 _m25_pgsocket to be integrated into upstream MOODLE_25_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2521 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2521/artifact/work/smurf.html Remote branch W14_ MDL-44862 _m26_pgsocket to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2522 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2522/artifact/work/smurf.html Remote branch W14_ MDL-44862 _m27_pgsocket to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2523 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2523/artifact/work/smurf.html
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Sending to integration, the fix seems correct, I've tested it here to run phpunit into another pgsql instance via socket. Worked perfectly.

          Show
          Eloy Lafuente (stronk7) added a comment - Sending to integration, the fix seems correct, I've tested it here to run phpunit into another pgsql instance via socket. Worked perfectly.
          Hide
          CiBoT added a comment -

          Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

          Show
          CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          Hi, just detected that we need to tweak a bit both the database auth and database enrol plugins (both using ADOdb) unit tests to add support for this new socket & non-standard port. Luckily, ADOdb supports it by using the format "socket:port", so I'd suggest to add this commit to the 3 branches (it should not affect "normal" sites at all, only those using socket and port).

          I've run them here and with the commit applied I get a complete pass.

          Commit: https://github.com/stronk7/moodle/commit/b174896111c1d089e0e0e356ca93ec720fbce046

          Feel free to add it to your branches, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - - edited Hi, just detected that we need to tweak a bit both the database auth and database enrol plugins (both using ADOdb) unit tests to add support for this new socket & non-standard port. Luckily, ADOdb supports it by using the format "socket:port", so I'd suggest to add this commit to the 3 branches (it should not affect "normal" sites at all, only those using socket and port). I've run them here and with the commit applied I get a complete pass. Commit: https://github.com/stronk7/moodle/commit/b174896111c1d089e0e0e356ca93ec720fbce046 Feel free to add it to your branches, ciao
          Hide
          Petr Skoda added a comment -

          cherry picked, thanks!

          Show
          Petr Skoda added a comment - cherry picked, thanks!
          Hide
          Marina Glancy added a comment -

          Eloy, Petr, can you please add testing instructions for changes in enrol and auth

          Show
          Marina Glancy added a comment - Eloy, Petr, can you please add testing instructions for changes in enrol and auth
          Hide
          Marina Glancy added a comment -

          Thanks Petr and Eloy, integrated in 2.5, 2.6 and master

          Show
          Marina Glancy added a comment - Thanks Petr and Eloy, integrated in 2.5, 2.6 and master
          Hide
          Andrew Nicols added a comment -

          All works as described. Thanks Petr.
          Passing!

          Show
          Andrew Nicols added a comment - All works as described. Thanks Petr. Passing!
          Hide
          Marina Glancy added a comment -

          Thanks for your hard work. Your code is now part of Moodle.

          Show
          Marina Glancy added a comment - Thanks for your hard work. Your code is now part of Moodle.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: