php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46494 no access to error when extended class
Submitted: 2008-11-05 10:58 UTC Modified: 2008-11-05 21:25 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Contact at LinuxIntro dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.2.6 OS: Fedora
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 2 = ?
Subscribe to this entry?

 
 [2008-11-05 10:58 UTC] Contact at LinuxIntro dot com
Description:
------------
I know that this is a 'no no', but i feel that the bug here was not bogus:
http://bugs.php.net/bug.php?id=37711

I disagree with the response. $this is used in the current class, whereas parent:: is used to access properties and methods of the parent class. errno and error are properties of the parent class, NOT of $this class. Using $this to access the property of parent:: is not inheritance, it is more closely related to symbiosis or polymorphism, or something. And besides, how is parent:: automatically giving $this new properties called errno and error? Shouldn't that only be done via a set/get type function? EX:

function GetErrno(){
    $this->errno=parent::errno;
}

function GetError(){
    $this->error=parent::error;
}

The fact that this is automatically available in the scope of $this is NOT inheritance, imho, it is a BUG.

Alex Grim


Reproduce code:
---------------
class dbMYSQL extends mysqli {
...
function __construct(
parent::__construct($args....);
echo parent::errno;
echo parent::error;
}
...
}



Expected result:
----------------
0
''

or some error and error message when error occurs

Actual result:
--------------
Fatal error: Undefined class constant 'errno'
Fatal error: Undefined class constant 'error'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-05 21:25 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

parent:: is for accessing the base implementation of a overwritten method, such a thing doesn't exist with properties.

Even if this would be a bug (what it isn't) it won't be a MySQLi issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 05:01:28 2024 UTC