mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Applying patch from 'farhadi' correcting regular expression when using magic findBy and fields that contain findBy in them. Fixes #6138
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8057 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
779b367d3b
commit
2a139b171c
2 changed files with 9 additions and 2 deletions
|
@ -225,10 +225,10 @@ class DboSource extends DataSource {
|
|||
|
||||
if (strpos(strtolower($args[0]), 'findby') === 0) {
|
||||
$all = false;
|
||||
$field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
|
||||
$field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0]));
|
||||
} else {
|
||||
$all = true;
|
||||
$field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
|
||||
$field = Inflector::underscore(preg_replace('/^findAllBy/i', '', $args[0]));
|
||||
}
|
||||
|
||||
$or = (strpos($field, '_or_') !== false);
|
||||
|
|
|
@ -3106,6 +3106,13 @@ class DboSourceTest extends CakeTestCase {
|
|||
'fields' => null, 'order' => null, 'recursive' => null
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->query('findByFindBy', array('value'), $this->Model);
|
||||
$expected = array('first', array(
|
||||
'conditions' => array('TestModel.find_by' => 'value'),
|
||||
'fields' => null, 'order' => null, 'recursive' => null
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model);
|
||||
$expected = array('all', array(
|
||||
|
|
Loading…
Add table
Reference in a new issue