summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Strojny <lstrojny@php.net>2013-01-15 09:30:44 +0100
committerLars Strojny <lstrojny@php.net>2013-01-15 09:30:44 +0100
commiteb40f73ca0a2a7563fbc95cc22741412e0beb76e (patch)
tree20dc73418d5266e84f16f65b2a7c23a463f0113b
parent6dc80f080ea97c09b36d8a05ec7ec5067f394c01 (diff)
downloadphp-git-eb40f73ca0a2a7563fbc95cc22741412e0beb76e.tar.gz
Bug #62489: dba_insert not working as expected
-rw-r--r--NEWS6
-rw-r--r--ext/dba/dba_flatfile.c19
-rw-r--r--ext/dba/dba_gdbm.c17
-rw-r--r--ext/dba/dba_inifile.c1
-rw-r--r--ext/dba/dba_qdbm.c10
-rw-r--r--ext/dba/tests/dba_db1.phpt4
-rw-r--r--ext/dba/tests/dba_db2.phpt4
-rw-r--r--ext/dba/tests/dba_db3.phpt4
-rw-r--r--ext/dba/tests/dba_db4_000.phpt4
-rw-r--r--ext/dba/tests/dba_dbm.phpt4
-rw-r--r--ext/dba/tests/dba_flatfile.phpt4
-rw-r--r--ext/dba/tests/dba_gdbm.phpt2
-rw-r--r--ext/dba/tests/dba_handler.inc12
-rw-r--r--ext/dba/tests/dba_inifile.phpt4
-rw-r--r--ext/dba/tests/dba_ndbm.phpt4
-rw-r--r--ext/dba/tests/dba_qdbm.phpt2
-rw-r--r--ext/dba/tests/dba_tcadb.phpt4
17 files changed, 83 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index 9e8cd8502b..4145dc54ee 100644
--- a/NEWS
+++ b/NEWS
@@ -27,12 +27,16 @@ PHP NEWS
- DateTime
. Added DateTimeImmutable - a variant of DateTime that only returns the
- modified state instead of changing itself. (Derick)
+ modified state instead of changing itself. (Derick)
- pgsql:
. Bug #46408: Locale number format settings can cause pg_query_params to
break with numerics. (asmecher, Lars)
+- dba:
+ . Bug #62489: dba_insert not working as expected.
+ (marc-bennewitz at arcor dot de, Lars)
+
18 Dec 2012, PHP 5.5.0 Alpha 2
- General improvements:
diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c
index 082aa5cdb6..34aa635a54 100644
--- a/ext/dba/dba_flatfile.c
+++ b/ext/dba/dba_flatfile.c
@@ -88,15 +88,16 @@ DBA_UPDATE_FUNC(flatfile)
gval.dsize = vallen;
switch(flatfile_store(dba, gkey, gval, mode==1 ? FLATFILE_INSERT : FLATFILE_REPLACE TSRMLS_CC)) {
- case -1:
- php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible");
- return FAILURE;
- default:
- case 0:
- return SUCCESS;
- case 1:
- php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists");
- return FAILURE;
+ case 0:
+ return SUCCESS;
+ case 1:
+ return FAILURE;
+ case -1:
+ php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible");
+ return FAILURE;
+ default:
+ php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value");
+ return FAILURE;
}
}
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
index 7534568d39..47dd576496 100644
--- a/ext/dba/dba_gdbm.c
+++ b/ext/dba/dba_gdbm.c
@@ -104,11 +104,18 @@ DBA_UPDATE_FUNC(gdbm)
gval.dptr = (char *) val;
gval.dsize = vallen;
- if(gdbm_store(dba->dbf, gkey, gval,
- mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0)
- return SUCCESS;
- php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno));
- return FAILURE;
+ switch (gdbm_store(dba->dbf, gkey, gval, mode == 1 ? GDBM_INSERT : GDBM_REPLACE)) {
+ case 0:
+ return SUCCESS;
+ case 1:
+ return FAILURE;
+ case -1:
+ php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno));
+ return FAILURE;
+ default:
+ php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value");
+ return FAILURE;
+ }
}
DBA_EXISTS_FUNC(gdbm)
diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c
index e1359b65e9..05ee95c0ec 100644
--- a/ext/dba/dba_inifile.c
+++ b/ext/dba/dba_inifile.c
@@ -101,7 +101,6 @@ DBA_UPDATE_FUNC(inifile)
case 0:
return SUCCESS;
case 1:
- php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists");
return FAILURE;
}
}
diff --git a/ext/dba/dba_qdbm.c b/ext/dba/dba_qdbm.c
index 485b1997e6..eeece57011 100644
--- a/ext/dba/dba_qdbm.c
+++ b/ext/dba/dba_qdbm.c
@@ -96,13 +96,15 @@ DBA_FETCH_FUNC(qdbm)
DBA_UPDATE_FUNC(qdbm)
{
QDBM_DATA;
- int result;
- result = dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER);
- if (result)
+ if (dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER)) {
return SUCCESS;
+ }
+
+ if (dpecode != DP_EKEEP) {
+ php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode));
+ }
- php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode));
return FAILURE;
}
diff --git a/ext/dba/tests/dba_db1.phpt b/ext/dba/tests/dba_db1.phpt
index a24600350f..d0e530e026 100644
--- a/ext/dba/tests/dba_db1.phpt
+++ b/ext/dba/tests/dba_db1.phpt
@@ -18,6 +18,8 @@ database handler: db1
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt
index 89d8a926e1..1cfbb3e340 100644
--- a/ext/dba/tests/dba_db2.phpt
+++ b/ext/dba/tests/dba_db2.phpt
@@ -18,6 +18,8 @@ database handler: db2
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt
index 257c882175..5de7e5a041 100644
--- a/ext/dba/tests/dba_db3.phpt
+++ b/ext/dba/tests/dba_db3.phpt
@@ -18,6 +18,8 @@ database handler: db3
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_db4_000.phpt b/ext/dba/tests/dba_db4_000.phpt
index bbbc52c9f1..17db4bb62d 100644
--- a/ext/dba/tests/dba_db4_000.phpt
+++ b/ext/dba/tests/dba_db4_000.phpt
@@ -22,6 +22,8 @@ database handler: db4
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt
index dd1fe1e31c..8bea8463da 100644
--- a/ext/dba/tests/dba_dbm.phpt
+++ b/ext/dba/tests/dba_dbm.phpt
@@ -18,6 +18,8 @@ database handler: dbm
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt
index 8e1ca6a933..ac7f86ebda 100644
--- a/ext/dba/tests/dba_flatfile.phpt
+++ b/ext/dba/tests/dba_flatfile.phpt
@@ -22,6 +22,8 @@ database handler: flatfile
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt
index 33d7d20615..e68e8b7409 100644
--- a/ext/dba/tests/dba_gdbm.phpt
+++ b/ext/dba/tests/dba_gdbm.phpt
@@ -21,6 +21,8 @@ database handler: gdbm
Content String 2
Content 2 replaced
Read during write:%sallowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc
index 1c3f5127ef..a950e903af 100644
--- a/ext/dba/tests/dba_handler.inc
+++ b/ext/dba/tests/dba_handler.inc
@@ -46,8 +46,16 @@ do {
echo "Read during write: allowed\n";
}
if ($db_writer!==FALSE) {
- dba_insert("key number 6", "The 6th value", $db_writer);
- @dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer);
+ if (dba_insert("key number 6", "The 6th value", $db_writer)) {
+ echo '"key number 6" written' . "\n";
+ } else {
+ echo 'Failed to write "key number 6"' . "\n";
+ }
+ if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) {
+ echo '"key number 6" written 2nd time' . "\n";
+ } else {
+ echo 'Failed to write "key number 6" 2nd time' . "\n";
+ }
dba_replace("key2", "Content 2 replaced 2nd time", $db_writer);
dba_delete("key4", $db_writer);
echo dba_fetch("key2", $db_writer)."\n";
diff --git a/ext/dba/tests/dba_inifile.phpt b/ext/dba/tests/dba_inifile.phpt
index 81ab738796..5975d25f4d 100644
--- a/ext/dba/tests/dba_inifile.phpt
+++ b/ext/dba/tests/dba_inifile.phpt
@@ -18,6 +18,8 @@ database handler: inifile
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt
index b0f5542de4..193db6f94d 100644
--- a/ext/dba/tests/dba_ndbm.phpt
+++ b/ext/dba/tests/dba_ndbm.phpt
@@ -18,6 +18,8 @@ database handler: ndbm
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_qdbm.phpt b/ext/dba/tests/dba_qdbm.phpt
index ef216d9258..e2205baa26 100644
--- a/ext/dba/tests/dba_qdbm.phpt
+++ b/ext/dba/tests/dba_qdbm.phpt
@@ -19,6 +19,8 @@ database handler: qdbm
Content String 2
Content 2 replaced
Read during write:%sallowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
diff --git a/ext/dba/tests/dba_tcadb.phpt b/ext/dba/tests/dba_tcadb.phpt
index 52dd4de336..28b6dd8f0b 100644
--- a/ext/dba/tests/dba_tcadb.phpt
+++ b/ext/dba/tests/dba_tcadb.phpt
@@ -22,6 +22,8 @@ database handler: tcadb
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
@@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
+"key number 6" written
+Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {