|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33274 Class extended from MySQLi mangles members on calling parent method
Submitted: 2005-06-08 12:27 UTC Modified: 2005-06-09 16:17 UTC
From: flying dot mushroom at gmail dot com Assigned:
Status: Closed Package: MySQLi related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
 [2005-06-08 12:27 UTC] flying dot mushroom at gmail dot com
A class that extends mysqli, if passing its own members directly to the parent constructor, will have those members mangled after the call.

Assigning member values to local variables and then passing those to the parent solves the problem on for the user, but the above behaviour shouldn't happen...?

(Replacing the line "parent::__construct($this->p_host, $this->p_uname, $this->p_password);" with "parent::__construct($host, $username, $password);" produces the expected result.)

This same problem is reported on the comment by hans at lintoo dot dk on

Reproduce code:

class db_mysql extends mysqli
    private $p_host;
    private $p_uname = '';
    private $p_password = '';

    public function __construct($host, $username = '', $password = '')
        $this->p_host     = $host;
        $this->p_uname    = $username;
        $this->p_password = $password;

        parent::__construct($this->p_host, $this->p_uname, $this->p_password);

var_dump(new db_mysql('localhost', 'username', 'password'));

Expected result:
object(db_mysql)#1 (3) {
  string(9) "localhost"
  string(8) "username"
  string(8) "password"

Actual result:
object(db_mysql)#1 (3) {
  string(9) "localhost"
  string(8) "username"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-08 18:02 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-06-09 12:51 UTC] flying dot mushroom at gmail dot com
Yep; the CVS version (200506090830) fixes it, producing the expected result.
 [2005-06-09 16:17 UTC] flying dot mushroom at gmail dot com
Fixed in CVS
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 01:03:35 2021 UTC