mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge branch '2.1' into 2.2
This commit is contained in:
commit
8da42dfcfa
3 changed files with 32 additions and 2 deletions
|
@ -186,7 +186,7 @@ class ConsoleOutput {
|
||||||
return preg_replace('#</?(?:' . $tags . ')>#', '', $text);
|
return preg_replace('#</?(?:' . $tags . ')>#', '', $text);
|
||||||
}
|
}
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'/<(?<tag>[a-z0-9-_]+)>(?<text>.*?)<\/(\1)>/ims', array($this, '_replaceTags'), $text
|
'/<(?P<tag>[a-z0-9-_]+)>(?P<text>.*?)<\/(\1)>/ims', array($this, '_replaceTags'), $text
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ class PaginatorComponent extends Component {
|
||||||
$count = $object->find('count', array_merge($parameters, $extra));
|
$count = $object->find('count', array_merge($parameters, $extra));
|
||||||
}
|
}
|
||||||
$pageCount = intval(ceil($count / $limit));
|
$pageCount = intval(ceil($count / $limit));
|
||||||
|
$page = max(min($page, $pageCount), 1);
|
||||||
|
|
||||||
$paging = array(
|
$paging = array(
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
|
@ -375,7 +376,7 @@ class PaginatorComponent extends Component {
|
||||||
if (empty($options['limit']) || $options['limit'] < 1) {
|
if (empty($options['limit']) || $options['limit'] < 1) {
|
||||||
$options['limit'] = 1;
|
$options['limit'] = 1;
|
||||||
}
|
}
|
||||||
$options['limit'] = min((int)$options['limit'], $options['maxLimit']);
|
$options['limit'] = min($options['limit'], $options['maxLimit']);
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -804,6 +804,35 @@ class PaginatorComponentTest extends CakeTestCase {
|
||||||
$this->assertEquals('asc', $result['order']['model.something']);
|
$this->assertEquals('asc', $result['order']['model.something']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that a really large page number gets clamped to the max page size.
|
||||||
|
*/
|
||||||
|
public function testOutOfRangePageNumberGetsClamped() {
|
||||||
|
$Controller = new PaginatorTestController($this->request);
|
||||||
|
$Controller->uses = array('PaginatorControllerPost');
|
||||||
|
$Controller->params['named'] = array(
|
||||||
|
'page' => 3000,
|
||||||
|
);
|
||||||
|
$Controller->constructClasses();
|
||||||
|
$Controller->PaginatorControllerPost->recursive = 0;
|
||||||
|
$Controller->Paginator->paginate('PaginatorControllerPost');
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
$Controller->request->params['paging']['PaginatorControllerPost']['page'],
|
||||||
|
'Super big page number should be capped to max number of pages'
|
||||||
|
);
|
||||||
|
|
||||||
|
$Controller->paginate = array(
|
||||||
|
'conditions' => array('PaginatorControllerPost.id >' => 100)
|
||||||
|
);
|
||||||
|
$Controller->Paginator->paginate('PaginatorControllerPost');
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
$Controller->request->params['paging']['PaginatorControllerPost']['page'],
|
||||||
|
'Page number should not be 0'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that fields not in whitelist won't be part of order conditions.
|
* test that fields not in whitelist won't be part of order conditions.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue