mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-06-20 21:53:38 +00:00
Adding fix for Set::reverse() XML handling, fixes #4275, plus fixes from previous commit
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6551 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1ddeb7fbfe
commit
bacb74a6ef
4 changed files with 19 additions and 11 deletions
cake
10
cake/libs/cache/model.php
vendored
10
cake/libs/cache/model.php
vendored
|
@ -100,16 +100,12 @@ class ModelEngine extends CacheEngine {
|
||||||
if (isset($this->settings['serialize'])) {
|
if (isset($this->settings['serialize'])) {
|
||||||
$data = serialize($data);
|
$data = serialize($data);
|
||||||
}
|
}
|
||||||
|
if ($data === '') {
|
||||||
if (!$data) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$cache = array('id' => $key, $this->__fields[0] => $data, $this->__fields[1] => time() + $duration);
|
||||||
$cache = array('id' => $key,
|
|
||||||
$this->__fields[0] => $data,
|
|
||||||
$this->__fields[1] => time() + $duration
|
|
||||||
);
|
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
if ($this->__Model->save($cache)) {
|
if ($this->__Model->save($cache)) {
|
||||||
$result = true;
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -814,6 +814,11 @@ class Set extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$camelName = Inflector::camelize($object->name);
|
$camelName = Inflector::camelize($object->name);
|
||||||
|
unset($parent);
|
||||||
|
|
||||||
|
if (isset($child) && is_object($child)) {
|
||||||
|
$parent =& $child->parent();
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($object->attributes) && !empty($children)) {
|
if (!empty($object->attributes) && !empty($children)) {
|
||||||
$out[$camelName] = array_merge($object->attributes, $children);
|
$out[$camelName] = array_merge($object->attributes, $children);
|
||||||
|
@ -821,7 +826,10 @@ class Set extends Object {
|
||||||
$out[$object->name] = array_merge($object->attributes, array('value' => $object->value));
|
$out[$object->name] = array_merge($object->attributes, array('value' => $object->value));
|
||||||
} elseif (!empty($object->attributes)) {
|
} elseif (!empty($object->attributes)) {
|
||||||
$out[$camelName] = $object->attributes;
|
$out[$camelName] = $object->attributes;
|
||||||
} elseif (!empty($children) && (isset($children[$childName][0]) || isset($children[$child->name][0]))) {
|
} elseif (
|
||||||
|
(!empty($children) && (isset($children[$childName][0]) || isset($children[$child->name][0]))) ||
|
||||||
|
(!empty($children) && count($parent->children) > 1 && count($child->children) == 0)
|
||||||
|
) {
|
||||||
$out = $children;
|
$out = $children;
|
||||||
} elseif (!empty($children)) {
|
} elseif (!empty($children)) {
|
||||||
$out[$camelName] = $children;
|
$out[$camelName] = $children;
|
||||||
|
|
|
@ -26,9 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
|
App::import('Core', 'Set');
|
||||||
// Include the class to be tested
|
|
||||||
uses('set');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnitTestCase for the Set class
|
* UnitTestCase for the Set class
|
||||||
|
@ -1083,6 +1081,11 @@ class SetTest extends UnitTestCase {
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$xml = new Xml('<example><item><title>An example of a correctly reversed XMLNode</title><desc/></item></example>');
|
||||||
|
$result = Set::reverse($xml);
|
||||||
|
$expected = array('Item' => array(array('title' => 'An example of a correctly reversed XMLNode')));
|
||||||
|
$this->assertIdentical($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testStrictKeyCheck() {
|
function testStrictKeyCheck() {
|
||||||
|
|
|
@ -416,6 +416,7 @@ class CakeTestCase extends UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* Initialize DB connection.
|
* Initialize DB connection.
|
||||||
*
|
*
|
||||||
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _initDb() {
|
function _initDb() {
|
||||||
$testDbAvailable = false;
|
$testDbAvailable = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue