php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58635 Issue a notice on invalid keys
Submitted: 2009-04-17 01:39 UTC Modified: 2012-03-07 17:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: brian at moonspot dot net Assigned:
Status: Open Package: memcached (PECL)
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-04-17 01:39 UTC] brian at moonspot dot net
Description:
------------
Currently, when a key is invalid, the get method/function simply returns false.  It would be nice if either an E_WARNING or E_NOTICE was thrown when a key is not a valid memcached key

Reproduce code:
---------------
$m = new Memcached();

$res = $m->addServer("localhost", 11211);

$res = $m->set("this is a key with spaces", 1);


Expected result:
----------------
E_WARNING or E_NOTICE

Actual result:
--------------
No error is thrown.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-17 12:50 UTC] andrei@php.net
You can use getResultCode() to check the result of the operation. Currently it returns Memcached::RES_PROTOCOL_ERROR for bad keys. I can add an option Memcached::OPT_VERIFY_KEYS that would validate all keys on every operation and return Memcached::RES_BAD_KEY_PROVIDED in case one of the keys is bad.d
 [2009-06-26 18:41 UTC] marc dot bennewitz at giata dot de
The memcache extension allows all strings to use as key. Is it possible to handle this same with this memcached exception ?

What is a list of rules for it ?
 [2009-06-26 18:43 UTC] andrei@php.net
I don't understand what you mean by "is it possible to handle this same with this memcached exception". Can you try asking again?
 [2009-06-26 18:43 UTC] andrei@php.net
I don't understand what you mean by "is it possible to handle this same with this memcached exception". Can you try asking again?
 [2009-06-26 18:56 UTC] marc dot bennewitz at giata dot de
On memcache it works fine to use special chars for cache ids:

$memcache->set("id &% \/\$\x00\t\n\r\\", 'data', 0, 100);
var_dump($memcache->get("id &% \/\$\x00\t\n\r\\"));

But on memcached the same code generates a Memcached::RES_BAD_KEY_PROVIDED.
It would be very nice if memcached will handle all characters as keys in the future?
 [2009-09-12 06:34 UTC] Jared dot Williams1 at ntlworld dot com
"What is a list of rules for it ?"

Keys have made up of characters that satisfy C's isgraph().
 [2012-03-07 17:13 UTC] andrei@php.net
-Summary: brianlmoon +Summary: Issue a notice on invalid keys
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 11:01:26 2019 UTC