DbObject: one more protection when looking up...

...prefetched objects by name
This commit is contained in:
Thomas Gelf 2016-10-27 19:34:11 +00:00
parent c10ad0e3a2
commit 5921f4773f
1 changed files with 8 additions and 2 deletions

View File

@ -943,7 +943,10 @@ abstract class DbObject
{
$class = get_called_class();
if (static::hasPrefetched($key)) {
if (is_string($key) && array_key_exists($key, self::$prefetchedNames[$class])) {
if (is_string($key)
&& array_key_exists($class, self::$prefetchedNames)
&& array_key_exists($key, self::$prefetchedNames[$class])
) {
return self::$prefetched[$class][
self::$prefetchedNames[$class][$key]
];
@ -973,7 +976,10 @@ abstract class DbObject
}
if (array_key_exists($class, self::$prefetched)) {
if (is_string($key) && array_key_exists($key, self::$prefetchedNames[$class])) {
if (is_string($key)
&& array_key_exists($class, self::$prefetchedNames)
&& array_key_exists($key, self::$prefetchedNames[$class])
) {
self::$prefetchStats[$class]->hitNames++;
return true;
} elseif (array_key_exists($key, self::$prefetched[$class])) {