Skip to content

Values stored in Memcached influence variables defined in PHP #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wellnessliving opened this issue Mar 10, 2016 · 7 comments
Closed
Labels

Comments

@wellnessliving
Copy link

Hello!

I have two files:

set('key','arbitrary_variable_name',0); include_once('b.php'); b(); ?>

When I try to run it under CLI, I get error:

[root@s6 q]# php a.php
PHP Notice: Undefined variable: arbitrary_variable_name in /home/wl/.htprivate/options/q/b.php on line 7
array(1) {
[0]=>
NULL
}

Error does not occur if I change name of the variable, or value stored in Memcached.

PHP 7.0.3 (cli) (built: Feb 4 2016 08:51:10) ( NTS )
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
libmemcached-1.0.18
Memcached extension sources are downloaded from php7 branch.

@yuripave
Copy link

I have similar issue with latest commit in php7 branch 52c644b via dotdeb https://github.com/gplessis/dotdeb-php-memcached/releases/tag/upstream%2F2.2.0-2-52c644b

I cannot reproduce with a test script yet but the issue is causing unexpected userland variable behavior:

$memcache = new \Memcached();
$memcache->addServer('localhost', 11211);
$json_from_memcached = $memcache->get('json'); // a valid json saved earlier
json_decode($json_from_memcached, true); // null, expected to be array
$json_from_literal = '{"valid":"json"}'; // same content as $json_from_memcached
json_decode($json_from_literal , true); // array
md5($json_from_memcached) == md5($json_from_literal); // true

I can confirmed last dotdeb release has no such issue.
https://github.com/gplessis/dotdeb-php-memcached/releases/tag/upstream%2F2.2.0-1-7cb0c48
which is on 7cb0c48.

@krakjoe
Copy link
Member

krakjoe commented Apr 4, 2016

I am not able to reproduce this issue with the latest 7.0, or 7.1.

Can anyone else?

@yuripave
Copy link

yuripave commented Apr 16, 2016

Sadly I am unable to reproduce in non-production environment and do not have time to test latest php7 branch. Our production is running fine with 7cb0c48, thanks!
@yuri-popoff Do you have time to make a reproducible test script?

@dictcp
Copy link
Contributor

dictcp commented Jun 8, 2016

for @yuripave case, it should be the same as #250

@thias
Copy link

thias commented Jan 12, 2017

Both #250 and #252 are closed, so this issue could probably be closed too now.

@cosminardeleanu
Copy link

I have the same issue:

class Test
{
    public function __construct()
    {
        $memcached = new \Memcached();
        $memcached->set('key', 'whatever');
    }

    public function wtf()
    {
        $whatever = 'tests';

        function () use ($whatever) {
            return $whatever;
        };
    }
}
(new Test())->wtf();

When executing this file from cli, i get

PHP Notice: Undefined variable: whatever in /home/vagrant/www/a.php on line 14
Php version : PHP 7.0.6-1+donate.sury.org~trusty+1 (cli) ( NTS )

@pyrou
Copy link

pyrou commented Oct 11, 2017

Another test case :

<?php

(new Memcached)->set("key", "a");

$test = create_function('', '$a = 10; return $a;');

var_dump($test()); // NULL
// PHP Notice:  Undefined variable: a in [...]/test.php(6) : runtime-created function on line 1

$test = create_function('', '$b = 10; return $b;');

var_dump($test()); // int(10)

$b is defined as expected

PHP 7.0.24 (cli) (built: Oct 5 2017 23:28:51) ( NTS )
PHP 7.0.27 (cli) (built: Jan 5 2018 12:24:33) ( NTS )

libmemcached version => 1.0.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants