Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed mergeAssociation scrubQueryData to be protected.

  • Loading branch information...
commit e9390985cadbd5e29131be8187f9827a3fc6dcf0 1 parent 689c7ff
@jrbasso jrbasso authored
View
6 lib/Cake/Model/Datasource/Database/Oracle.php
@@ -1101,16 +1101,16 @@ public function queryAssociation($model, &$linkModel, $type, $association, $asso
if (empty($merge) && !isset($row[$association])) {
$row[$association] = $merge;
} else {
- $this->__mergeAssociation($resultSet[$i], $merge, $association, $type);
+ $this->_mergeAssociation($resultSet[$i], $merge, $association, $type);
}
} else {
- $this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
+ $this->_mergeAssociation($resultSet[$i], $fetch, $association, $type);
}
$resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
} else {
$tempArray[0][$association] = false;
- $this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type);
+ $this->_mergeAssociation($resultSet[$i], $tempArray, $association, $type);
}
}
}
View
16 lib/Cake/Model/Datasource/DboSource.php
@@ -1016,7 +1016,7 @@ public function create(Model $model, $fields = null, $values = null) {
* @return mixed boolean false on error/failure. An array of results on success.
*/
public function read(Model $model, $queryData = array(), $recursive = null) {
- $queryData = $this->__scrubQueryData($queryData);
+ $queryData = $this->_scrubQueryData($queryData);
$null = null;
$array = array();
@@ -1279,17 +1279,17 @@ public function queryAssociation($model, &$linkModel, $type, $association, $asso
if (empty($merge) && !isset($row[$association])) {
$row[$association] = $merge;
} else {
- $this->__mergeAssociation($row, $merge, $association, $type);
+ $this->_mergeAssociation($row, $merge, $association, $type);
}
} else {
- $this->__mergeAssociation($row, $fetch, $association, $type, $selfJoin);
+ $this->_mergeAssociation($row, $fetch, $association, $type, $selfJoin);
}
if (isset($row[$association])) {
$row[$association] = $linkModel->afterFind($row[$association], false);
}
} else {
$tempArray[0][$association] = false;
- $this->__mergeAssociation($row, $tempArray, $association, $type, $selfJoin);
+ $this->_mergeAssociation($row, $tempArray, $association, $type, $selfJoin);
}
}
}
@@ -1362,7 +1362,7 @@ protected function _mergeHasMany(&$resultSet, $merge, $association, $model, $lin
* @param boolean $selfJoin
* @return void
*/
- function __mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
+ protected function _mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
if (isset($merge[0]) && !isset($merge[0][$association])) {
$association = Inflector::pluralize($association);
}
@@ -1446,8 +1446,8 @@ function __mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = fa
* @return mixed
*/
public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
- $queryData = $this->__scrubQueryData($queryData);
- $assocData = $this->__scrubQueryData($assocData);
+ $queryData = $this->_scrubQueryData($queryData);
+ $assocData = $this->_scrubQueryData($assocData);
$modelAlias = $model->alias;
if (empty($queryData['fields'])) {
@@ -2123,7 +2123,7 @@ public function resolveKey(Model $model, $key, $assoc = null) {
* @param array $data
* @return array
*/
- function __scrubQueryData($data) {
+ protected function _scrubQueryData($data) {
static $base = null;
if ($base === null) {
$base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array());
View
4 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
@@ -1010,7 +1010,9 @@ function &_prepareAssociationQuery($model, &$queryData, $binding) {
$linkModel = $model->{$className};
$external = isset($assocData['external']);
- $queryData = $this->Dbo->__scrubQueryData($queryData);
+ $reflection = new ReflectionMethod($this->Dbo, '_scrubQueryData');
+ $reflection->setAccessible(true);
+ $queryData = $reflection->invokeArgs($this->Dbo, array($queryData));
$result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external'));
return $result;
View
20 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -92,6 +92,10 @@ function _execute(\$sql) {
public function getLastQuery() {
return \$this->simulated[count(\$this->simulated) - 1];
}
+
+ public function mergeAssociation(&\$data, &\$merge, \$association, \$type, \$selfJoin = false) {
+ return parent::_mergeAssociation(\$data, \$merge, \$association, \$type, \$selfJoin);
+ }
}");
}
@@ -177,7 +181,7 @@ public function testMergeAssociations() {
'updated' => '2007-03-17 01:18:31'
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'Topic', 'hasOne');
+ $this->testDb->mergeAssociation($data, $merge, 'Topic', 'hasOne');
$this->assertEqual($data, $expected);
$data = array('Article2' => array(
@@ -200,7 +204,7 @@ public function testMergeAssociations() {
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'User2', 'belongsTo');
+ $this->testDb->mergeAssociation($data, $merge, 'User2', 'belongsTo');
$this->assertEqual($data, $expected);
$data = array(
@@ -215,7 +219,7 @@ public function testMergeAssociations() {
),
'Comment' => array()
);
- $this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
+ $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany');
$this->assertEqual($data, $expected);
$data = array(
@@ -248,7 +252,7 @@ public function testMergeAssociations() {
)
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
+ $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany');
$this->assertEqual($data, $expected);
$data = array(
@@ -293,7 +297,7 @@ public function testMergeAssociations() {
)
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
+ $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany');
$this->assertEqual($data, $expected);
$data = array(
@@ -348,7 +352,7 @@ public function testMergeAssociations() {
)
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
+ $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany');
$this->assertEqual($data, $expected);
$data = array(
@@ -389,7 +393,7 @@ public function testMergeAssociations() {
)
)
);
- $this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasAndBelongsToMany');
+ $this->testDb->mergeAssociation($data, $merge, 'Tag', 'hasAndBelongsToMany');
$this->assertEqual($data, $expected);
$data = array(
@@ -420,7 +424,7 @@ public function testMergeAssociations() {
),
'Tag' => array('id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
);
- $this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasOne');
+ $this->testDb->mergeAssociation($data, $merge, 'Tag', 'hasOne');
$this->assertEqual($data, $expected);
}
Please sign in to comment.
Something went wrong with that request. Please try again.