Merge branch 'master' into 2.5

This commit is contained in:
mark_story 2013-12-01 21:37:37 -05:00
commit 8578708e76
5 changed files with 60 additions and 15 deletions

View file

@ -212,9 +212,6 @@ class PaginatorComponent extends Component {
$pageCount = intval(ceil($count / $limit)); $pageCount = intval(ceil($count / $limit));
$requestedPage = $page; $requestedPage = $page;
$page = max(min($page, $pageCount), 1); $page = max(min($page, $pageCount), 1);
if ($requestedPage > $page) {
throw new NotFoundException();
}
$paging = array( $paging = array(
'page' => $page, 'page' => $page,
@ -237,6 +234,10 @@ class PaginatorComponent extends Component {
array($object->alias => $paging) array($object->alias => $paging)
); );
if ($requestedPage > $page) {
throw new NotFoundException();
}
if ( if (
!in_array('Paginator', $this->Controller->helpers) && !in_array('Paginator', $this->Controller->helpers) &&
!array_key_exists('Paginator', $this->Controller->helpers) !array_key_exists('Paginator', $this->Controller->helpers)

View file

@ -919,7 +919,6 @@ class PaginatorComponentTest extends CakeTestCase {
/** /**
* testOutOfRangePageNumberAndPageCountZero * testOutOfRangePageNumberAndPageCountZero
* *
* @expectedException NotFoundException
* @return void * @return void
*/ */
public function testOutOfRangePageNumberAndPageCountZero() { public function testOutOfRangePageNumberAndPageCountZero() {
@ -933,7 +932,17 @@ class PaginatorComponentTest extends CakeTestCase {
$Controller->paginate = array( $Controller->paginate = array(
'conditions' => array('PaginatorControllerPost.id >' => 100) 'conditions' => array('PaginatorControllerPost.id >' => 100)
); );
$Controller->Paginator->paginate('PaginatorControllerPost');
try {
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->fail();
} catch (NotFoundException $e) {
$this->assertEquals(
1,
$Controller->request->params['paging']['PaginatorControllerPost']['page'],
'Page number should not be 0'
);
}
} }
/** /**

View file

@ -142,7 +142,27 @@ class TextHelperTest extends CakeTestCase {
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
}
/**
* Test mixing URLs and Email addresses in one confusing string.
*
* @return void
*/
public function testAutoLinkMixed() {
$text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
$expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' .
'http://example.com/store?email=mark@example.com</a> and email.';
$result = $this->Text->autoLink($text);
$this->assertEquals($expected, $result);
}
/**
* test autoLink() and options.
*
* @return void
*/
public function testAutoLinkOptions() {
$text = 'This is a test text with URL http://www.cakephp.org'; $text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
$result = $this->Text->autoLink($text, array('class' => 'link')); $result = $this->Text->autoLink($text, array('class' => 'link'));
@ -246,7 +266,7 @@ class TextHelperTest extends CakeTestCase {
array( array(
'Text with a partial http://www.küchenschöhn-not-working.de URL', 'Text with a partial http://www.küchenschöhn-not-working.de URL',
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL' 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
) ),
); );
} }
@ -343,10 +363,25 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->autoLinkUrls($text); $result = $this->Text->autoLinkUrls($text);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$text = 'Text with email@example.com address'; $text = 'email@example.com address';
$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address'; $expected = '<a href="mailto:email@example.com">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text); $result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result); $this->assertEquals($expected, $result);
$text = 'email@example.com address';
$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text);
$this->assertEquals($expected, $result);
$text = '(email@example.com) address';
$expected = '(<a href="mailto:email@example.com">email@example.com</a>) address';
$result = $this->Text->autoLinkEmails($text);
$this->assertEquals($expected, $result);
$text = 'Text with email@example.com address';
$expected = 'Text with <a href="mailto:email@example.com">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text);
$this->assertEquals($expected, $result);
$text = "Text with o'hare._-bob@example.com address"; $text = "Text with o'hare._-bob@example.com address";
$expected = 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address'; $expected = 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address';
@ -354,19 +389,19 @@ class TextHelperTest extends CakeTestCase {
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$text = 'Text with email@example.com address'; $text = 'Text with email@example.com address';
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address'; $expected = 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text, array('class' => 'link')); $result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
$this->assertRegExp('#^' . $expected . '$#', $result); $this->assertEquals($expected, $result);
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address'; $text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address'; $expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
$result = $this->Text->autoLinkEmails($text); $result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result); $this->assertEquals($expected, $result);
$text = 'Text with me@subdomain.küchenschöhn.de address'; $text = 'Text with me@subdomain.küchenschöhn.de address';
$expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address'; $expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address';
$result = $this->Text->autoLinkEmails($text); $result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result); $this->assertEquals($expected, $result);
} }
/** /**

View file

@ -187,7 +187,7 @@ class TextHelper extends AppHelper {
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]'; $atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback( $text = preg_replace_callback(
'/(' . $atom . '+(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui', '/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
array(&$this, '_insertPlaceholder'), array(&$this, '_insertPlaceholder'),
$text $text
); );

View file

@ -1095,7 +1095,7 @@ class View extends Object {
* Return all possible paths to find view files in order * Return all possible paths to find view files in order
* *
* @param string $plugin Optional plugin name to scan for view files. * @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached Set to true to force a refresh of view paths. * @param boolean $cached Set to false to force a refresh of view paths. Default true.
* @return array paths * @return array paths
*/ */
protected function _paths($plugin = null, $cached = true) { protected function _paths($plugin = null, $cached = true) {