1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-03 10:49:12 +02:00

e_model fix for data keys containing '/', the whole _getData() logic could be moved to preference models in the future (performance)

This commit is contained in:
secretr 2010-12-17 11:07:18 +00:00
parent 6f49745358
commit abef53b493

View File

@ -782,7 +782,8 @@ class e_model extends e_object
return $this->$data_src;
}
if (strpos($key, '/'))
// Fix - check if _data[path/to/value] really doesn't exist
if (!isset($this->{$data_src}[$key]) && strpos($key, '/'))
{
if(isset($this->_parsed_keys[$data_src.'/'.$key]))
{
@ -790,16 +791,29 @@ class e_model extends e_object
}
$keyArr = explode('/', $key);
$data = $this->$data_src;
foreach ($keyArr as $k)
foreach ($keyArr as $i => $k)
{
if ('' === $k)
{
return $default;
}
unset($keyArr[$i]);
if (is_array($data))
{
if (!isset($data[$k]))
{
if($keyArr)
{
// fix for 'key' => array('some/key1' => 'someValue)
// NOTE: works only if 'key' => array('some' => array('key1' => 'someValue))
// doesn't exist!!!
$k1 = implode('/', $keyArr);
if(isset($data[$k1]))
{
$this->_parsed_keys[$data_src.'/'.$key] = $data[$k1];
return $data[$k1];
}
}
return $default;
}
$data = $data[$k];