Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove the $state === 'after' condition.

Can only be before / after.
  • Loading branch information...
commit b64c7e3e8405708cde381043ba2f6dec689c425f 1 parent 1c080b2
@kimegede kimegede authored
Showing with 56 additions and 56 deletions.
  1. +56 −56 lib/Cake/Model/Model.php
View
112 lib/Cake/Model/Model.php
@@ -2818,9 +2818,9 @@ public function buildQuery($type = 'first', $query = array()) {
protected function _findAll($state, $query, $results = array()) {
if ($state === 'before') {
return $query;
- } elseif ($state === 'after') {
- return $results;
}
+
+ return $results;
}
/**
@@ -2836,12 +2836,12 @@ protected function _findFirst($state, $query, $results = array()) {
if ($state === 'before') {
$query['limit'] = 1;
return $query;
- } elseif ($state === 'after') {
- if (empty($results[0])) {
- return array();
- }
- return $results[0];
}
+
+ if (empty($results[0])) {
+ return array();
+ }
+ return $results[0];
}
/**
@@ -2877,17 +2877,17 @@ protected function _findCount($state, $query, $results = array()) {
));
}
return $query;
- } elseif ($state === 'after') {
- foreach (array(0, $this->alias) as $key) {
- if (isset($results[0][$key]['count'])) {
- if ($query['group']) {
- return count($results);
- }
- return intval($results[0][$key]['count']);
+ }
+
+ foreach (array(0, $this->alias) as $key) {
+ if (isset($results[0][$key]['count'])) {
+ if ($query['group']) {
+ return count($results);
}
+ return intval($results[0][$key]['count']);
}
- return false;
}
+ return false;
}
/**
@@ -2939,12 +2939,12 @@ protected function _findList($state, $query, $results = array()) {
}
list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list;
return $query;
- } elseif ($state === 'after') {
- if (empty($results)) {
- return array();
- }
- return Hash::combine($results, $query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']);
}
+
+ if (empty($results)) {
+ return array();
+ }
+ return Hash::combine($results, $query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']);
}
/**
@@ -2974,34 +2974,34 @@ protected function _findNeighbors($state, $query, $results = array()) {
$query['field'] = $field;
$query['value'] = $value;
return $query;
- } elseif ($state === 'after') {
- extract($query);
- unset($query['conditions'][$field . ' <']);
- $return = array();
- if (isset($results[0])) {
- $prevVal = Hash::get($results[0], $field);
- $query['conditions'][$field . ' >='] = $prevVal;
- $query['conditions'][$field . ' !='] = $value;
- $query['limit'] = 2;
- } else {
- $return['prev'] = null;
- $query['conditions'][$field . ' >'] = $value;
- $query['limit'] = 1;
- }
- $query['order'] = $field . ' ASC';
- $neighbors = $this->find('all', $query);
- if (!array_key_exists('prev', $return)) {
- $return['prev'] = isset($neighbors[0]) ? $neighbors[0] : null;
- }
- if (count($neighbors) === 2) {
- $return['next'] = $neighbors[1];
- } elseif (count($neighbors) === 1 && !$return['prev']) {
- $return['next'] = $neighbors[0];
- } else {
- $return['next'] = null;
- }
- return $return;
}
+
+ extract($query);
+ unset($query['conditions'][$field . ' <']);
+ $return = array();
+ if (isset($results[0])) {
+ $prevVal = Hash::get($results[0], $field);
+ $query['conditions'][$field . ' >='] = $prevVal;
+ $query['conditions'][$field . ' !='] = $value;
+ $query['limit'] = 2;
+ } else {
+ $return['prev'] = null;
+ $query['conditions'][$field . ' >'] = $value;
+ $query['limit'] = 1;
+ }
+ $query['order'] = $field . ' ASC';
+ $neighbors = $this->find('all', $query);
+ if (!array_key_exists('prev', $return)) {
+ $return['prev'] = isset($neighbors[0]) ? $neighbors[0] : null;
+ }
+ if (count($neighbors) === 2) {
+ $return['next'] = $neighbors[1];
+ } elseif (count($neighbors) === 1 && !$return['prev']) {
+ $return['next'] = $neighbors[0];
+ } else {
+ $return['next'] = null;
+ }
+ return $return;
}
/**
@@ -3016,16 +3016,16 @@ protected function _findNeighbors($state, $query, $results = array()) {
protected function _findThreaded($state, $query, $results = array()) {
if ($state === 'before') {
return $query;
- } elseif ($state === 'after') {
- $parent = 'parent_id';
- if (isset($query['parent'])) {
- $parent = $query['parent'];
- }
- return Hash::nest($results, array(
- 'idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey,
- 'parentPath' => '{n}.' . $this->alias . '.' . $parent
- ));
}
+
+ $parent = 'parent_id';
+ if (isset($query['parent'])) {
+ $parent = $query['parent'];
+ }
+ return Hash::nest($results, array(
+ 'idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey,
+ 'parentPath' => '{n}.' . $this->alias . '.' . $parent
+ ));
}
/**

0 comments on commit b64c7e3

Please sign in to comment.
Something went wrong with that request. Please try again.