From:             beat at joomlapolis dot com
Operating system: osX 10.6.8
PHP version:      5.3.14
Package:          Class/Object related
Bug Type:         Bug
Bug description:callback of private function in parent class works but static 
vars are lost

Description:
------------
In the case below where the callback function is private, its static local

variable is lost during call of inherited class,

t if the callback function is private as below, it still gets called, but
the 
local static variable is null instead of initialized like in PHP 5.2, where
it 
works.

Also if you make the callback function "protected" instead of "private",
the 
result is correct, as expected.

This is reproducible at least on PHP 5.3.8.

Test script:
---------------
class ok {
        public function t() {
                $this->replacer( '*' );
                return preg_replace_callback( '/(t)/', array( $this, 
'replacer'), 'this
is a simple test' );
        }
        private function replacer( $input ) {
                static $cache                                   =       '-';
                if ( ! is_array( $input ) ) {
                        $cache                                          =       
$input;
                } else {
                        return $cache . $input[1] . $cache;
                }
        }
}
class buggyphp extends ok {}

class buggyphptoo extends ok {
        public function t() {
                return parent::t();
        }
}

$buggy = new buggyphp();
echo 'Result buggyphp: ' . $buggy->t();
echo "\n";
$buggy = new buggyphptoo();
echo 'Result buggyphptoo: ' . $buggy->t();
echo "\n";
$a = new ok();
echo 'Result ok: ' . $a->t();
exit();


Expected result:
----------------
Result buggyphp: *t*his is a simple *t*es*t*
Result buggyphptoo: *t*his is a simple *t*es*t*
Result ok: *t*his is a simple *t*es*t*

Actual result:
--------------
Result buggyphp: -t-his is a simple -t-es-t-
Result buggyphptoo: -t-his is a simple -t-es-t-
Result ok: *t*his is a simple *t*es*t*

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62547&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62547&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62547&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62547&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62547&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62547&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62547&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62547&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62547&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62547&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62547&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62547&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62547&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62547&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62547&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62547&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62547&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62547&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62547&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62547&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62547&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62547&r=mysqlcfg

Reply via email to