zendtech / ZendOptimizerPlus

Other
914 stars 142 forks source link

use of undefined constant leads to 2 elements with same name in session-array unter certain circumstances #170

Open mandark opened 10 years ago

mandark commented 10 years ago

i've stumbled upon a strange bug using Zend OPcache (v7.0.3).

here are the steps to reproduce it:

create a php file with the following content:

<?php

namespace test;

@session_start();

setSessionData();

echo "<pre>";
print_r($_SESSION);
echo "</pre>";
die;

function setSessionData($strSessionKey = FOO) {
    if (!isset($_SESSION[$strSessionKey]))  {
        $_SESSION[$strSessionKey] = 'BAR';
    }
}

now execute the script in the browser. the first time you will see this result:

Array
(
    [FOO] => BAR
)

now hit F5 once or twice. after that, you will see this session-content:

Array
(
    [FOO] => 
    [FOO] => BAR
)

this should of course not be possible and also does not occur with zendopcache disabled.

TerryE commented 10 years ago

This one intrigues me. I'll take a look over the next few day if I have time, and see if I can replicate it -- and if so look at proposing a fix.

TerryE commented 10 years ago

Sorry, but I tried to replicate this with

php56 -S localhost:8080 -d opcache.enable=1 -d opcache.enable_cli=1

-- that is with my current 5.6 test build and I don't see this happing.