Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move check out of the loop, and allow nulls.

Refs #2341
  • Loading branch information...
commit a8bc91610486f763c94498a798056ced3c773419 1 parent d238d8c
@markstory markstory authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/Cake/Model/Model.php
View
15 lib/Cake/Model/Model.php
@@ -2815,16 +2815,17 @@ protected function _findThreaded($state, $query, $results = array()) {
$return = $idMap = array();
$ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey);
+ if (isset($results[0][$this->alias]) && !array_key_exists('parent_id', $results[0][$this->alias])) {
+ trigger_error(
+ __d('cake_dev', 'You cannot use find("threaded") on models without a "parent_id" field.'),
+ E_USER_WARNING
+ );
+ return $return;
+ }
+
foreach ($results as $result) {
$result['children'] = array();
$id = $result[$this->alias][$this->primaryKey];
- if (!isset($result[$this->alias]['parent_id'])) {
- trigger_error(
- __d('cake_dev', 'You cannot use find("threaded") on models without a "parent_id" field.'),
- E_USER_WARNING
- );
- return $return;
- }
$parentId = $result[$this->alias]['parent_id'];
if (isset($idMap[$id]['children'])) {
$idMap[$id] = array_merge($result, (array)$idMap[$id]);

0 comments on commit a8bc916

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