|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66006 memcache->increment behavior undefined if value > MAX_INT
Submitted: 2013-10-30 19:28 UTC Modified: 2013-10-30 19:39 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: bquinlan at google dot com Assigned:
Status: Open Package: memcache (PECL)
PHP Version: 5.4.21 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-10-30 19:28 UTC] bquinlan at google dot com
php > $memcache = new Memcached;
php > $memcache->addServer('localhost', 11211) or die ("Could not connect");
php > var_dump($memcache->set('key', 9223372036854775807));
php > var_dump($memcache->increment('key'));

The negative return value is a consequence of memcache->increment's use of atol to parse the results i.e.

  *number = (long) atol(mmc->inbuf);
  return 1;

memcache->increment should return the same thing as memcache->get for the key after increment.

Though I'm not sure if the clipping behavior of memcache->get is correct either:

php > var_dump($memcache->get('key'));


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-30 19:39 UTC]
It is hard to do anything relevant for integers > MAX_INT. Casting them to double won't work well either, while it will at least keep the value (not the integer tho').
 [2013-10-31 17:41 UTC] petermck at google dot com
Wouldn't it be better if the increment() call in the example code returned int(9223372036854775807) ?  At least that'd be consistent with doing a subsequent get() call on the same key.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 23 12:01:24 2020 UTC