From 2d81d25f410ec9c2527fab92c769e72e04134a0e Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 27 Jan 2010 11:08:04 -0500 Subject: [PATCH 1/6] Fixing issue where webroot paths would be incorrect when using a virtual host setup and no mod_rewrite. An additional app/webroot would be appended. Incorrect tests updated. Fixes #259 --- cake/dispatcher.php | 17 ++++++++++------- cake/tests/cases/dispatcher.test.php | 14 +++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 7c241473c..3aa8b9510 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -367,21 +367,24 @@ class Dispatcher extends Object { $this->webroot = $base .'/'; return $base; } - $file = '/' . basename($baseUrl); - $base = dirname($baseUrl); - if ($base === DS || $base === '.') { - $base = ''; - } - $this->webroot = $base .'/'; + $file = '/' . basename($baseUrl); + $base = dirname($baseUrl); + if ($base === DS || $base === '.') { + $base = ''; + } + $this->webroot = $base .'/'; + + if (!empty($base)) { if (strpos($this->webroot, $dir) === false) { $this->webroot .= $dir . '/' ; } if (strpos($this->webroot, $webroot) === false) { $this->webroot .= $webroot . '/'; } - return $base . $file; + } + return $base . $file; } /** * Restructure params in case we're serving a plugin. diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 98f6312fb..f7da2949b 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1103,7 +1103,7 @@ class DispatcherTest extends CakeTestCase { $result = $Dispatcher->baseUrl(); $expected = '/index.php'; $this->assertEqual($expected, $result); - $expectedWebroot = '/app/webroot/'; + $expectedWebroot = '/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php'); @@ -1174,12 +1174,12 @@ class DispatcherTest extends CakeTestCase { */ function testMissingController() { $Dispatcher =& new TestDispatcher(); - Configure::write('App.baseUrl','/index.php'); + Configure::write('App.baseUrl', '/index.php'); $url = 'some_controller/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('missingController', array(array( 'className' => 'SomeControllerController', - 'webroot' => '/app/webroot/', + 'webroot' => '/', 'url' => 'some_controller/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1201,7 +1201,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('privateAction', array(array( 'className' => 'SomePagesController', 'action' => '_protected', - 'webroot' => '/app/webroot/', + 'webroot' => '/', 'url' => 'some_pages/_protected/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1215,7 +1215,7 @@ class DispatcherTest extends CakeTestCase { */ function testMissingAction() { $Dispatcher =& new TestDispatcher(); - Configure::write('App.baseUrl','/index.php'); + Configure::write('App.baseUrl', '/index.php'); $url = 'some_pages/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return'=> 1)); @@ -1223,7 +1223,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'home', - 'webroot' => '/app/webroot/', + 'webroot' => '/', 'url' => '/index.php/some_pages/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1238,7 +1238,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'redirect', - 'webroot' => '/app/webroot/', + 'webroot' => '/', 'url' => '/index.php/some_pages/redirect/param:value/param2:value2', 'base' => '/index.php' ))); From 7cfb5aba8ddcba05fe9d55a3182efd5477d0905a Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 29 Jan 2010 11:21:37 -0500 Subject: [PATCH 2/6] Minor refactor of Model::_deleteLinks to improve readability. --- cake/libs/model/model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 78be07d47..1d82dbaca 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1825,14 +1825,15 @@ class Model extends Overloadable { */ function _deleteLinks($id) { foreach ($this->hasAndBelongsToMany as $assoc => $data) { - $records = $this->{$data['with']}->find('all', array( - 'conditions' => array_merge(array($this->{$data['with']}->escapeField($data['foreignKey']) => $id)), - 'fields' => $this->{$data['with']}->primaryKey, + $joinModel = $data['with']; + $records = $this->{$joinModel}->find('all', array( + 'conditions' => array_merge(array($this->{$joinModel}->escapeField($data['foreignKey']) => $id)), + 'fields' => $this->{$joinModel}->primaryKey, 'recursive' => -1 )); if (!empty($records)) { foreach ($records as $record) { - $this->{$data['with']}->delete($record[$this->{$data['with']}->alias][$this->{$data['with']}->primaryKey]); + $this->{$joinModel}->delete($record[$this->{$joinModel}->alias][$this->{$joinModel}->primaryKey]); } } } From 7ac87d8543dfbdf0e8b087524f647e81fe3b814b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 29 Jan 2010 21:35:00 -0500 Subject: [PATCH 3/6] Updating links on home.ctp to point at github and lighthouse. --- cake/libs/view/pages/home.ctp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index 61c427c60..c8534b115 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -26,7 +26,7 @@ if (Configure::read() == 0): endif; ?>

- + 0): Debugger::checkSessionKey(); @@ -136,8 +136,10 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
  • irc.freenode.net #cakephp
  • -
  • -
  • +
  • +
  • +
  • +
  • From be7ddfb972a1fc508c3e4b0d8c78494923bc20e2 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 29 Jan 2010 21:54:54 -0500 Subject: [PATCH 4/6] Updating version numbers to 1.2.6 --- cake/VERSION.txt | 2 +- cake/config/config.php | 2 +- cake/libs/view/pages/home.ctp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/VERSION.txt b/cake/VERSION.txt index 3a1f10eae..7e099ec5d 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -1 +1 @@ -1.2.5 \ No newline at end of file +1.2.6 \ No newline at end of file diff --git a/cake/config/config.php b/cake/config/config.php index f4f248de0..fff46b1a1 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -22,5 +22,5 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -return $config['Cake.version'] = '1.2.5'; +return $config['Cake.version'] = '1.2.6'; ?> \ No newline at end of file diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index c8534b115..38db9ba3f 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -26,7 +26,7 @@ if (Configure::read() == 0): endif; ?>

    - + 0): Debugger::checkSessionKey(); From 8d382d9168e98140367e908d1855e70292b71f5f Mon Sep 17 00:00:00 2001 From: predominant Date: Tue, 2 Feb 2010 09:13:52 +1100 Subject: [PATCH 5/6] Fixes #288. TextHelper truncation not playing nice with html in ending. --- cake/libs/view/helpers/text.php | 3 +-- cake/tests/cases/libs/view/helpers/text.test.php | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/text.php b/cake/libs/view/helpers/text.php index 737681ef9..37d25ac8b 100644 --- a/cake/libs/view/helpers/text.php +++ b/cake/libs/view/helpers/text.php @@ -168,7 +168,7 @@ class TextHelper extends AppHelper { if (mb_strlen(preg_replace('/<.*?>/', '', $text)) <= $length) { return $text; } - $totalLength = mb_strlen($ending); + $totalLength = mb_strlen(strip_tags($ending)); $openTags = array(); $truncate = ''; preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER); @@ -210,7 +210,6 @@ class TextHelper extends AppHelper { break; } } - } else { if (mb_strlen($text) <= $length) { return $text; diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php index 283e17df0..6aa35d21d 100644 --- a/cake/tests/cases/libs/view/helpers/text.test.php +++ b/cake/tests/cases/libs/view/helpers/text.test.php @@ -100,7 +100,9 @@ class TextHelperTest extends CakeTestCase { $this->assertIdentical($this->Text->{$m}($text7, 255), $text7); $this->assertIdentical($this->Text->{$m}($text7, 15), 'El moño está...'); $this->assertIdentical($this->Text->{$m}($text8, 15), 'Vive la R'.chr(195).chr(169).'pu...'); - + $this->assertIdentical($this->Text->{$m}($text1, 25, 'Read more'), 'The quick brown Read more'); + $this->assertIdentical($this->Text->{$m}($text1, 25, 'Read more', true, true), 'The quick brown Read more'); + if ($this->method == 'truncate') { $this->method = 'trim'; $this->testTruncate(); From 205c95ef65e3a41cfef6ab11ffa1fa044e967470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Perras?= Date: Tue, 2 Feb 2010 11:45:57 -0500 Subject: [PATCH 6/6] Fix array_values() warning when using Tree Behavior under certain situations. In TreeBehavior::_setParent(), if the $Model->find('first') returned false, then array_values() would throw a warning. --- cake/libs/model/behaviors/tree.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index addd8c6c2..126f5aac1 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -808,11 +808,16 @@ class TreeBehavior extends ModelBehavior { $this->__sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); $this->__sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created); } else { - $parentNode = array_values($Model->find('first', array( + $values = $Model->find('first', array( 'conditions' => array($scope, $Model->escapeField() => $parentId), 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive - ))); + )); + + if ($values === false) { + return false; + } + $parentNode = array_values($values); if (empty($parentNode) || empty($parentNode[0])) { return false;