Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Revert "PCBC-227: Allow store of pure numeric keys"
Browse files Browse the repository at this point in the history
This patch breaks PCBC-191

This reverts commit 8382d33.

Change-Id: Iafd740c6594d9cb31654226cfafb938e3728a2e4
Reviewed-on: http://review.couchbase.org/26223
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
trondn committed May 9, 2013
1 parent 0aa8372 commit afe5200
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 96 deletions.
27 changes: 6 additions & 21 deletions store.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,20 +669,8 @@ void php_couchbase_store_multi_impl_oo(INTERNAL_FUNCTION_PARAMETERS)
char *payload;
unsigned int flags = 0;
zval **ppzval;
int allocated_key = 0;

switch (zend_hash_get_current_key_type(Z_ARRVAL_P(akeys))) {
case HASH_KEY_IS_LONG: {
ulong kval;
zend_hash_get_current_key(Z_ARRVAL_P(akeys), &key, &kval, 0);
spprintf(&key, 0, "%llu", kval);
allocated_key = 1;
}
break;
case HASH_KEY_IS_STRING:
zend_hash_get_current_key(Z_ARRVAL_P(akeys), &key, NULL, 0);
break;
default: {

if (zend_hash_get_current_key_type(Z_ARRVAL_P(akeys)) != HASH_KEY_IS_STRING) {
int xx;
for (xx = 0; xx < ii; ++xx) {
efree((void *)cmds[xx].v.v0.bytes);
Expand All @@ -697,10 +685,9 @@ void php_couchbase_store_multi_impl_oo(INTERNAL_FUNCTION_PARAMETERS)
0 TSRMLS_CC);
return ;
}
}

klen = strlen(key);
if (klen == 0) {
zend_hash_get_current_key(Z_ARRVAL_P(akeys), &key, NULL, 0);
if ((klen = strlen(key)) == 0) {
int xx;
for (xx = 0; xx < ii; ++xx) {
efree((void *)cmds[xx].v.v0.bytes);
Expand Down Expand Up @@ -745,9 +732,7 @@ void php_couchbase_store_multi_impl_oo(INTERNAL_FUNCTION_PARAMETERS)

if (couchbase_res->prefix_key_len) {
char *new_key;
allocated_key = 1;
klen = spprintf(&new_key, 0, "%s_%s", couchbase_res->prefix_key,
key);
klen = spprintf(&new_key, 0, "%s_%s", couchbase_res->prefix_key, key);
key = new_key;
}

Expand All @@ -762,7 +747,7 @@ void php_couchbase_store_multi_impl_oo(INTERNAL_FUNCTION_PARAMETERS)
cmds[ii].v.v0.flags = flags;
cmds[ii].v.v0.exptime = exp;

if (allocated_key) {
if (couchbase_res->prefix_key_len) {
efree(key);
}
}
Expand Down
61 changes: 0 additions & 61 deletions tests/Regression.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,65 +48,4 @@ class Regression extends CouchbaseTestCommon {
$this->assertEquals("", $msg);
}

function testPCBC_227() {
$oo = $this->oo;
$msg = "";


try {
couchbase_set($this->handle, "1234", "foo");
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
couchbase_set($this->handle, 1234, "foo");
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
couchbase_set_multi($this->handle, array("1234" => "foo"));
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
couchbase_set_multi($this->handle, array(1234 => "foo"));
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
$oo->set("1234", "foo");
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
$oo->set(1234, "foo");
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
$oo->setMulti(array("1234" => "foo"));
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);

try {
$oo->setMulti(array(1234 => "foo"));
} catch (Exception $exp) {
$msg = $exp->getMessage();
}
$this->assertEquals("", $msg);
}
}
14 changes: 0 additions & 14 deletions tests/phpt/Regression/PCBC_227.phpt

This file was deleted.

0 comments on commit afe5200

Please sign in to comment.