PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Configuration » Config » Bug #860

PEAR QA: improvement for get_class()-usage

Details

Submitted2004-02-26 13:15 UTC
Frompear-qa at lists dot php dot net
Assignedmansion
StatusClosed
PackageConfig
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2004-02-26 13:15 UTC] pear-qa at lists dot php dot net

Description:
------------
## from the PEAR QA team ##
## quality-assurance related ##

Please note that if you don't react to this issue within 4 weeks the PEAR QA-team will take care of it automatically. This is not "rude" but necessary for QA.
If this is a "false positive" and your package is not affected please apologize.

This package uses get_class()-calls without care for case-sensitivity of the returned classnames. In PHP 4.x the default for getclass() was that lowercase classnames were returned. However, due to extended DOM functionality, PHP 5.x returns classnames with correct upper-and-lowercase.

If you intend to run your package under both PHP4 and PHP5 please consider using case-independent comparisons or apply case-fixes.

Found in:
FILE: '/cvs/php/pear/Config/Config.php' :
/cvs/php/pear/Config/Config.php(161): if (is_object($rootContainer) && get_class($rootContainer) == 'config_container') {

Reproduce code:
---------------
Reproduceable code:

Affected are constructs like:

if (get_class($foo) == 'foo') {
...
}

Possible solutions for correct class-checks:

strtolower(get_class($foo)) == 'foo'
is_a($foo, 'foo')
!strcasecmp(get_class($foo), 'foo')

[2004-02-26 13:17 UTC] neufeind at php dot net

Also found in:

FILE: '/cvs/php/pear/Config/Config/Container.php' :
/cvs/php/pear/Config/Config/Container.php(127): if (get_class($target) != 'config_container') {
/cvs/php/pear/Config/Config/Container.php(696): if (in_array('writedatasrc', get_class_methods($className))) {

[2004-06-04 09:39 UTC] bmansion at mamasam dot com

This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pear.php.net.

In case this was a pear.php.net website problem, the change will show
up on the website in short time.

Thank you for the report, and for helping us make PEAR better.

[2004-06-09 00:32 UTC] james_r at learningmedia dot co dot nz

Unfortunately your fix in Container.php v1.30 line 693 (line 696 in v1.31) solved the problem for php5 but breaks php4.

rather than:
if (in_array('writeDatasrc', get_class_methods($className))) {

try:
if (in_array('writedatasrc', strtolower(get_class_methods($className)))) {

[Which is the approach used on line 124 v1.30]

Thanks
James Robertson

[2004-06-09 04:29 UTC] james_r at learningmedia dot co dot nz

Please ingnore earlier suggested fix. This will [of course!] not work as get_class_methods() returns an array.

[I am very embarrassed!]