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

ZF2 Memcached PHP7 backward incompatible change #140

Closed
@octavianparalescu

Description

@octavianparalescu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions