From d986953449842adf87d8fba71c7d24295b5ea135 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Tue, 12 Mar 2013 10:16:18 +0100 Subject: [PATCH 01/21] add CONTRIBUTING.md --- CONTRIBUTING.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..0b05c2754 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,73 @@ +# How to contribute + +CakePHP loves to welcome your contributions. There are several ways to help out: +* Create a ticket in Lighthouse, if you have found a bug +* Write testcases for open bug tickets +* Write patches for open bug/feature tickets, preferably with testcases included +* Contribute to the [documentation](https://github.com/cakephp/docs) + +There are a few guidelines that we need contributors to follow so that we have a +chance of keeping on top of things. + +## Getting Started + +* Make sure you have a [GitHub account](https://github.com/signup/free) +* Submit a ticket for your issue, assuming one does not already exist. + * Clearly describe the issue including steps to reproduce when it is a bug. + * Make sure you fill in the earliest version that you know has the issue. +* Fork the repository on GitHub. + +## Making Changes + +* Create a topic branch from where you want to base your work. + * This is usually the master branch + * Only target release branches if you are certain your fix must be on that + branch + * To quickly create a topic branch based on master; `git branch + master/my_contribution master` then checkout the new branch with `git + checkout master/my_contribution`. Better avoid working directly on the + `master` branch, to avoid conflicts if you pull in updates from origin. +* Make commits of logical units. +* Check for unnecessary whitespace with `git diff --check` before committing. +* Use descriptive commit messages and reference the #ticket number +* Core testcases should continue to pass. You can run tests locally or enable + [travis-ci](https://travis-ci.org/) for your fork, so all tests and codesniffs + will be executed. +* Your work should apply the CakePHP coding standards. + +## Which branch to base the work + +* Bugfix branches will be based on master. +* New features that are backwards compatible will be based on next minor release + branch. +* New features or other non-BC changes will go in the next major release branch. + +## Submitting Changes + +* Push your changes to a topic branch in your fork of the repository. +* Submit a pull request to the repository in the cakephp organization, with the + correct target branch. + +## Testcases and codesniffer + +CakePHP tests requires [PHPUnit](http://www.phpunit.de/manual/current/en/installation.html) +3.5 or higher. To run the testcases locally use the following command: + + ./lib/Cake/Console/cake test core AllTests --stderr + +To run the sniffs for CakePHP coding standards + + phpcs -p --extensions=php --standard=CakePHP ./lib/Cake + +Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer) +repository to setup the CakePHP standard. The README contains installation info +for the sniff and phpcs. + + +# Additional Resources + +* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html) +* [Bug tracker](https://cakephp.lighthouseapp.com/projects/42648-cakephp) +* [General GitHub documentation](http://help.github.com/) +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) +* #cakephp IRC channel on freenode.org From ec56d828b0615e10aaf22e3bd07cf6cb80a88775 Mon Sep 17 00:00:00 2001 From: Graham Watson Date: Thu, 14 Mar 2013 16:48:12 -0300 Subject: [PATCH 02/21] Fix incorrect default meridian Prevent the default meridian from being changed from 'pm' to 'am' when the default time is in a 12-hour format between 1:00pm and 11:59pm and both a minute interval and default minute value are specified. --- lib/Cake/View/Helper/FormHelper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 0733cfd90..75cca4234 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2383,11 +2383,16 @@ class FormHelper extends AppHelper { $current->setDate($year, $month, $day); } if ($hour !== null) { + if ($timeFormat == '12') { + $hour = date('H', strtotime("$hour:$min $meridian")); + } $current->setTime($hour, $min); } $change = (round($min * (1 / $interval)) * $interval) - $min; $current->modify($change > 0 ? "+$change minutes" : "$change minutes"); $newTime = explode(' ', $current->format('Y m d H i a')); + $format = ($timeFormat == '12') ? 'Y m d h i a' : 'Y m d H i a'; + $newTime = explode(' ', $current->format($format)); list($year, $month, $day, $hour, $min, $meridian) = $newTime; } From 2ac545291af53f6e93a5fc2e7dbe900ba9d9ccb0 Mon Sep 17 00:00:00 2001 From: Graham Watson Date: Thu, 14 Mar 2013 16:58:13 -0300 Subject: [PATCH 03/21] Fix incorrect default meridian Forgot to remove a line --- lib/Cake/View/Helper/FormHelper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 75cca4234..ba3b3003c 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2390,7 +2390,6 @@ class FormHelper extends AppHelper { } $change = (round($min * (1 / $interval)) * $interval) - $min; $current->modify($change > 0 ? "+$change minutes" : "$change minutes"); - $newTime = explode(' ', $current->format('Y m d H i a')); $format = ($timeFormat == '12') ? 'Y m d h i a' : 'Y m d H i a'; $newTime = explode(' ', $current->format($format)); list($year, $month, $day, $hour, $min, $meridian) = $newTime; From 99c41e0af4d864c5a13a46659f52f9db90b97ad0 Mon Sep 17 00:00:00 2001 From: Sethrin Date: Fri, 15 Mar 2013 04:11:22 -0700 Subject: [PATCH 04/21] Improvement to Validator::uuid Properly matches version digit and variant digit, based on RFC4122 --- lib/Cake/Utility/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 43347e37d..d5c8a6029 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -776,7 +776,7 @@ class Validation { * @return boolean Success */ public static function uuid($check) { - $regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i'; + $regex = '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/'; return self::_check($check, $regex); } From 83de70efcf2f4f0f65bb0cf513f7e73927947bea Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 17 Mar 2013 18:14:24 -0400 Subject: [PATCH 05/21] Tighten Canadian postal code validation. D, F, I, O, Q, U should not be valid anywhere in a canadian postal code. Fixes #3708 --- lib/Cake/Test/Case/Utility/ValidationTest.php | 4 ++++ lib/Cake/Utility/Validation.php | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 647e46261..2af075603 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -2126,6 +2126,10 @@ class ValidationTest extends CakeTestCase { $this->assertFalse(Validation::postal('BAA 0ABC', null, 'ca')); $this->assertFalse(Validation::postal('B2A AABC', null, 'ca')); $this->assertFalse(Validation::postal('B2A 2AB', null, 'ca')); + $this->assertFalse(Validation::postal('K1A 1D1', null, 'ca')); + $this->assertFalse(Validation::postal('K1O 1Q1', null, 'ca')); + $this->assertFalse(Validation::postal('A1A 1U1', null, 'ca')); + $this->assertFalse(Validation::postal('A1F 1B1', null, 'ca')); $this->assertTrue(Validation::postal('X0A 0A2', null, 'ca')); $this->assertTrue(Validation::postal('G4V 4C3', null, 'ca')); diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 91f828ab5..accd571df 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -646,7 +646,9 @@ class Validation { $regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i'; break; case 'ca': - $regex = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]\\b\\z/i'; + $district = '[ABCEGHJKLMNPRSTVYX]'; + $letters = '[ABCEGHJKLMNPRSTVWXYZ]'; + $regex = "/\\A\\b{$district}[0-9]{$letters} [0-9]{$letters}[0-9]\\b\\z/i"; break; case 'it': case 'de': From 89100f947682ae0cdbc383a3dfbd152c5da884d5 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Mon, 18 Mar 2013 11:12:28 +0100 Subject: [PATCH 06/21] fix coding standards --- .../Case/TestSuite/CakeTestFixtureTest.php | 14 ++-- .../TestSuite/CakeTestSuiteDispatcherTest.php | 70 ++++++++++++------- .../TestSuite/CakeTestSuiteDispatcher.php | 4 +- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index 394195520..7684bdf9c 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -437,7 +437,7 @@ class CakeTestFixtureTest extends CakeTestCase { $this->insertMulti['fields'] = $fields; $this->insertMulti['values'] = $values; $this->insertMulti['fields_values'] = array(); - foreach($values as $record) { + foreach ($values as $record) { $this->insertMulti['fields_values'][] = array_combine($fields, $record); } return true; @@ -467,18 +467,18 @@ class CakeTestFixtureTest extends CakeTestCase { $this->assertEquals($expected, $this->insertMulti['values']); $expected = array( array( - 'name' => 'Mark Doe', - 'email' => 'mark.doe@email.com', + 'name' => 'Mark Doe', + 'email' => 'mark.doe@email.com', 'age' => null ), array( - 'name' => 'John Doe', - 'email' => 'john.doe@email.com', + 'name' => 'John Doe', + 'email' => 'john.doe@email.com', 'age' => 20 ), array( - 'name' => 'Jane Doe', - 'email' => 'jane.doe@email.com', + 'name' => 'Jane Doe', + 'email' => 'jane.doe@email.com', 'age' => 30 ), ); diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php index 9969370f1..a736223c8 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php @@ -1,38 +1,58 @@ vendors = App::path('vendors'); - $this->includePath = ini_get('include_path'); - } + public function setUp() { + $this->vendors = App::path('vendors'); + $this->includePath = ini_get('include_path'); + } - public function tearDown() { - App::build(array('Vendor' => $this->vendors), App::RESET); - ini_set('include_path', $this->includePath); - } + public function tearDown() { + App::build(array('Vendor' => $this->vendors), App::RESET); + ini_set('include_path', $this->includePath); + } - protected function clearPaths() { - App::build(array('Vendor' => array('junk')), App::RESET); - ini_set('include_path', 'junk'); - } + protected function clearPaths() { + App::build(array('Vendor' => array('junk')), App::RESET); + ini_set('include_path', 'junk'); + } - public function testLoadTestFramework() { - $dispatcher = new CakeTestSuiteDispatcher(); + public function testLoadTestFramework() { + $dispatcher = new CakeTestSuiteDispatcher(); - $this->assertTrue($dispatcher->loadTestFramework()); + $this->assertTrue($dispatcher->loadTestFramework()); - $this->clearPaths(); + $this->clearPaths(); - $exception = null; + $exception = null; - try { - $dispatcher->loadTestFramework(); - } catch (Exception $ex) { - $exception = $ex; - } + try { + $dispatcher->loadTestFramework(); + } catch (Exception $ex) { + $exception = $ex; + } - $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning"); - } + $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning"); + } -} +} \ No newline at end of file diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 86dfd3895..88db1a509 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -138,14 +138,14 @@ class CakeTestSuiteDispatcher { */ public function loadTestFramework() { foreach (App::path('vendors') as $vendor) { - $vendor = rtrim($vendor, DS); + $vendor = rtrim($vendor, DS); if (is_dir($vendor . DS . 'PHPUnit')) { ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path')); break; } } - return (include('PHPUnit' . DS . 'Autoload.php')) !== false; + return (include ('PHPUnit' . DS . 'Autoload.php')) !== false; } /** From 99fba8c60184fe538e84245046596ff2063e527c Mon Sep 17 00:00:00 2001 From: Ceeram Date: Mon, 18 Mar 2013 11:38:50 +0100 Subject: [PATCH 07/21] more coding standards fixes, minor rectaoring of testcase --- .../TestSuite/CakeTestSuiteDispatcherTest.php | 35 +++++++++++++------ .../TestSuite/CakeTestSuiteDispatcher.php | 2 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php index a736223c8..9d04226f8 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php @@ -22,37 +22,50 @@ class CakeTestSuiteDispatcherTest extends CakeTestCase { +/** + * setUp method + * + * @return void + */ public function setUp() { $this->vendors = App::path('vendors'); $this->includePath = ini_get('include_path'); } +/** + * tearDown method + * + * @return void + */ public function tearDown() { App::build(array('Vendor' => $this->vendors), App::RESET); ini_set('include_path', $this->includePath); } - protected function clearPaths() { +/** + * Helper method to set vendor path + * + * @return void + */ + protected function _clearPaths() { App::build(array('Vendor' => array('junk')), App::RESET); ini_set('include_path', 'junk'); } +/** + * testLoadTestFramework method + * + * @return void + */ public function testLoadTestFramework() { $dispatcher = new CakeTestSuiteDispatcher(); $this->assertTrue($dispatcher->loadTestFramework()); - $this->clearPaths(); + $this->_clearPaths(); - $exception = null; - - try { - $dispatcher->loadTestFramework(); - } catch (Exception $ex) { - $exception = $ex; - } - - $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning"); + $this->setExpectedException('PHPUnit_Framework_Error_Warning'); + $dispatcher->loadTestFramework(); } } \ No newline at end of file diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 88db1a509..214cdb859 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -138,7 +138,7 @@ class CakeTestSuiteDispatcher { */ public function loadTestFramework() { foreach (App::path('vendors') as $vendor) { - $vendor = rtrim($vendor, DS); + $vendor = rtrim($vendor, DS); if (is_dir($vendor . DS . 'PHPUnit')) { ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path')); break; From 6002d6913d7bfbd0fa2b69ce79964b36ee985342 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 18 Mar 2013 17:17:16 +0100 Subject: [PATCH 08/21] correct doc block --- lib/Cake/Network/Email/CakeEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 92446ff25..6268570ec 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1424,7 +1424,7 @@ class CakeEmail { /** * Render the body of the email. * - * @param string $content Content to render + * @param array $content Content to render * @return array Email body ready to be sent */ protected function _render($content) { From e38892ff06c0066c572f8251953a091041246814 Mon Sep 17 00:00:00 2001 From: Graham Watson Date: Mon, 18 Mar 2013 13:34:14 -0300 Subject: [PATCH 09/21] Change equal operators to identity operators --- lib/Cake/View/Helper/FormHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index ba3b3003c..2bb2c54de 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2383,14 +2383,14 @@ class FormHelper extends AppHelper { $current->setDate($year, $month, $day); } if ($hour !== null) { - if ($timeFormat == '12') { + if ($timeFormat === '12') { $hour = date('H', strtotime("$hour:$min $meridian")); } $current->setTime($hour, $min); } $change = (round($min * (1 / $interval)) * $interval) - $min; $current->modify($change > 0 ? "+$change minutes" : "$change minutes"); - $format = ($timeFormat == '12') ? 'Y m d h i a' : 'Y m d H i a'; + $format = ($timeFormat === '12') ? 'Y m d h i a' : 'Y m d H i a'; $newTime = explode(' ', $current->format($format)); list($year, $month, $day, $hour, $min, $meridian) = $newTime; } From 1ebb2ed0a0d2d710e54fb436c943ceef3ff37fcd Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 18 Mar 2013 21:17:24 -0400 Subject: [PATCH 10/21] Fix coding style. --- lib/Cake/View/View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index f3de05497..24dc5c2e4 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -560,7 +560,7 @@ class View extends Object { //@codingStandardsIgnoreStart @unlink($filename); //@codingStandardsIgnoreEnd - unset ($out); + unset($out); return false; } else { if ($this->layout === 'xml') { From ca10c49e2158dba1a47ff4d9a299927c48787adc Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 18 Mar 2013 21:27:00 -0400 Subject: [PATCH 11/21] Re-use existing string instead of making another one. --- lib/Cake/View/View.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 24dc5c2e4..ff492b839 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -566,8 +566,7 @@ class View extends Object { if ($this->layout === 'xml') { header('Content-type: text/xml'); } - $commentLength = strlen(''); - return substr($out, $commentLength); + return substr($out, strlen($match[0])); } } } From 37532389d670e4045072d20b6af5ef21b5df8aae Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 18 Mar 2013 21:37:38 -0400 Subject: [PATCH 12/21] Add test cases for GH-1182 Add tests for afternoon times with an interval and 12 hour time format. --- .../Test/Case/View/Helper/FormHelperTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index b95f21ce5..4988cd39f 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2276,6 +2276,33 @@ class FormHelperTest extends CakeTestCase { $this->assertContains('', $result); } +/** + * Test interval & timeFormat = 12 + * + * @return void + */ + public function testInputTimeWithIntervalAnd12HourFormat() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 5, + 'selected' => array('hour' => '4', 'min' => '30', 'meridian' => 'pm') + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => '12', + 'interval' => 5, + 'selected' => '2013-04-19 16:30:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * test form->input() with datetime, date and time types * From 2f799961404ed7fda48fbdbca15df08d15a86f0b Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 18 Mar 2013 21:38:02 -0400 Subject: [PATCH 13/21] Remove unused code and remove strict type checks. Remove some unused code around manipulating hours. Also allow the timeFormat option to be specified as either a string or an int. Both types should be accepted and treated as equivalent. --- lib/Cake/View/Helper/FormHelper.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 2bb2c54de..e7374a40f 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2383,9 +2383,6 @@ class FormHelper extends AppHelper { $current->setDate($year, $month, $day); } if ($hour !== null) { - if ($timeFormat === '12') { - $hour = date('H', strtotime("$hour:$min $meridian")); - } $current->setTime($hour, $min); } $change = (round($min * (1 / $interval)) * $interval) - $min; @@ -2511,14 +2508,14 @@ class FormHelper extends AppHelper { if (!empty($timeFormat)) { $time = explode(':', $days[1]); - if ($time[0] >= '12' && $timeFormat === '12') { + if ($time[0] >= 12 && $timeFormat == 12) { $meridian = 'pm'; - } elseif ($time[0] === '00' && $timeFormat === '12') { + } elseif ($time[0] === '00' && $timeFormat == 12) { $time[0] = 12; } elseif ($time[0] >= 12) { $meridian = 'pm'; } - if ($time[0] == 0 && $timeFormat === '12') { + if ($time[0] == 0 && $timeFormat == 12) { $time[0] = 12; } $hour = $min = null; From 729ef8fe58b98a0b0ab96ae25b7aa55b061f2516 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 19 Mar 2013 21:02:27 -0400 Subject: [PATCH 14/21] Fix default null not being reflected by SqlServer Apply patch from 'Josh Rehm' to fix null default values from being stomped on when reflecting table schema. Fixes #3615 --- .../Model/Datasource/Database/Sqlserver.php | 10 ++++++++-- .../Datasource/Database/SqlserverTest.php | 20 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 92f133674..941630c6c 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -216,14 +216,20 @@ class Sqlserver extends DboSource { $fields[$field] = array( 'type' => $this->column($column), 'null' => ($column->Null === 'YES' ? true : false), - 'default' => preg_replace("/^[(]{1,2}'?([^')]*)?'?[)]{1,2}$/", "$1", $column->Default), + 'default' => $column->Default, 'length' => $this->length($column), 'key' => ($column->Key == '1') ? 'primary' : false ); if ($fields[$field]['default'] === 'null') { $fields[$field]['default'] = null; - } else { + } + if ($fields[$field]['default'] !== null) { + $fields[$field]['default'] = preg_replace( + "/^[(]{1,2}'?([^')]*)?'?[)]{1,2}$/", + "$1", + $fields[$field]['default'] + ); $this->value($fields[$field]['default'], $fields[$field]['type']); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php index 4c5fe5699..e2611699d 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php @@ -448,7 +448,16 @@ class SqlserverTest extends CakeTestCase { 'Length' => 72, 'Null' => 'NO', 'Size' => '' - ) + ), + (object)array( + 'Default' => null, + 'Field' => 'parent_id', + 'Key' => '0', + 'Type' => 'bigint', + 'Length' => 8, + 'Null' => 'YES', + 'Size' => '0', + ), )); $this->db->executeResultsStack = array($SqlserverTableDescription); $dummyModel = $this->model; @@ -478,9 +487,16 @@ class SqlserverTest extends CakeTestCase { 'default' => '', 'length' => 36, 'key' => 'primary' - ) + ), + 'parent_id' => array( + 'type' => 'biginteger', + 'null' => true, + 'default' => null, + 'length' => 8, + ), ); $this->assertEquals($expected, $result); + $this->assertSame($expected['parent_id'], $result['parent_id']); } /** From d1d3bcff041428242b519407d513ee39ccdbb01f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 20 Mar 2013 20:37:13 -0400 Subject: [PATCH 15/21] Move import to top of file. --- lib/Cake/Console/Shell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 175b879ee..d90de4490 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -22,6 +22,7 @@ App::uses('ConsoleOutput', 'Console'); App::uses('ConsoleInput', 'Console'); App::uses('ConsoleInputSubcommand', 'Console'); App::uses('ConsoleOptionParser', 'Console'); +App::uses('ClassRegistry', 'Utility'); App::uses('File', 'Utility'); /** @@ -234,7 +235,6 @@ class Shell extends Object { if (empty($this->uses)) { return false; } - App::uses('ClassRegistry', 'Utility'); $uses = is_array($this->uses) ? $this->uses : array($this->uses); From 819029e1f3235c075e688af53845021f742007ab Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 20 Mar 2013 21:26:42 -0400 Subject: [PATCH 16/21] Only load the object cache when requested. Instead of loading a cache key that may not exist on every request, it should only be loaded when required. Fixes #3717 --- lib/Cake/Core/App.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index ae9942553..e36b10a24 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -425,6 +425,10 @@ class App { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects */ public static function objects($type, $path = null, $cache = true) { + if (empty(self::$_objects) && $cache === true) { + self::$_objects = (array)Cache::read('object_map', '_cake_core_'); + } + $extension = '/\.php$/'; $includeDirectories = false; $name = $type; @@ -451,10 +455,6 @@ class App { $name = $type . str_replace(DS, '', $path); } - if (empty(self::$_objects) && $cache === true) { - self::$_objects = Cache::read('object_map', '_cake_core_'); - } - $cacheLocation = empty($plugin) ? 'app' : $plugin; if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) { @@ -768,7 +768,6 @@ class App { */ public static function init() { self::$_map += (array)Cache::read('file_map', '_cake_core_'); - self::$_objects += (array)Cache::read('object_map', '_cake_core_'); register_shutdown_function(array('App', 'shutdown')); } @@ -896,7 +895,6 @@ class App { if (self::$_objectCacheChange) { Cache::write('object_map', self::$_objects, '_cake_core_'); } - self::_checkFatalError(); } From 5d6a6fa203eeaf32d87c77276f38fbb3451561a0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 21 Mar 2013 21:12:21 -0400 Subject: [PATCH 17/21] Fix error when generating Xml. Fix warnings/un-escaped entities with deeply nested elements. Fixes #3718 --- lib/Cake/Test/Case/Utility/XmlTest.php | 35 ++++++++++++++++++++++++++ lib/Cake/Utility/Xml.php | 5 ++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 9a2b5cc79..14557f36d 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -459,6 +459,41 @@ XML; } } +/** + * Test that there are not unterminated errors when building xml + * + * @return void + */ + public function testFromArrayUnterminatedError() { + $data = array( + 'product_ID' => 'GENERT-DL', + 'deeplink' => 'http://example.com/deep', + 'image_URL' => 'http://example.com/image', + 'thumbnail_image_URL' => 'http://example.com/thumb', + 'brand' => 'Malte Lange & Co', + 'availability' => 'in stock', + 'authors' =>array( + 'author' => array('Malte Lange & Co') + ) + ); + $xml = Xml::fromArray(array('products' => $data), 'tags'); + $expected = << + + GENERT-DL + http://example.com/deep + http://example.com/image + http://example.com/thumb + Malte Lange & Co + in stock + + Malte Lange & Co + + +XML; + $this->assertXmlStringEqualsXmlString($expected, $xml->asXML()); + } + /** * testToArray method * diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index f822abea8..9fd609578 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -300,10 +300,9 @@ class Xml { $childValue = (string)$value; } + $child = $dom->createElement($key); if ($childValue) { - $child = $dom->createElement($key, $childValue); - } else { - $child = $dom->createElement($key); + $child->appendChild($dom->createTextNode($childValue)); } if ($childNS) { $child->setAttribute('xmlns', $childNS); From 386be52c71a34621d60373a29c19f178864f0223 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 22 Mar 2013 21:01:20 -0400 Subject: [PATCH 18/21] Be compatible with PHPUnit installed with composer. Doing a class_exists() check is a simple way to check for PHPUnit being installed via an autoloader. It also keeps things compatible with a Vendor dir installation. Fixes #3721 --- lib/Cake/TestSuite/CakeTestSuiteDispatcher.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 214cdb859..636f13b57 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -137,6 +137,9 @@ class CakeTestSuiteDispatcher { * @return boolean true if found, false otherwise */ public function loadTestFramework() { + if (class_exists('PHPUnit_Framework_TestCase')) { + return true; + } foreach (App::path('vendors') as $vendor) { $vendor = rtrim($vendor, DS); if (is_dir($vendor . DS . 'PHPUnit')) { @@ -144,8 +147,8 @@ class CakeTestSuiteDispatcher { break; } } - - return (include ('PHPUnit' . DS . 'Autoload.php')) !== false; + include 'PHPUnit' . DS . 'Autoload.php'; + return class_exists('PHPUnit_Framework_TestCase'); } /** From a7708c914ff1bc12232cb8650723c69f9ab26f33 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 22 Mar 2013 21:36:11 -0400 Subject: [PATCH 19/21] Remove test case that is no longer useful. It is impossible for the current test to ever fail in the test suite, as PHPUnit will always be loaded. --- .../TestSuite/CakeTestSuiteDispatcherTest.php | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php deleted file mode 100644 index 9d04226f8..000000000 --- a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php +++ /dev/null @@ -1,71 +0,0 @@ -vendors = App::path('vendors'); - $this->includePath = ini_get('include_path'); - } - -/** - * tearDown method - * - * @return void - */ - public function tearDown() { - App::build(array('Vendor' => $this->vendors), App::RESET); - ini_set('include_path', $this->includePath); - } - -/** - * Helper method to set vendor path - * - * @return void - */ - protected function _clearPaths() { - App::build(array('Vendor' => array('junk')), App::RESET); - ini_set('include_path', 'junk'); - } - -/** - * testLoadTestFramework method - * - * @return void - */ - public function testLoadTestFramework() { - $dispatcher = new CakeTestSuiteDispatcher(); - - $this->assertTrue($dispatcher->loadTestFramework()); - - $this->_clearPaths(); - - $this->setExpectedException('PHPUnit_Framework_Error_Warning'); - $dispatcher->loadTestFramework(); - } - -} \ No newline at end of file From 3a1ff36d5eb63fb3c880a84f799ed7516614ba75 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 25 Mar 2013 13:06:38 +0100 Subject: [PATCH 20/21] correct coding standards --- lib/Cake/Test/Case/Utility/XmlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 14557f36d..9849984ac 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -472,7 +472,7 @@ XML; 'thumbnail_image_URL' => 'http://example.com/thumb', 'brand' => 'Malte Lange & Co', 'availability' => 'in stock', - 'authors' =>array( + 'authors' => array( 'author' => array('Malte Lange & Co') ) ); From 9d367e1add2bd9beb309d2ac7ba80e6ed06cf374 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 27 Mar 2013 00:12:24 +0530 Subject: [PATCH 21/21] Fix docblock of bake template --- .../Console/Templates/default/actions/controller_actions.ctp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp index a0c16a5a3..3e7ef27c1 100644 --- a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp +++ b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp @@ -133,7 +133,6 @@ * delete method * * @throws NotFoundException - * @throws MethodNotAllowedException * @param string $id * @return void */