mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +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:
@@ -782,7 +782,8 @@ class e_model extends e_object
|
|||||||
return $this->$data_src;
|
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]))
|
if(isset($this->_parsed_keys[$data_src.'/'.$key]))
|
||||||
{
|
{
|
||||||
@@ -790,16 +791,29 @@ class e_model extends e_object
|
|||||||
}
|
}
|
||||||
$keyArr = explode('/', $key);
|
$keyArr = explode('/', $key);
|
||||||
$data = $this->$data_src;
|
$data = $this->$data_src;
|
||||||
foreach ($keyArr as $k)
|
foreach ($keyArr as $i => $k)
|
||||||
{
|
{
|
||||||
if ('' === $k)
|
if ('' === $k)
|
||||||
{
|
{
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
unset($keyArr[$i]);
|
||||||
if (is_array($data))
|
if (is_array($data))
|
||||||
{
|
{
|
||||||
if (!isset($data[$k]))
|
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;
|
return $default;
|
||||||
}
|
}
|
||||||
$data = $data[$k];
|
$data = $data[$k];
|
||||||
|
Reference in New Issue
Block a user