From: kinder at wxs dot nl
Operating system: Windows XP
PHP version: 5.0.0
PHP Bug Type: Class/Object related
Bug description: Setting or getting declared members won't work when extending mysqli
Description:
------------
I've posted this problem to the php.db mailinglist, as well as asked in
three different php-related irc-channels, in which no-one could explain
this behaviour. Although I haven't been able to reproduce this problem on
another machine (none available), I suspect it to be a bug.
-----
I'm running php5.0.0 with mysqli extention as a Apache2 module on a
Windows XP box. I've tested the database by querying it with mysqli
(procedural) and results are coming back just fine. This makes me believe
that the mysqli-extention is working properly.
Running this code (see 'reproduce code'), you would expect an output like
"xconstructorytest" however, I'm getting "xy" (the private member $somevar
isn't set and/or read). No reported errors or warnings.
Changing the line that says
class database_foobar extends mysqli
to
class database_foobar
gets me the expected result of "xconstructorytest". Somehow, making the
class an extention of mysqli, seems to interfere with calling the $somevar
member.
Reproduce code:
---------------
error_reporting(E_ALL);
class database_foobar extends mysqli
{
private $somevar;
function database_foobar()
{
$this->somevar = "constructor";
echo "x";
echo $this->somevar;
}
function test()
{
$this->somevar = "test";
echo "y";
echo $this->somevar;
}
}
$foo = new database_foobar();
$foo->test();
Expected result:
----------------
xconstructorytest
Actual result:
--------------
xy
--
Edit bug report at http://bugs.php.net/?id=29596&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29596&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29596&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29596&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29596&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29596&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29596&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29596&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29596&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29596&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29596&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29596&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29596&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29596&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29596&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29596&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29596&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29596&r=float