Edit report at https://bugs.php.net/bug.php?id=55801&edit=1

 ID:                 55801
 Updated by:         johan...@php.net
 Reported by:        mapi at pdepend dot org
 Summary:            Behavior of unserialize has changed
 Status:             Feedback
 Type:               Bug
 Package:            Variables related
 Operating System:   Linux (Fedora 15)
 PHP Version:        5.4.0beta1
 Block user comment: N
 Private report:     N

 New Comment:

Can you try reverting SVN revision r299770 and then run your test? - That's 
mostly a guess, though.

bug #36424
http://svn.php.net/viewvc/?view=revision&revision=299770


Previous Comments:
------------------------------------------------------------------------
[2011-09-28 16:29:50] mapi at pdepend dot org

It seems that this has something todo with the visibility of properties that 
should be serialized. If I do the following:

~ $ rm -rf ~/.pdepend
~ $ git clone https://github.com/pdepend/pdepend.git
~ $ cd pdepend
~ $ vim src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php +86
    -> Change from PROTECTED to PUBLIC
       protected $parentClassReference = null; -> public $parentClassReference 
= 
null;
~ $ vim src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php +132
    -> Change from PROTECTED to PUBLIC
       protected $nodes = array(); -> public $nodes = array();
~ $ php540 src/bin/pdepend.php --summary-xml=sum.xml 
src/main/php/PHP/Depend/Code/ASTArrayType.php
~ $ php540 src/bin/pdepend.php --summary-xml=sum.xml 
src/main/php/PHP/Depend/Code/ASTArrayType.php
...
Executing CyclomaticComplexity-Analyzer:

Fatal error: Call to a member function findChildrenOfType() on a non-object in 
/tmp/pdepend/src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php on line 
268

If I now revert the visibility of both properties from PUBLIC to PROTECTED, it 
works:

~ $ vim src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php +86
    -> Change from PUBLIC to PROTECTED
       public $parentClassReference = null; -> protected $parentClassReference 
= 
null;
~ $ vim src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php +132
    -> Change from PUBLIC to PROTECTED
       public $nodes = array(); -> protected $nodes = array();
~ $ php540 src/bin/pdepend.php --summary-xml=sum.xml 
src/main/php/PHP/Depend/Code/ASTArrayType.php

This means that a PUBLIC property that was serialized can be restored in a 
PROTECTED property while unserializing the object structure.

------------------------------------------------------------------------
[2011-09-28 15:20:33] mapi at pdepend dot org

Yes, here you can get the two serialized object structures:

http://manuel-pichler.de/stuff/5.3.ser
http://manuel-pichler.de/stuff/5.4.ser

And there is the difference:

5.3 -> *nodes";a:1:{i:0;r:18;}}}}}}}}}
5.4 -> *nodes";a:1:{i:0;r:36;}}}}}}}}}

It references something different.

------------------------------------------------------------------------
[2011-09-28 13:41:54] paj...@php.net

Any chance to get something that shows us the serialized data with 5.4 and 5.4 
so 
we can see how they differ?

Maybe upload the small possible code somewhere?

------------------------------------------------------------------------
[2011-09-28 13:30:46] mapi at pdepend dot org

Okay, I tried for several hours to create a reproducable outside of 
PHP_Depend's 
context, but I cannot reproduce this behavior :(

But at least I came up with a small code fragement that illustrates this 
behavior:

  <?php
  class Test {
      function method() {   
          $this->prop[$y]++;
      }
  }

which was translated into the following object graph:

 Statement
   Expression
     MemberPrimaryPrefix  <----------
       Variable                     |
       PropertyPostfix              |
         ArrayIndexExpression  [Same Instance]
           Identifier               |
           Variable                 |
     PostfixExpression              |
       MemberPrimaryPrefix ----------
         Variable
         PropertyPostfix
           ArrayIndexExpression
             Identifier
             Variable

And this second reference to MemberPrimaryPrefix is NULL after unserialization 
with PHP 5.4 and it is just a second clone with PHP < 5.4

------------------------------------------------------------------------
[2011-09-28 08:56:52] mapi at pdepend dot org

I will try to create a reproducable.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=55801


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55801&edit=1

Reply via email to