Moodle
  1. Moodle
  2. MDL-25532

mysqli: optional dbport is ignored

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Component/s: Database SQL/XMLDB
    • Labels:
    • Environment:
      mysql 5.0 running on alternative port 3307
    • Database:
      MySQL
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      1579

      Description

      To run mysql under different port than default port 3306 we have the dboptions-array in config.php.
      But dboptions['dbport'] is ignored when creating the mysqli connection.

      I changed line 265 in lib/dml/mysqli_native_moodle_database.php
      from

      $this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

      to

      $this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dboptions['dbport']);

      to solve this problem

        Activity

        Hide
        Petr Škoda added a comment -

        reassigning

        Show
        Petr Škoda added a comment - reassigning
        Hide
        Aparup Banerjee added a comment - - edited

        hm from grepping the dbport option only seems supported in the oracle and postgres drivers.. (also the db option didn't work on mysql)

        ./lib/dml/pgsql_native_moodle_database.php:146: } else if (empty($this->dboptions['dbport'])) {
        ./lib/dml/pgsql_native_moodle_database.php:149: $port = "port ='".$this->dboptions['dbport']."'";
        ./lib/dml/oci_native_moodle_database.php:177: if (empty($this->dboptions['dbport'])) {
        ./lib/dml/oci_native_moodle_database.php:178: $this->dboptions['dbport'] = 1521;
        ./lib/dml/oci_native_moodle_database.php:180: $dbstring = '//'.$this->dbhost.':'.$this->dboptions['dbport'].'/'.$this->dbname;
        ./config-dist.php:56: 'dbport' => '', // the TCP port number to use when connecting

        i'll add 'dbport' to the mysql driver and make a subtask for mssql drivers

        Show
        Aparup Banerjee added a comment - - edited hm from grepping the dbport option only seems supported in the oracle and postgres drivers.. (also the db option didn't work on mysql) ./lib/dml/pgsql_native_moodle_database.php:146: } else if (empty($this->dboptions ['dbport'] )) { ./lib/dml/pgsql_native_moodle_database.php:149: $port = "port ='".$this->dboptions ['dbport'] ."'"; ./lib/dml/oci_native_moodle_database.php:177: if (empty($this->dboptions ['dbport'] )) { ./lib/dml/oci_native_moodle_database.php:178: $this->dboptions ['dbport'] = 1521; ./lib/dml/oci_native_moodle_database.php:180: $dbstring = '//'.$this->dbhost.':'.$this->dboptions ['dbport'] .'/'.$this->dbname; ./config-dist.php:56: 'dbport' => '', // the TCP port number to use when connecting i'll add 'dbport' to the mysql driver and make a subtask for mssql drivers
        Hide
        Aparup Banerjee added a comment -
        Show
        Aparup Banerjee added a comment - Petr, can you review https://github.com/nebgor/moodle/commit/ee414a02c9d4f43230650ead0ca3fd665a65a27b ..can't do pull requests yet
        Hide
        Petr Škoda added a comment -

        Please use single quotes for simple strings in PHP: "mysqli.default_port" --> 'mysqli.default_port'

        +1 for commit, thanks!

        Show
        Petr Škoda added a comment - Please use single quotes for simple strings in PHP: "mysqli.default_port" --> 'mysqli.default_port' +1 for commit, thanks!
        Hide
        Aparup Banerjee added a comment -

        ok, committed into CVS head.

        i was about to do the similar thing for create_database() but i always recall having to create the database first so i'm not to sure what this method really does in moodle.

        Show
        Aparup Banerjee added a comment - ok, committed into CVS head. i was about to do the similar thing for create_database() but i always recall having to create the database first so i'm not to sure what this method really does in moodle.
        Show
        Aparup Banerjee added a comment - i mean something like this https://github.com/nebgor/moodle/commit/bc620ac81ef5c6244de3e5c4617c4377835579e3
        Hide
        Petr Škoda added a comment -

        +1 for the commit

        Show
        Petr Škoda added a comment - +1 for the commit
        Hide
        Aparup Banerjee added a comment -

        thank, thats been committed via cvs into head.

        Show
        Aparup Banerjee added a comment - thank, thats been committed via cvs into head.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: