Moodle
  1. Moodle
  2. MDL-26290

MDL-25910 still not okay, mysqli_connect rquires port to be integer

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Installation
    • Labels:
      None
    • Environment:
    • Database:
      MySQL
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      16377

      Description

      Continuing on MDL-25910... I've upgraded to the latest $release = '2.0.1+ (Build: 20110204)';
      After upgrade, I modified my config.php to this:

      $CFG->dbtype = 'mysqli';
      $CFG->dbhost = 'localhost';
      $CFG->dbname = 'moodle_openwide';
      $CFG->dbuser = 'moodle_openwide';
      $CFG->dbpass = pass;
      $CFG->prefix = 'mdl_';
      $CFG->dblibrary = 'native'; // 'native' only at the moment
      $CFG->dboptions = array(
      'dbpersist' => false,
      'dbsocket' => '/web/mysql/mysql.sock',
      'dbport' => '',
      );

      Based on the comments in config_dist.php this should work. But it is not. I got the following error in php log:

      [06-Feb-2011 18:42:24] PHP Warning: mysqli::mysqli() expects parameter 5 to be long, string given in /web/www/openwide-moodle/lib/dml/mysqli_native_moodle_
      database.php on line 281
      [06-Feb-2011 18:42:24] PHP Warning: mysqli::set_charset() [<a href='mysqli.set-charset'>mysqli.set-charset</a>]: Couldn't fetch mysqli in /web/www/
      openwide-moodle/lib/dml/mysqli_native_moodle_database.php on line 291
      [06-Feb-2011 18:42:24] PHP Warning: mysqli_native_moodle_database::get_server_info() [<a href='mysqli-native-moodle-database.get-server-info'>mysqli-native-
      moodle-database.get-server-info</a>]: Couldn't fetch mysqli in /web/www/openwide-moodle/lib/dml/mysqli_native_moodle_database.php on line 331
      [06-Feb-2011 18:42:24] PHP Warning: mysqli_native_moodle_database::get_server_info() [<a href='mysqli-native-moodle-database.get-server-info'>mysqli-native-
      moodle-database.get-server-info</a>]: Couldn't fetch mysqli in /web/www/openwide-moodle/lib/dml/mysqli_native_moodle_database.php on line 331
      [06-Feb-2011 18:42:24] PHP Warning: mysqli::query() [<a href='mysqli.query'>mysqli.query</a>]: Couldn't fetch mysqli in /web/www/openwide-moodle/lib/dml/
      mysqli_native_moodle_database.php on line 774
      [06-Feb-2011 18:42:24] PHP Fatal error: Call to a member function fetch_assoc() on a non-object in /web/www/openwide-moodle/lib/dml/mysqli_native_moodle_
      database.php on line 779

      it's clear, that mysqli_native_moodle_database.php on line 281 there is a bug. I could resolve it by doing the change in the attached picture. Nevertheless the (int) conversion some lines above the mysqli_connect, the function call still not working.
      It seems, ini_get retrieves a string, and this is the problem.

        Activity

        Hide
        Éliás Tamás added a comment -

        Also it is an interesting question, if "/" checking in socket would work under windows. I don't use mysql under Windows OS, but I may imagine that named pipes not conatins "/" but "\". If this is the case, moodle + windows + mysql with named pipes is not a working combination.

        Show
        Éliás Tamás added a comment - Also it is an interesting question, if "/" checking in socket would work under windows. I don't use mysql under Windows OS, but I may imagine that named pipes not conatins "/" but "\". If this is the case, moodle + windows + mysql with named pipes is not a working combination.
        Hide
        Petr Škoda added a comment -

        It looks like your PHP.ini does not include default port, try to default port to your config.php (or any random number).

        I am going to add some workaround for this case.

        Show
        Petr Škoda added a comment - It looks like your PHP.ini does not include default port, try to default port to your config.php (or any random number). I am going to add some workaround for this case.
        Hide
        Petr Škoda added a comment -

        Should be fixed in the next weekly build, thanks for the report.

        Petr

        Show
        Petr Škoda added a comment - Should be fixed in the next weekly build, thanks for the report. Petr
        Hide
        Éliás Tamás added a comment -

        Yeah, if you look at the screenshot I've uploaded, I did that. Anyway, it is common misconception that get_ini always returns values. So there sholuld bealways an "else way" .
        Any opinion about the named pipes?
        I hope that the next moodle update will go on without problems. (It will be somewhen in March.)

        Show
        Éliás Tamás added a comment - Yeah, if you look at the screenshot I've uploaded, I did that. Anyway, it is common misconception that get_ini always returns values. So there sholuld bealways an "else way" . Any opinion about the named pipes? I hope that the next moodle update will go on without problems. (It will be somewhen in March.)
        Hide
        Éliás Tamás added a comment -

        It is also a common misconception, that ini_get is even enabled on the server. But I don't want to make you nightmares, I turned on ini_get.

        Show
        Éliás Tamás added a comment - It is also a common misconception, that ini_get is even enabled on the server. But I don't want to make you nightmares, I turned on ini_get.
        Hide
        Éliás Tamás added a comment -

        Hm. Well, my feelings about socket path under windows seems to be right: http://en.wikipedia.org/wiki/Named_pipe

        Some lines below the mysqli connect I can see, that you are looking for "/" in the socket name. It should be extended with searching for "\" if we are running under windows.

        Show
        Éliás Tamás added a comment - Hm. Well, my feelings about socket path under windows seems to be right: http://en.wikipedia.org/wiki/Named_pipe Some lines below the mysqli connect I can see, that you are looking for "/" in the socket name. It should be extended with searching for "\" if we are running under windows.
        Hide
        Éliás Tamás added a comment -

        Now I'm certain. Mysql has support for named pipes under Windows: http://dev.mysql.com/doc/refman/5.1/en/windows-select-server.html

        Show
        Éliás Tamás added a comment - Now I'm certain. Mysql has support for named pipes under Windows: http://dev.mysql.com/doc/refman/5.1/en/windows-select-server.html
        Hide
        Petr Škoda added a comment -

        Hehe, Moodle is not going to run on servers that disable random PHP functions.
        Anyway I have added the test for \, thanks a lot for the info and testing!!

        Petr

        Show
        Petr Škoda added a comment - Hehe, Moodle is not going to run on servers that disable random PHP functions. Anyway I have added the test for \, thanks a lot for the info and testing!! Petr
        Hide
        Helen Foster added a comment -

        Éliás, thanks for your report and Petr, thanks for fixing.

        Show
        Helen Foster added a comment - Éliás, thanks for your report and Petr, thanks for fixing.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: