Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-8978

Wrong parameters for mysql_pconnect in mysql DBAL Class

    Details

      Description

      The persistent connection mysql_pconnect is handed the same parameters as mysql_connect. The fourth parameter however is the parameter "new_link" which makes no sense for mysql_pconnect and furthermore does not exist as parameter for the PHP function.

      This is the function call:

      @mysql_pconnect($this->server, $this->user, $sqlpassword, $new_link)

      This is the function call for non-persistent calls:

      @mysql_connect($this->server, $this->user, $sqlpassword, $new_link)

      This is the function Synopsis for persistent calls:

      resource mysql_pconnect  ([ string $server = ini_get("mysql.default_host")  [, string $username = ini_get("mysql.default_user")  [, string $password = ini_get("mysql.default_password")  [, int $client_flags  ]]]] )

      This is the Synopsis for non-persistent calls:

      resource mysql_connect  ([ string $server = ini_get("mysql.default_host")  [, string $username = ini_get("mysql.default_user")  [, string $password = ini_get("mysql.default_password")  [, bool $new_link = false  [, int $client_flags = 0  ]]]]] )

      Please notice, that in the persistent case, there is no parameter bool $new_link = false, therefore the parameter will be interpreted as client_flag.

      Simple solution: Since a new connection does not make sense if using persistent connections anyways, the parameter should be ignored if a persistent connection is to be set up:
      Replace

      $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);


      with

        $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);

      This bug is not critical as phpBB does not use the implemented persistent connections at this time and therefore the parameter is used correctly in all cases of normal operation, it will however be an error if persistent connections are used in the future.

      This error does not exist in the mssql or postgres classes as the parameter definitions are different in this case.

        Attachments

          Activity

            People

            • Assignee:
              bantu Andreas Fischer
              Reporter:
              gn#36 gn#36
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: