mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +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
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'])) {
|
||||
$data = serialize($data);
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
if ($data === '') {
|
||||
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;
|
||||
|
||||
if ($this->__Model->save($cache)) {
|
||||
$result = true;
|
||||
}
|
||||
|
|
|
@ -814,6 +814,11 @@ class Set extends Object {
|
|||
}
|
||||
}
|
||||
$camelName = Inflector::camelize($object->name);
|
||||
unset($parent);
|
||||
|
||||
if (isset($child) && is_object($child)) {
|
||||
$parent =& $child->parent();
|
||||
}
|
||||
|
||||
if (!empty($object->attributes) && !empty($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));
|
||||
} elseif (!empty($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;
|
||||
} elseif (!empty($children)) {
|
||||
$out[$camelName] = $children;
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
// Include the class to be tested
|
||||
uses('set');
|
||||
App::import('Core', 'Set');
|
||||
|
||||
/**
|
||||
* UnitTestCase for the Set class
|
||||
|
@ -1083,6 +1081,11 @@ class SetTest extends UnitTestCase {
|
|||
$result = Set::reverse($xml);
|
||||
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
||||
$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() {
|
||||
|
|
|
@ -416,6 +416,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
/**
|
||||
* Initialize DB connection.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _initDb() {
|
||||
$testDbAvailable = false;
|
||||
|
|
Loading…
Reference in a new issue