#46761 [NEW]: get_class_vars includes protected variables depending on calling context

From: Date: Fri, 05 Dec 2008 13:46:04 +0000
Subject: #46761 [NEW]: get_class_vars includes protected variables depending on calling context
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131627@lists.php.net to get a copy of this message
From: phpbug dot classvars at sub dot noloop dot net Operating system: Linux PHP version: 5.2.7 PHP Bug Type: Class/Object related Bug description: get_class_vars includes protected variables depending on calling context Description: ------------ PHP 5.2.7 seems to have introduced a regression in get_class_vars(); depending on the calling context protected variables may be included in the result. This looks very similar to bug 45862 (which was closed in August with a comment saying fix committed to CVS 5.2, 5.3 and HEAD). This build (built from source from today's release) produces "actual result": PHP 5.2.7 (cli) (built: Dec 5 2008 12:39:40) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies This build (built from source from 5.2.6 release) produces "expected result": PHP 5.2.6 (cli) (built: May 22 2008 10:18:33) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies Reproduce code: --------------- <?php abstract class Absclass { protected $v_protected; private $v_private; protected static function testIt($className) { var_dump(get_class_vars($className)); } } class Testclass extends Absclass { public $v_public_sub; public static function init() { self::testIt('Testclass'); } } $a = new Testclass(); Testclass::init(); var_dump(get_class_vars('Testclass')); Expected result: ---------------- array(1) { ["v_public_sub"]=> NULL } array(1) { ["v_public_sub"]=> NULL } Actual result: -------------- array(2) { ["v_public_sub"]=> NULL ["v_protected"]=> NULL } array(1) { ["v_public_sub"]=> NULL } -- Edit bug report at http://bugs.php.net/?id=46761&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46761&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46761&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46761&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46761&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46761&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46761&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46761&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46761&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46761&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46761&r=support Expected behavior: http://bugs.php.net/fix.php?id=46761&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46761&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46761&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46761&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46761&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46761&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46761&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46761&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46761&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46761&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46761&r=mysqlcfg

« previous php.bugs (#131627) next »