From 819d9e2cbc23c46537b3620df8789a93f7f3f02a Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 8 Apr 2013 00:26:59 +0530 Subject: [PATCH 1/5] docblock tweaks for apigen --- lib/Cake/Model/Model.php | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 660936cca..61d2c7980 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -643,11 +643,11 @@ class Model extends Object implements CakeEventListener { * * If `$id` is an array it can be used to pass several options into the model. * - * - id - The id to start the model on. - * - table - The table to use for this model. - * - ds - The connection name this model is connected to. - * - name - The name of the model eg. Post. - * - alias - The alias of the model, this is used for registering the instance in the `ClassRegistry`. + * - `id`: The id to start the model on. + * - `table`: The table to use for this model. + * - `ds`: The connection name this model is connected to. + * - `name`: The name of the model eg. Post. + * - `alias`: The alias of the model, this is used for registering the instance in the `ClassRegistry`. * eg. `ParentThread` * * ### Overriding Model's __construct method. @@ -1202,7 +1202,7 @@ class Model extends Object implements CakeEventListener { } /** - * Normalize Xml::toArray() to use in Model::save() + * Normalize `Xml::toArray()` to use in `Model::save()` * * @param array $xml XML as array * @return array @@ -1601,9 +1601,9 @@ class Model extends Object implements CakeEventListener { * If a boolean, indicates whether or not to validate before saving. * If an array, can have following keys: * - * - `validate`: Set to true/false to enable or disable validation. - * - `fieldList`: An array of fields you want to allow for saving. - * - `callbacks`: Set to false to disable callbacks. Using 'before' or 'after' + * - validate: Set to true/false to enable or disable validation. + * - fieldList: An array of fields you want to allow for saving. + * - callbacks: Set to false to disable callbacks. Using 'before' or 'after' * will enable only those callbacks. * * @param array $fieldList List of fields to allow to be saved @@ -1979,7 +1979,7 @@ class Model extends Object implements CakeEventListener { } /** - * Helper method for Model::updateCounterCache(). Checks the fields to be updated for + * Helper method for `Model::updateCounterCache()`. Checks the fields to be updated for * * @param array $data The fields of the record that will be updated * @return array Returns updated foreign key values, along with an 'old' key containing the old @@ -2014,12 +2014,12 @@ class Model extends Object implements CakeEventListener { * * #### Options * - * - validate: Set to false to disable validation, true to validate each record before saving, + * - `validate`: Set to false to disable validation, true to validate each record before saving, * 'first' to validate *all* records before any are saved (default), * or 'only' to only validate the records, but not save them. - * - atomic: If true (default), will attempt to save all records in a single transaction. + * - `atomic`: If true (default), will attempt to save all records in a single transaction. * Should be set to false if database/table does not support transactions. - * - fieldList: Equivalent to the $fieldList parameter in Model::save(). + * - `fieldList`: Equivalent to the $fieldList parameter in Model::save(). * It should be an associate array with model name as key and array of fields as value. Eg. * {{{ * array( @@ -2027,7 +2027,7 @@ class Model extends Object implements CakeEventListener { * 'AssociatedModel' => array('field', 'otherfield') * ) * }}} - * - deep: see saveMany/saveAssociated + * - `deep`: see saveMany/saveAssociated * * @param array $data Record data to save. This can be either a numerically-indexed array (for saving multiple * records of the same type), or an array indexed by association name. @@ -2057,12 +2057,12 @@ class Model extends Object implements CakeEventListener { * * #### Options * - * - validate: Set to false to disable validation, true to validate each record before saving, + * - `validate`: Set to false to disable validation, true to validate each record before saving, * 'first' to validate *all* records before any are saved (default), - * - atomic: If true (default), will attempt to save all records in a single transaction. + * - `atomic`: If true (default), will attempt to save all records in a single transaction. * Should be set to false if database/table does not support transactions. - * - fieldList: Equivalent to the $fieldList parameter in Model::save() - * - deep: If set to true, all associated data will be saved as well. + * - `fieldList`: Equivalent to the $fieldList parameter in Model::save() + * - `deep`: If set to true, all associated data will be saved as well. * * @param array $data Record data to save. This should be a numerically-indexed array * @param array $options Options to use when saving record data, See $options above. @@ -2140,9 +2140,9 @@ class Model extends Object implements CakeEventListener { * * #### Options * - * - atomic: If true (default), returns boolean. If false returns array. - * - fieldList: Equivalent to the $fieldList parameter in Model::save() - * - deep: If set to true, all associated data will be validated as well. + * - `atomic`: If true (default), returns boolean. If false returns array. + * - `fieldList`: Equivalent to the $fieldList parameter in Model::save() + * - `deep`: If set to true, all associated data will be validated as well. * * Warning: This method could potentially change the passed argument `$data`, * If you do not want this to happen, make a copy of `$data` before passing it @@ -2163,11 +2163,11 @@ class Model extends Object implements CakeEventListener { * * #### Options * - * - `validate` Set to `false` to disable validation, `true` to validate each record before saving, + * - `validate`: Set to `false` to disable validation, `true` to validate each record before saving, * 'first' to validate *all* records before any are saved(default), - * - `atomic` If true (default), will attempt to save all records in a single transaction. + * - `atomic`: If true (default), will attempt to save all records in a single transaction. * Should be set to false if database/table does not support transactions. - * - fieldList: Equivalent to the $fieldList parameter in Model::save(). + * - `fieldList`: Equivalent to the $fieldList parameter in Model::save(). * It should be an associate array with model name as key and array of fields as value. Eg. * {{{ * array( @@ -2175,7 +2175,7 @@ class Model extends Object implements CakeEventListener { * 'AssociatedModel' => array('field', 'otherfield') * ) * }}} - * - deep: If set to true, not only directly associated data is saved, but deeper nested associated data as well. + * - `deep`: If set to true, not only directly associated data is saved, but deeper nested associated data as well. * * @param array $data Record data to save. This should be an array indexed by association name. * @param array $options Options to use when saving record data, See $options above. @@ -2347,9 +2347,9 @@ class Model extends Object implements CakeEventListener { * * #### Options * - * - atomic: If true (default), returns boolean. If false returns array. - * - fieldList: Equivalent to the $fieldList parameter in Model::save() - * - deep: If set to true, not only directly associated data , but deeper nested associated data is validated as well. + * - `atomic`: If true (default), returns boolean. If false returns array. + * - `fieldList`: Equivalent to the $fieldList parameter in Model::save() + * - `deep`: If set to true, not only directly associated data , but deeper nested associated data is validated as well. * * Warning: This method could potentially change the passed argument `$data`, * If you do not want this to happen, make a copy of `$data` before passing it @@ -2581,8 +2581,8 @@ class Model extends Object implements CakeEventListener { /** * Returns true if a record with particular ID exists. * - * If $id is not passed it calls Model::getID() to obtain the current record ID, - * and then performs a Model::find('count') on the currently configured datasource + * If $id is not passed it calls `Model::getID()` to obtain the current record ID, + * and then performs a `Model::find('count')` on the currently configured datasource * to ascertain the existence of the record in persistent storage. * * @param integer|string $id ID of record to check for existence From 9cd54bd736f56884aaff1082ef86567fa807139f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 7 Apr 2013 15:00:11 -0400 Subject: [PATCH 2/5] Update version number to 2.3.2 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index bef2d7c84..3043388a4 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.3.1 +2.3.2 From da2f0668e0bf085af5803011b5d6613cb9b73fdc Mon Sep 17 00:00:00 2001 From: Ceeram Date: Mon, 8 Apr 2013 11:24:23 +0200 Subject: [PATCH 3/5] Replace node.js with lighthttpd to avoid socket exceptions --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d75ab91e0..5283442c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,11 +24,7 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test2;' -U postgres -d cakephp_test; fi" - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi" - chmod -R 777 ./app/tmp - - echo "var net = require('net'); - var server = net.createServer(); - server.listen(80, 'localhost'); - console.log('TCP server listening on port 80 at localhost.');" > app/tmp/socket.js - - sudo node ./app/tmp/socket.js & + - sudo apt-get install lighttpd - pear channel-discover pear.cakephp.org - pear install --alldeps cakephp/CakePHP_CodeSniffer - phpenv rehash From 0e646a2a4d16598023d37a96a7dfd5c606ad74b7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 9 Apr 2013 21:30:20 -0400 Subject: [PATCH 4/5] Fix incorrect timestamp values when using fromString() When using fromString() on DateTime objects that were in the global timezone, an incorrect value would be returned. Fixes #3743 --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 15 ++++++++++++++- lib/Cake/Utility/CakeTime.php | 9 +++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 78ab94efa..bcb17d25c 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -846,7 +846,7 @@ class CakeTimeTest extends CakeTestCase { $date = new DateTime('+1 hour', new DateTimeZone('America/New_York')); $result = $this->Time->fromString($date, 'UTC'); $date->setTimezone(new DateTimeZone('UTC')); - $expected = $date->format('U') + $date->getOffset(); + $expected = $date->getTimestamp() + $date->getOffset(); $this->assertWithinMargin($expected, $result, 1); @@ -854,6 +854,7 @@ class CakeTimeTest extends CakeTestCase { $date = new DateTime('+1 hour', new DateTimeZone('America/New_York')); $result = $this->Time->fromString($date, 'Asia/Kuwait'); + $date->setTimezone(new DateTimeZone('Asia/Kuwait')); $expected = $date->format('U') + $date->getOffset(); $this->assertWithinMargin($expected, $result, 1); @@ -861,6 +862,18 @@ class CakeTimeTest extends CakeTestCase { $this->_restoreSystemTimezone(); } +/** + * Test that datetimes in the default timezone are not modified. + * + * @return void + */ + public function testFromStringWithDateTimeNoConversion() { + Configure::write('Config.timezone', date_default_timezone_get()); + $date = new DateTime('2013-04-09'); + $result = $this->Time->fromString($date); + $this->assertEquals($result, $date->getTimestamp()); + } + /** * test converting time specifiers using a time definition localfe file * diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 95da85d84..09698d1aa 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -319,10 +319,15 @@ class CakeTime { if (is_int($dateString) || is_numeric($dateString)) { $date = intval($dateString); - } elseif (is_object($dateString) && $dateString instanceof DateTime) { + } elseif ( + $dateString instanceof DateTime && + $dateString->getTimezone()->getName() != date_default_timezone_get() + ) { $clone = clone $dateString; $clone->setTimezone(new DateTimeZone(date_default_timezone_get())); - $date = (int)$clone->format('U') + $clone->getOffset(); + $date = (int)$clone->getTimestamp() + $clone->getOffset(); + } elseif ($dateString instanceof DateTime) { + $date = (int)$dateString->getTimeStamp(); } else { $date = strtotime($dateString); } From c77c7a734739aa7a099bbb60c36c974e35450bb3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 9 Apr 2013 21:46:51 -0400 Subject: [PATCH 5/5] Fix warning with FormHelper::inputs() introspectModel() can return non-array data sometimes. Casting avoids warnings when forms are generate for models with no or faulty schema() methods. Refs #3602 --- lib/Cake/View/Helper/FormHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index beb191cd2..921b5a2a3 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -845,7 +845,7 @@ class FormHelper extends AppHelper { $modelFields = array(); $model = $this->model(); if ($model) { - $modelFields = array_keys($this->_introspectModel($model, 'fields')); + $modelFields = array_keys((array)$this->_introspectModel($model, 'fields')); } if (is_array($fields)) { if (array_key_exists('legend', $fields) && !in_array('legend', $modelFields)) {