Skip to content

Commit

Permalink
Merge pull request #1623 from bar/php54-afterFind
Browse files Browse the repository at this point in the history
Update afterFind() callback signature to be PHP5.4+ compliant.
  • Loading branch information
ADmad committed Sep 10, 2013
2 parents 994a5b0 + 0a52061 commit e77a751
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -275,7 +275,7 @@ protected function _addJoin(Model $Model, $query, $field, $aliasField, $locale)
* @param boolean $primary Did the find originate on $model.
* @return array Modified results
*/
public function afterFind(Model $Model, $results, $primary) {
public function afterFind(Model $Model, $results, $primary = false) {
$Model->virtualFields = $this->runtime[$Model->alias]['virtualFields'];
$this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array();
$locale = $this->_getLocale($Model);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Model.php
Expand Up @@ -3392,12 +3392,12 @@ public function joinModel($assoc, $keys = array()) {
* Called before each find operation. Return false if you want to halt the find
* call, otherwise return the (modified) query data.
*
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
* @param array $query Data used to execute this query, i.e. conditions, order, etc.
* @return mixed true if the operation should continue, false if it should abort; or, modified
* $queryData to continue with new $queryData
* $query to continue with new $query
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforefind
*/
public function beforeFind($queryData) {
public function beforeFind($query) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/ModelBehavior.php
Expand Up @@ -132,7 +132,7 @@ public function beforeFind(Model $model, $query) {
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
* @return mixed An array value will replace the value of $results - any other value will be ignored.
*/
public function afterFind(Model $model, $results, $primary) {
public function afterFind(Model $model, $results, $primary = false) {
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
Expand Up @@ -84,7 +84,7 @@ public function beforeFind(Model $model, $query) {
* @param boolean $primary
* @return void
*/
public function afterFind(Model $model, $results, $primary) {
public function afterFind(Model $model, $results, $primary = false) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterFind']) || $settings['afterFind'] === 'off') {
return parent::afterFind($model, $results, $primary);
Expand Down

0 comments on commit e77a751

Please sign in to comment.