Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

ZF2 Memcached PHP7 backward incompatible change #140

Closed
octavianparalescu opened this issue Oct 25, 2017 · 2 comments
Closed

ZF2 Memcached PHP7 backward incompatible change #140

octavianparalescu opened this issue Oct 25, 2017 · 2 comments

Comments

@octavianparalescu
Copy link

octavianparalescu commented Oct 25, 2017

The new syntax is at the official PHP page:
http://php.net/manual/ro/memcached.get.php

This comment describes the problem:
http://php.net/manual/ro/memcached.get.php#121119

PHP PR that brang the backward incompatible change:
php-memcached-dev/php-memcached#214

So the easy way to support the latest change would be to change:

     protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
     {
        $memc        = $this->getMemcachedResource();
        $internalKey = $this->namespacePrefix . $normalizedKey;

        if (func_num_args() > 2) {
            $result = $memc->get($internalKey, null, $casToken);
        } else {
            $result = $memc->get($internalKey);
        }
        // etc

TO

    protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
    {
        $memc        = $this->getMemcachedResource();
        $internalKey = $this->namespacePrefix . $normalizedKey;

        if (func_num_args() > 2) {
            if(defined('Memcached::GET_EXTENDED')) {
                $tempResult = $memc->get($internalKey, null, \Memcached::GET_EXTENDED);
                $result = $tempResult['value'];
                $casToken = $tempResult['cas'];
            } else {
                $result = $memc->get($internalKey, null, $casToken);
            }
        } else {
            $result = $memc->get($internalKey);
        }
        // etc

I tested it through a custom adapter that extends the main class and it works just fine. If the changes look ok to you, I will open a pull request.

@thomasvargiu
Copy link
Contributor

Fixed in #150

@octavianparalescu
Copy link
Author

Gratzie. I can confirm this is a working fix as it has the same code as our replacement class which has been functioning for a while now.

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

No branches or pull requests

3 participants