Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7 Preview Release
-
Fix Version/s: 1.8.0
-
Component/s: Zend_Config
-
Labels:None
Description
I have to say, that i dont know, if this behaviour is mentioned as issue before. ![]()
I thought, that the method setReadOnly() acts like the constructor-parameter allowModifications, so Im able to build up a configuration from different sources and merge it into one, but the method only locks the object itself, not the containing objects, as it will be done when setting the constructor-parameter to false.
$array = array ('key1'=>1,'key2'=>array('a'=>1,'b'=>2));
$c = new Zend_Config($array,false);
$c->key2->a = 3;
$array = array ('key1'=>1,'key2'=>array('a'=>1,'b'=>2));
$c = new Zend_Config($array,true);
$c->setReadOnly();
$c->key2->a = 3;
Changing setReadOnly()
public function setReadOnly() { $this->_allowModifications = false; }
to
public function setReadOnly() { $this->_allowModifications = false; foreach (this->_data as $value) { if ($value instanceof Zend_Config) { $value->setReadOnly(); } } }
will also lock nested objects and will make the behaviour equal to that of the constructor-parameter.
And makes the method more useful
I dont see, why i should be able to lock a config, but are able to change deeper config settings.
I usually use this method to apply readOnly to the current iteration's elements.Because i separate readonly segment and allowModificatable segment .
I prefer to add a method setReadOnlyRecursively() as follows for more flexibilty and backward compatibility.