From bc990f41e3d29db70cf5c181a11668c8e63f4bdf Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 15 Mar 2010 11:55:47 +0100 Subject: [PATCH 01/14] Prevent sql error for uuids if id is specified as null if the primary key is present in the data to be saved as null - prevent passing the same key (id) twice and therefore triggering an sql error. Signed-off-by: Mark Story --- cake/libs/model/model.php | 7 +++++- .../cases/libs/model/model_write.test.php | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 184a75fee..f3c26e01a 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1273,7 +1273,12 @@ class Model extends Overloadable { ($fInfo['type'] === 'string' || $fInfo['type'] === 'binary') ); if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) { - list($fields[], $values[]) = array($this->primaryKey, String::uuid()); + if (array_key_exists($this->primaryKey, $this->data[$this->alias])) { + $j = array_search($this->primaryKey, $fields); + $values[$j] = String::uuid(); + } else { + list($fields[], $values[]) = array($this->primaryKey, String::uuid()); + } } break; } diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index b43b0facf..2cc0326f3 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -161,6 +161,29 @@ class ModelWriteTest extends BaseModelTest { ); $this->assertEqual(strlen($result['Uuid']['id']), 36); } +/** + * Ensure that if the id key is null but present the save doesn't fail (with an + * x sql error: "Column id specified twice") + * + * @return void + * @access public + */ + function testSaveUuidNull() { + // SQLite does not support non-integer primary keys + $this->skipIf($this->db->config['driver'] == 'sqlite'); + + $this->loadFixtures('Uuid'); + $TestModel =& new Uuid(); + + $TestModel->save(array('title' => 'Test record', 'id' => null)); + $result = $TestModel->findByTitle('Test record'); + $this->assertEqual( + array_keys($result['Uuid']), + array('id', 'title', 'count', 'created', 'updated') + ); + $this->assertEqual(strlen($result['Uuid']['id']), 36); + } + /** * testZeroDefaultFieldValue method * From 28cb57a92c54a223fed4aacc738db5ccc8bc71c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 17 Mar 2010 10:32:36 -0430 Subject: [PATCH 02/14] Fixing bug in Model::escapeField() where it would return the wrong string id the datasource's name method returs the unmodified string. Tests added. Closes #473 --- cake/libs/model/model.php | 2 +- .../libs/model/model_integration.test.php | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index f3c26e01a..12de7f31f 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2631,7 +2631,7 @@ class Model extends Overloadable { $field = $this->primaryKey; } $db =& ConnectionManager::getDataSource($this->useDbConfig); - if (strpos($field, $db->name($alias)) === 0) { + if (strpos($field, $db->name($alias) . '.') === 0) { return $field; } return $db->name($alias . '.' . $field); diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index 3da333592..85de2ed96 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -24,6 +24,27 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ require_once dirname(__FILE__) . DS . 'model.test.php'; +App::import('Core', 'DboSource'); + +/** + * DboMock class + * A Dbo Source driver to mock a connection and a identity name() method + */ +class DboMock extends DboSource { + +/** +* Returns the $field without modifications +*/ + function name($field) { + return $field; + } +/** +* Returns true to fake a database connection +*/ + function connect() { + return true; + } +} /** * ModelIntegrationTest @@ -1831,5 +1852,36 @@ class ModelIntegrationTest extends BaseModelTest { $this->assertEqual($FeaturedModel->create($data), $expected); } +/** + * testEscapeField to prove it escapes the field well even when it has part of the alias on it + * @see ttp://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/473-escapefield-doesnt-consistently-prepend-modelname + * + * @access public + * @return void + */ + function testEscapeField() { + $TestModel =& new Test(); + $db =& $TestModel->getDataSource(); + + $result = $TestModel->escapeField('test_field'); + $expected = $db->name('Test.test_field'); + $this->assertEqual($result, $expected); + + $result = $TestModel->escapeField('TestField'); + $expected = $db->name('Test.TestField'); + $this->assertEqual($result, $expected); + + $result = $TestModel->escapeField('DomainHandle', 'Domain'); + $expected = $db->name('Domain.DomainHandle'); + $this->assertEqual($result, $expected); + + ConnectionManager::create('mock', array('driver' => 'mock')); + $TestModel->setDataSource('mock'); + $db =& $TestModel->getDataSource(); + + $result = $TestModel->escapeField('DomainHandle', 'Domain'); + $expected = $db->name('Domain.DomainHandle'); + $this->assertEqual($result, $expected); + } } ?> \ No newline at end of file From c3aec39d75a944c2105adbaba286049e03311f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 17 Mar 2010 10:47:03 -0430 Subject: [PATCH 03/14] Chaging array_push call for array_merge, as the first one would produce worng nested arrays in MediaView. closes #391 --- cake/libs/view/media.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 71c4e43a2..f50217d8f 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -148,7 +148,7 @@ class MediaView extends View { $contentTypes[0] = 'application/octetstream'; } else if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) { $contentTypes[0] = 'application/force-download'; - array_push($contentTypes, array( + array_merge($contentTypes, array( 'application/octet-stream', 'application/download' )); From f65cb31cbea30b551369689990a1f0d78af0cc84 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 19 Mar 2010 20:44:18 -0400 Subject: [PATCH 04/14] Updating documentation for Router::normalize(). Refs #486 --- cake/libs/router.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 51d452cec..1569ba359 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1180,9 +1180,11 @@ class Router extends Object { return $out; } /** - * Normalizes a URL for purposes of comparison + * Normalizes a URL for purposes of comparison. Will strip the base path off + * and replace any double /'s. It will not unify the casing and underscoring + * of the input value. * - * @param mixed $url URL to normalize + * @param mixed $url URL to normalize Either an array or a string url. * @return string Normalized URL * @access public */ From 6c8ce984aad2fa830da219cd2665c378cecec340 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 20 Mar 2010 18:15:52 -0400 Subject: [PATCH 05/14] Adding import for String to ensure that String has been loaded when Security component is used without making any database connections. Fixes #482 --- cake/libs/controller/components/security.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index f702c194a..e49f69966 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -23,6 +23,7 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ +App::import('Core', 'String'); /** * Short description for file. * From 9d3f2fb4a757e0cccbb590a5062dc4a29dff13e4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 24 Mar 2010 22:33:51 -0400 Subject: [PATCH 06/14] Moving Non-Zero tests for Set::extract() into a separate method. --- cake/tests/cases/libs/set.test.php | 114 ++++++++++++++++------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 6867ae4f1..19dbc9968 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -417,43 +417,15 @@ class SetTest extends CakeTestCase { array('a' => array('II' => array('a' => 3, 'III' => array('a' => array('foo' => 4))))), ); - $nonSequential = array( - 'User' => array( - 0 => array('id' => 1), - 2 => array('id' => 2), - 6 => array('id' => 3), - 9 => array('id' => 4), - 3 => array('id' => 5), - ), - ); - - $nonZero = array( - 'User' => array( - 2 => array('id' => 1), - 4 => array('id' => 2), - 6 => array('id' => 3), - 9 => array('id' => 4), - 3 => array('id' => 5), - ), - ); - $expected = array(array('a' => $c[2]['a'])); $r = Set::extract('/a/II[a=3]/..', $c); $this->assertEqual($r, $expected); $expected = array(1, 2, 3, 4, 5); $this->assertEqual(Set::extract('/User/id', $a), $expected); - $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); - - $result = Set::extract('/User/id', $nonZero); - $this->assertEqual($result, $expected, 'Failed non zero array key extract'); $expected = array(1, 2, 3, 4, 5); $this->assertEqual(Set::extract('/User/id', $a), $expected); - $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); - - $result = Set::extract('/User/id', $nonZero); - $this->assertEqual($result, $expected, 'Failed non zero array key extract'); $expected = array( array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4), array('id' => 5) @@ -549,30 +521,6 @@ class SetTest extends CakeTestCase { $r = Set::extract('/User/@*', $tricky); $this->assertEqual($r, $expected); - $nonZero = array( - 1 => array( - 'User' => array( - 'id' => 1, - 'name' => 'John', - ) - ), - 2 => array( - 'User' => array( - 'id' => 2, - 'name' => 'Bob', - ) - ), - 3 => array( - 'User' => array( - 'id' => 3, - 'name' => 'Tony', - ) - ) - ); - $expected = array(1, 2, 3); - $r = Set::extract('/User/id', $nonZero); - $this->assertEqual($r, $expected); - $common = array( array( 'Article' => array( @@ -1026,6 +974,68 @@ class SetTest extends CakeTestCase { $expected = array('Second'); $this->assertEqual($result, $expected); } +/** + * test that extract() still works when arrays don't contain a 0 index. + * + * @return void + */ + function testExtractWithNonZeroArrays() { + $nonZero = array( + 1 => array( + 'User' => array( + 'id' => 1, + 'name' => 'John', + ) + ), + 2 => array( + 'User' => array( + 'id' => 2, + 'name' => 'Bob', + ) + ), + 3 => array( + 'User' => array( + 'id' => 3, + 'name' => 'Tony', + ) + ) + ); + $expected = array(1, 2, 3); + $r = Set::extract('/User/id', $nonZero); + $this->assertEqual($r, $expected); + + $nonSequential = array( + 'User' => array( + 0 => array('id' => 1), + 2 => array('id' => 2), + 6 => array('id' => 3), + 9 => array('id' => 4), + 3 => array('id' => 5), + ), + ); + + $nonZero = array( + 'User' => array( + 2 => array('id' => 1), + 4 => array('id' => 2), + 6 => array('id' => 3), + 9 => array('id' => 4), + 3 => array('id' => 5), + ), + ); + + $expected = array(1, 2, 3, 4, 5); + $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); + + $result = Set::extract('/User/id', $nonZero); + $this->assertEqual($result, $expected, 'Failed non zero array key extract'); + + $expected = array(1, 2, 3, 4, 5); + $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); + + $result = Set::extract('/User/id', $nonZero); + $this->assertEqual($result, $expected, 'Failed non zero array key extract'); + } /** * testExtractWithArrays method * From e8e520d6f2114b2e954299ca95e7360f4d191535 Mon Sep 17 00:00:00 2001 From: Jimmy Bourassa Date: Wed, 17 Mar 2010 00:09:27 -0400 Subject: [PATCH 07/14] Added test case for a bug in Set::extract Signed-off-by: Mark Story --- cake/tests/cases/libs/set.test.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 19dbc9968..06632a796 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -973,6 +973,20 @@ class SetTest extends CakeTestCase { $result = Set::extract('/ParentNode/name', $hasMany); $expected = array('Second'); $this->assertEqual($result, $expected); + + $startingAtOne = array( + 'Article' => array( + 1=> array( + 'id' => 1, + 'approved' => 1, + ), + ) + ); + + $expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1))); + $result = Set::extract('/Article[approved=1]', $startingAtOne); + $this->assertEqual($result, $expected); + } /** * test that extract() still works when arrays don't contain a 0 index. From cbb65ca85f514df59486b4ac02517d78b9c7e5a5 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 24 Mar 2010 22:36:38 -0400 Subject: [PATCH 08/14] Moving failing test into new method for non-zero array extraction. --- cake/tests/cases/libs/set.test.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 06632a796..46c2dd597 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -973,20 +973,6 @@ class SetTest extends CakeTestCase { $result = Set::extract('/ParentNode/name', $hasMany); $expected = array('Second'); $this->assertEqual($result, $expected); - - $startingAtOne = array( - 'Article' => array( - 1=> array( - 'id' => 1, - 'approved' => 1, - ), - ) - ); - - $expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1))); - $result = Set::extract('/Article[approved=1]', $startingAtOne); - $this->assertEqual($result, $expected); - } /** * test that extract() still works when arrays don't contain a 0 index. @@ -1049,6 +1035,19 @@ class SetTest extends CakeTestCase { $result = Set::extract('/User/id', $nonZero); $this->assertEqual($result, $expected, 'Failed non zero array key extract'); + + $startingAtOne = array( + 'Article' => array( + 1=> array( + 'id' => 1, + 'approved' => 1, + ), + ) + ); + + $expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1))); + $result = Set::extract('/Article[approved=1]', $startingAtOne); + $this->assertEqual($result, $expected); } /** * testExtractWithArrays method From 4f4d3f9ffe186ed5fde8c1b800903630e66b6113 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 24 Mar 2010 23:25:02 -0400 Subject: [PATCH 09/14] Fixing extraction of non-zero arrays with only one element and attribute selectors. Fixes #475 --- cake/libs/set.php | 3 ++- cake/tests/cases/libs/set.test.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/set.php b/cake/libs/set.php index ed8e19c91..b6179de1c 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -438,7 +438,8 @@ class Set extends Object { $items = array($items); } elseif (!isset($items[0])) { $current = current($items); - if ((is_array($current) && count($items) <= 1) || !is_array($current)) { + $currentKey = key($items); + if (!is_array($current) || (is_array($current) && count($items) <= 1 && !is_numeric($currentKey))) { $items = array($items); } } diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 46c2dd597..349522ece 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -1035,10 +1035,10 @@ class SetTest extends CakeTestCase { $result = Set::extract('/User/id', $nonZero); $this->assertEqual($result, $expected, 'Failed non zero array key extract'); - + $startingAtOne = array( 'Article' => array( - 1=> array( + 1 => array( 'id' => 1, 'approved' => 1, ), From d95e482894927f8f9dbb80959d36a87d57467ed3 Mon Sep 17 00:00:00 2001 From: predominant Date: Fri, 26 Mar 2010 10:46:48 +1100 Subject: [PATCH 10/14] Refs #332. Beginning fix for multiple session starts. --- cake/libs/session.php | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/cake/libs/session.php b/cake/libs/session.php index 8dbbdb78a..f44740648 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -116,6 +116,13 @@ class CakeSession extends Object { * @access public */ var $id = null; +/** + * Session Started + * + * @var boolean + * @access public + */ + var $started = false; /** * Constructor. * @@ -163,16 +170,19 @@ class CakeSession extends Object { /** * Starts the Session. * - * @param string $name Variable name to check for - * @return boolean True if variable is there + * @return boolean True if session was started * @access public */ function start() { + if ($this->started) { + return true; + } if (function_exists('session_write_close')) { session_write_close(); } $this->__initSession(); - return $this->__startSession(); + $this->started = $this->__startSession(); + return $this->started; } /** * Determine if Session has been started. @@ -475,12 +485,13 @@ class CakeSession extends Object { ini_set('session.auto_start', 0); } } - session_set_save_handler(array('CakeSession','__open'), - array('CakeSession', '__close'), - array('CakeSession', '__read'), - array('CakeSession', '__write'), - array('CakeSession', '__destroy'), - array('CakeSession', '__gc')); + session_set_save_handler( + array('CakeSession','__open'), + array('CakeSession', '__close'), + array('CakeSession', '__read'), + array('CakeSession', '__write'), + array('CakeSession', '__destroy'), + array('CakeSession', '__gc')); break; case 'php': if (empty($_SESSION)) { @@ -507,12 +518,13 @@ class CakeSession extends Object { ini_set('session.cookie_path', $this->path); } } - session_set_save_handler(array('CakeSession','__open'), - array('CakeSession', '__close'), - array('Cache', 'read'), - array('Cache', 'write'), - array('Cache', 'delete'), - array('Cache', 'gc')); + session_set_save_handler( + array('CakeSession','__open'), + array('CakeSession', '__close'), + array('Cache', 'read'), + array('Cache', 'write'), + array('Cache', 'delete'), + array('Cache', 'gc')); break; default: if (empty($_SESSION)) { From 9740029e9e2db239c54f8db53d69046e04ef0dbe Mon Sep 17 00:00:00 2001 From: predominant Date: Fri, 26 Mar 2010 14:21:08 +1100 Subject: [PATCH 11/14] Fixes #332. --- cake/libs/session.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/session.php b/cake/libs/session.php index f44740648..d6a856392 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -120,9 +120,9 @@ class CakeSession extends Object { * Session Started * * @var boolean - * @access public + * @access protected */ - var $started = false; + var $_started = false; /** * Constructor. * @@ -174,15 +174,15 @@ class CakeSession extends Object { * @access public */ function start() { - if ($this->started) { + if ($this->started()) { return true; } if (function_exists('session_write_close')) { session_write_close(); } $this->__initSession(); - $this->started = $this->__startSession(); - return $this->started; + $this->_started = $this->__startSession(); + return $this->started(); } /** * Determine if Session has been started. @@ -191,7 +191,7 @@ class CakeSession extends Object { * @return boolean True if session has been started. */ function started() { - if (isset($_SESSION)) { + if (isset($_SESSION) && $this->_started) { return true; } return false; @@ -223,7 +223,7 @@ class CakeSession extends Object { $this->id = $id; session_id($this->id); } - if (isset($_SESSION)) { + if ($this->started()) { return session_id(); } else { return $this->id; From 9f5949ab5273048c76bf411d7c0057ba217d6132 Mon Sep 17 00:00:00 2001 From: predominant Date: Fri, 26 Mar 2010 14:29:27 +1100 Subject: [PATCH 12/14] Fix for Session Component to use CakeSession started() checks. Refs #332. --- cake/libs/controller/components/session.php | 16 ++++------------ .../libs/controller/components/session.test.php | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 5300ab6f4..7f8c2df55 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -43,13 +43,6 @@ class SessionComponent extends CakeSession { * @access private */ var $__active = true; -/** - * Used to determine if Session has been started - * - * @var boolean - * @access private - */ - var $__started = false; /** * Used to determine if request are from an Ajax request * @@ -89,7 +82,7 @@ class SessionComponent extends CakeSession { * @access public */ function startup(&$controller) { - if ($this->__started === false && $this->__active === true) { + if ($this->started() === false && $this->__active === true) { $this->__start(); } } @@ -299,15 +292,14 @@ class SessionComponent extends CakeSession { * @access private */ function __start() { - if ($this->__started === false) { + if ($this->started() === false) { if (!$this->id() && parent::start()) { - $this->__started = true; parent::_checkValid(); } else { - $this->__started = parent::start(); + parent::start(); } } - return $this->__started; + return $this->started(); } } diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index c87c9f6f0..b6115fe29 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -108,13 +108,13 @@ class SessionComponentTest extends CakeTestCase { Configure::write('Session.start', false); $Session =& new SessionComponent(); $this->assertFalse($Session->__active); - $this->assertFalse($Session->__started); + $this->assertFalse($Session->started()); $Session->startup(new SessionTestController()); Configure::write('Session.start', true); $Session =& new SessionComponent(); $this->assertTrue($Session->__active); - $this->assertFalse($Session->__started); + $this->assertFalse($Session->started()); $Session->startup(new SessionTestController()); $this->assertTrue(isset($_SESSION)); From ec3f4b8d34005d533d5d0f6d4003e65971a3e394 Mon Sep 17 00:00:00 2001 From: predominant Date: Fri, 26 Mar 2010 19:59:09 +1100 Subject: [PATCH 13/14] Fixes #53, ordering of XML::toArray() operations. --- cake/libs/xml.php | 3 ++- cake/tests/cases/libs/xml.test.php | 37 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/cake/libs/xml.php b/cake/libs/xml.php index ba37d5d96..4c2e03894 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -664,6 +664,7 @@ class XmlNode extends Object { foreach ($this->children as $child) { $key = $camelize ? Inflector::camelize($child->name) : $child->name; + //debug($key); if (is_a($child, 'XmlTextNode')) { $out['value'] = $child->value; @@ -688,7 +689,7 @@ class XmlNode extends Object { if (isset($out[$key]) || isset($multi[$key])) { if (!isset($multi[$key])) { $multi[$key] = array($out[$key]); - unset($out[$key]); + //unset($out[$key]); } $multi[$key][] = $value; } elseif (!empty($value)) { diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index bb71e1456..abcb7d0f4 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -1244,6 +1244,43 @@ class XmlTest extends CakeTestCase { ) ); $this->assertEqual($result, $expected); + + $text = '
'; + $xml = new Xml($text); + $result = $xml->toArray(); + $expected = array( + 'Main' => array( + 'First' => array( + array('label' => 'first type node 1'), + array('label' => 'first type node 2') + ), + 'Second' => array('label'=>'second type node') + ) + ); + $this->assertIdentical($result,$expected); + + $text = '
'; + $xml = new Xml($text); + $result = $xml->toArray(); + $expected = array( + 'Main' => array( + 'First' => array( + array('label' => 'first type node 1'), + array('label' => 'first type node 2') + ), + 'Second' => array('label'=>'second type node'), + 'Collection' => array( + 'Fifth' => array('label' => 'fifth type node'), + 'Third' => array( + array('label' => 'third type node 1'), + array('label' => 'third type node 2'), + array('label' => 'third type node 3'), + ), + 'Fourth' => array('label' => 'fourth type node'), + ) + ) + ); + $this->assertIdentical($result,$expected); } /** * testAppend method From abefca759a0305b2d945b68aff312a067fa6390b Mon Sep 17 00:00:00 2001 From: predominant Date: Fri, 26 Mar 2010 22:51:58 +1100 Subject: [PATCH 14/14] Fix $host not being defined on SessionHelper. --- cake/libs/session.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cake/libs/session.php b/cake/libs/session.php index d6a856392..a2568d157 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -123,6 +123,13 @@ class CakeSession extends Object { * @access protected */ var $_started = false; +/** + * Hostname + * + * @var string + * @access public + */ + var $host = null; /** * Constructor. *