Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005765 [Quercus] minor always 07-03-14 00:25 11-13-14 12:58
Reporter luye66 View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.36
Summary 0005765: 4.0.39 subclass can not assign value to the parent protected field
Description Here is a sample
class A {
     private $_my;
     
     public function __construct(){
         
     }
     
     public function printMy(){
         print_r($this);
     }
 }

class B extends A{
     public function __construct() {
         parent::__construct();
         $this->_my = 'bac';
     }
 }

 $b = new B();
 $b->printMy();

and the output with Qurcus is
B Object ( [_my:protected] => [_my] => bac )

while in Apache is
B Object ( [_my:protected] => bac )

this caused functions in parent cannot use $this->_my to get the value where subcalss set..
Additional Information
Attached Files  index.php [^] (309 bytes) 07-03-14 00:25

- Relationships

- Notes
(0006458)
luye66
07-03-14 00:28

got a typo the "private" in class A should be "protected"
 
(0006459)
tobia
07-04-14 10:15

+1

This is breaking Doctrine in more places than I can count, and probably any other big library making extensive use of protected visibility.

I would have reported it with major severity.

Here is another example:

    abstract class AbstractClass {
        protected $_string;

        public function getString() {
            return $this->_string;
        }
    }

    class MyClass extends AbstractClass {
        public function __construct($s) {
            $this->_string = $s;
        }
    }

    $foo = new MyClass('Foo');

    var_dump($foo->_string);
    var_dump($foo->getString());

Output:

    string(3) "Foo"
    NULL
 
(0006575)
nam
11-13-14 12:58

php/091q

Fixed for 4.0.42.
 

- Issue History
Date Modified Username Field Change
07-03-14 00:25 luye66 New Issue
07-03-14 00:25 luye66 File Added: index.php
07-03-14 00:28 luye66 Note Added: 0006458
07-04-14 10:15 tobia Note Added: 0006459
11-13-14 12:57 nam Status new => assigned
11-13-14 12:57 nam Assigned To  => nam
11-13-14 12:58 nam Status assigned => closed
11-13-14 12:58 nam Note Added: 0006575
11-13-14 12:58 nam Resolution open => fixed


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
35 total queries executed.
29 unique queries executed.
Powered by Mantis Bugtracker