Index: Config.php
===================================================================
--- Config.php (revision 14089)
+++ Config.php (working copy)
@@ -84,6 +84,13 @@
protected $_loadFileErrorStr = null;
/**
+ * Contains the index keys of the configuration data array.
+ *
+ * @var array
+ */
+ protected $_indexes = array();
+
+ /**
* Zend_Config provides a property based interface to
* an array. The data are read-only unless $allowModifications
* is set to true on construction.
@@ -100,6 +107,7 @@
$this->_allowModifications = (boolean) $allowModifications;
$this->_loadedSection = null;
$this->_index = 0;
+ $this->_indexes = array_keys($array);
$this->_data = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
@@ -155,6 +163,9 @@
} else {
$this->_data[$name] = $value;
}
+ if (!in_array($name, $this->_indexes)) {
+ $this->_indexes[] = $name;
+ }
$this->_count = count($this->_data);
} else {
/** @see Zend_Config_Exception */
@@ -222,7 +233,10 @@
{
if ($this->_allowModifications) {
unset($this->_data[$name]);
+ unset($this->_indexes[array_search($name, $this->_indexes)]);
+ $this->_indexes = array_values($this->_indexes);
$this->_count = count($this->_data);
+ --$this->_index;
} else {
/** @see Zend_Config_Exception */
require_once 'Zend/Config/Exception.php';
@@ -248,7 +262,10 @@
*/
public function current()
{
- return current($this->_data);
+ if (!array_key_exists($key = $this->key(), $this->_data)) {
+ return false;
+ }
+ return $this->_data[$key];
}
/**
@@ -258,7 +275,7 @@
*/
public function key()
{
- return key($this->_data);
+ return $this->_indexes[$this->_index];
}
/**
@@ -267,8 +284,7 @@
*/
public function next()
{
- next($this->_data);
- $this->_index++;
+ ++$this->_index;
}
/**
@@ -277,7 +293,6 @@
*/
public function rewind()
{
- reset($this->_data);
$this->_index = 0;
}
This is the most simple test code I could come up with to show the problem.
I have no idea how to fix it!