mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Update to use Hash.
Update CakeSession & Configure to use Hash.
This commit is contained in:
parent
8becc4c985
commit
29048b3bb7
2 changed files with 11 additions and 31 deletions
|
@ -13,7 +13,7 @@
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::uses('Set', 'Utility');
|
App::uses('Hash', 'Utility');
|
||||||
App::uses('ConfigReaderInterface', 'Configure');
|
App::uses('ConfigReaderInterface', 'Configure');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,12 +127,7 @@ class Configure {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($config as $name => $value) {
|
foreach ($config as $name => $value) {
|
||||||
$pointer = &self::$_values;
|
self::$_values = Hash::insert(self::$_values, $name, $value);
|
||||||
foreach (explode('.', $name) as $key) {
|
|
||||||
$pointer = &$pointer[$key];
|
|
||||||
}
|
|
||||||
$pointer = $value;
|
|
||||||
unset($pointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['debug']) && function_exists('ini_set')) {
|
if (isset($config['debug']) && function_exists('ini_set')) {
|
||||||
|
@ -163,18 +158,7 @@ class Configure {
|
||||||
if ($var === null) {
|
if ($var === null) {
|
||||||
return self::$_values;
|
return self::$_values;
|
||||||
}
|
}
|
||||||
if (isset(self::$_values[$var])) {
|
return Hash::get(self::$_values, $var);
|
||||||
return self::$_values[$var];
|
|
||||||
}
|
|
||||||
$pointer = &self::$_values;
|
|
||||||
foreach (explode('.', $var) as $key) {
|
|
||||||
if (isset($pointer[$key])) {
|
|
||||||
$pointer = &$pointer[$key];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,11 +177,7 @@ class Configure {
|
||||||
public static function delete($var = null) {
|
public static function delete($var = null) {
|
||||||
$keys = explode('.', $var);
|
$keys = explode('.', $var);
|
||||||
$last = array_pop($keys);
|
$last = array_pop($keys);
|
||||||
$pointer = &self::$_values;
|
self::$_values = Hash::remove(self::$_values, $var);
|
||||||
foreach ($keys as $key) {
|
|
||||||
$pointer = &$pointer[$key];
|
|
||||||
}
|
|
||||||
unset($pointer[$last]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,7 +266,7 @@ class Configure {
|
||||||
$keys = array_keys($values);
|
$keys = array_keys($values);
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) {
|
if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) {
|
||||||
$values[$key] = Set::merge($c, $values[$key]);
|
$values[$key] = Hash::merge($c, $values[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::uses('Set', 'Utility');
|
App::uses('Hash', 'Utility');
|
||||||
App::uses('Security', 'Utility');
|
App::uses('Security', 'Utility');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,7 +216,7 @@ class CakeSession {
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result = Set::classicExtract($_SESSION, $name);
|
$result = Hash::get($_SESSION, $name);
|
||||||
return isset($result);
|
return isset($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,9 +364,9 @@ class CakeSession {
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result = Set::classicExtract($_SESSION, $name);
|
$result = Hash::get($_SESSION, $name);
|
||||||
|
|
||||||
if (!is_null($result)) {
|
if (isset($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
self::_setError(2, "$name doesn't exist");
|
self::_setError(2, "$name doesn't exist");
|
||||||
|
@ -405,8 +405,8 @@ class CakeSession {
|
||||||
$write = array($name => $value);
|
$write = array($name => $value);
|
||||||
}
|
}
|
||||||
foreach ($write as $key => $val) {
|
foreach ($write as $key => $val) {
|
||||||
self::_overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
|
self::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val));
|
||||||
if (Set::classicExtract($_SESSION, $key) !== $val) {
|
if (Hash::get($_SESSION, $key) !== $val) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue