diff --git a/libraries/vendor/joomla/registry/src/Registry.php b/libraries/vendor/joomla/registry/src/Registry.php index 6de99b42a9027..36886993247b8 100644 --- a/libraries/vendor/joomla/registry/src/Registry.php +++ b/libraries/vendor/joomla/registry/src/Registry.php @@ -143,34 +143,39 @@ public function def($key, $default = '') */ public function exists($path) { + // Return default value if path is empty + if (empty($path)) + { + return false; + } + // Explode the registry path into an array $nodes = explode('.', $path); - if ($nodes) - { - // Initialize the current node to be the registry root. - $node = $this->data; + // Initialize the current node to be the registry root. + $node = $this->data; + $found = false; - // Traverse the registry to find the correct node for the result. - for ($i = 0, $n = count($nodes); $i < $n; $i++) + // Traverse the registry to find the correct node for the result. + foreach ($nodes as $n) + { + if (is_array($node) && isset($node[$n])) { - if (isset($node->$nodes[$i])) - { - $node = $node->$nodes[$i]; - } - else - { - break; - } + $node = $node[$n]; + $found = true; + continue; + } - if ($i + 1 == $n) - { - return true; - } + if (!isset($node->$n)) + { + return false; } + + $node = $node->$n; + $found = true; } - return false; + return $found; } /** @@ -202,16 +207,20 @@ public function get($path, $default = null) // Traverse the registry to find the correct node for the result. foreach ($nodes as $n) { - if (isset($node->$n)) + if (is_array($node) && isset($node[$n])) { - $node = $node->$n; + $node = $node[$n]; $found = true; + continue; } - else + + if (!isset($node->$n)) { - $found = false; - break; + return $default; } + + $node = $node->$n; + $found = true; } if ($found && $node !== null && $node !== '')