Bug #73302 [Fbk->Csd]: Copy-On-Write on $_SESSION fails with session_decode

From: Date: Fri, 14 Oct 2016 08:57:18 +0000
Subject: Bug #73302 [Fbk->Csd]: Copy-On-Write on $_SESSION fails with session_decode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204764@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73302&edit=1

 ID:                 73302
 User updated by:    d dot negrier at thecodingmachine dot com
 Reported by:        d dot negrier at thecodingmachine dot com
 Summary:            Copy-On-Write on $_SESSION fails with session_decode
-Status:             Feedback
+Status:             Closed
 Type:               Bug
 Package:            Session related
 Operating System:   Ubuntu
 PHP Version:        7.1.0RC3
 Block user comment: N
 Private report:     N

 New Comment:

Hey Damian,

Just checked with latest master.
I confirm that the problem is indeed solved.

I'm closing this bug.
Thanks @nikic!


Previous Comments:
------------------------------------------------------------------------
[2016-10-13 13:42:53] requinix@php.net

This sounds like the same problem as bug #73273. Can you try a build of master to confirm whether
@nikic's fix solves this?

------------------------------------------------------------------------
[2016-10-13 13:37:53] x dot huberty at thecodingmachine dot Com

Description:
------------
Bug can seen here:

https://3v4l.org/tekjZ

We have the same behaviour when we copy a temp variable ($sessionCopy) in $_SESSION.

------------------------------------------------------------------------
[2016-10-12 13:53:58] d dot negrier at thecodingmachine dot com

Description:
------------
Bug can seen here:

https://3v4l.org/m1HQ3

It affects all versions starting with 7.0.

If I copy the $_SESSION variable in another variable ($sessionCopy) and then I call session_decode,
I do not expect $sessionCopy to be impacted by the call to $_SESSION.

Yet, in PHP 7.0+, $sessionCopy is also modified.

Test script:
---------------
<?php

session_start();

// $_SESSION is empty so $oldSession is empty too now.
// I expect copy to be by value, not by reference so anything impacting $_SESSION should not impace
$oldSession.
$oldSession = $_SESSION;

session_decode('id|i:1;');

var_dump($_SESSION);
var_dump($oldSession);

Expected result:
----------------
I expect $_SESSION and $oldSession to be different.


Actual result:
--------------
In PHP 7+, $_SESSION and $oldSession are equal.


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



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


Thread (4 messages)

« previous php.bugs (#204764) next »