]> granicus.if.org Git - php/commitdiff
Fixed bug #28822: ArrayObject::offsetExists() works inverted
authorMarcus Boerger <helly@php.net>
Mon, 21 Jun 2004 19:15:27 +0000 (19:15 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 21 Jun 2004 19:15:27 +0000 (19:15 +0000)
NEWS
ext/spl/spl_array.c
ext/spl/tests/bug28822.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index d81337c40728abf6b44ffe3649095e0b8589ffac..33389050a1798c3d9caa997c91f240a472562283 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP                                                                        NEWS
 - Fixed bug #28851 (call_user_func_array has typo in error message). (Marcus)
 - Fixed bug #28831 (ArrayObject::offsetGet() does the work of offsetUnset()). 
   (Marcus)
+- Fixed bug #28822 (ArrayObject::offsetExists() works inverted). (Marcus)
 - Fixed bug #28789 (ReflectionProperty getValue() fails on public static 
   members). (Marcus)
 - Fixed bug #28771 (Segfault when using xslt and clone). (Rob)
index 28a4870366aefaea1fcab8ae25ad6fb4aa10a0cd..901bd35552babb9378c307cf8478f02e7d9ac0c9 100755 (executable)
@@ -337,7 +337,7 @@ SPL_METHOD(Array, offsetExists)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
                return;
        }
-       RETURN_BOOL(spl_array_has_dimension(getThis(), index, 1 TSRMLS_CC) == SUCCESS);
+       RETURN_BOOL(spl_array_has_dimension(getThis(), index, 1 TSRMLS_CC));
 } /* }}} */
 
 /* {{{ proto bool ArrayObject::offsetGet(mixed $index)
diff --git a/ext/spl/tests/bug28822.phpt b/ext/spl/tests/bug28822.phpt
new file mode 100755 (executable)
index 0000000..c3da460
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #28822: ArrayObject::offsetExists() works inverted
+--FILE--
+<?php
+
+$array = new ArrayObject();
+$array->offsetSet('key', 'value');
+var_dump($array->offsetExists('key'));
+var_dump($array->offsetExists('nokey'));
+
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(false)
+===DONE===