php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62131 increment function working incorrectly (with binary protocol)
Submitted: 2012-05-23 21:25 UTC Modified: 2012-05-23 21:32 UTC
From: parf at comfi dot com Assigned: andrei (profile)
Status: Closed Package: memcached (PECL)
PHP Version: 5.4.3 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: parf at comfi dot com
New email:
PHP Version: OS:

 

 [2012-05-23 21:25 UTC] parf at comfi dot com
Description:
------------
5.4.3 64 bit

increment / decrement operations failing with binary protocol in the following 
scenario.

add operation returns incorrect result (true instead of false)

there is no bug without binary protocol

Test script:
---------------
!/bin/env spartan-test

// spartan-test unit test: https://github.com/parf/spartan-test
// PHP memcached extension BUG

$mc = new Memcached();
#={"class":"Memcached","0":{}}
- $mc->addServer("localhost", 11211);

# this options are irrelevant
#- $mc->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY);
#- $mc->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
#- $mc->setOption(Memcached::OPT_TCP_NODELAY,true);

# this IS a bug option - binary protocol messes things up
- $mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);

$mc->getVersion();
#={"localhost:11211":"1.4.10"}

# #={"p:11211":"1.4.10"}  << test on another server also have same issue

phpversion();
#="5.4.3"

# 5.4.1 was also tested

# no idea hwo to get pecl package version from php.
# rpm -qa | grep php-pecl-memcached : php-pecl-memcached-2.0.1-6.el6.remi.x86_64

- $key="key-for-testing";

# OK CASE·
$mc->set($key, 0);
#=true
$mc->increment($key);
#=1
$mc->increment($key);
#=2
$mc->increment($key);
#=3

# BUG CASE
# extra get after set messes subsequent increments
$mc->set($key, 0);
#=true
$mc->get($key);
#=0
# OMG - BUG !!!·
$mc->increment($key);
#=-1
$mc->increment($key);
#=1
$mc->increment($key);
#=2




# ANOTHER BUG
- $mc->delete($key);

## add if not exists
$mc->add($key, "abc");
#=true
$mc->get($key);
#="abc"

## BUG in memcached extension
## - it returned true, and it should return false !!!
$mc->add($key, "def");
#=true
$mc->get($key);
#="abc"


Expected result:
----------------
$mc = new Memcached();
#={"class":"Memcached","0":{}}
- $mc->addServer("localhost", 11211);
- $mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);


# extra get after set messes subsequent increments
$mc->set($key, 0);
#=true
$mc->get($key);
#=0
$mc->increment($key);
#=1
$mc->increment($key);
#=2
$mc->increment($key);
#=3


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-23 21:32 UTC] andrei@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: andrei
 [2012-05-23 21:32 UTC] andrei@php.net
Please open an issue here:

https://github.com/php-memcached-dev/php-memcached/issues
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC