php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #73629
Patch fix-iterator-mask.patch revision 2016-11-30 15:50 UTC by j dot jeising at gmail dot com

Patch fix-iterator-mask.patch for SPL related Bug #73629

Patch version 2016-11-30 15:50 UTC

Return to Bug #73629 | Download this patch
Patch Revisions:

Developer: j.jeising@gmail.com

diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index f8408b7..7b62018 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -733,7 +733,7 @@ SPL_METHOD(SplDoublyLinkedList, setIteratorMode)
 		return;
 	}
 
-	intern->flags = value & SPL_DLLIST_IT_MASK;
+	intern->flags = (value & SPL_DLLIST_IT_MASK) | (intern->flags & ~SPL_DLLIST_IT_MASK);
 
 	RETURN_LONG(intern->flags);
 }
diff --git a/ext/spl/tests/bugXXXXX.phpt b/ext/spl/tests/bugXXXXX.phpt
new file mode 100644
index 0000000..f179515
--- /dev/null
+++ b/ext/spl/tests/bugXXXXX.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: DoublyLinkedList: iterator modes with internal flags
+--FILE--
+<?php
+$q = new SplQueue();
+$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
+$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+
+try {
+	$q = new SplQueue();
+	$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
+	$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+} catch (Exception $e) {
+	echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 10:01:28 2024 UTC