Browse Source

Merge pull request #7406 from cakephp/issue-7290

Make debugInfo methods more resilient.
José Lorenzo Rodríguez 10 years ago
parent
commit
2e2d8f0fc7
2 changed files with 6 additions and 4 deletions
  1. 2 2
      src/ORM/Query.php
  2. 4 2
      src/ORM/Table.php

+ 2 - 2
src/ORM/Query.php

@@ -826,8 +826,8 @@ class Query extends DatabaseQuery implements JsonSerializable
             'buffered' => $this->_useBufferedResults,
             'formatters' => count($this->_formatters),
             'mapReducers' => count($this->_mapReduce),
-            'contain' => $eagerLoader->contain(),
-            'matching' => $eagerLoader->matching(),
+            'contain' => $eagerLoader ? $eagerLoader->contain() : [],
+            'matching' => $eagerLoader ? $eagerLoader->matching() : [],
             'extraOptions' => $this->_options,
             'repository' => $this->_repository
         ];

+ 4 - 2
src/ORM/Table.php

@@ -2203,13 +2203,15 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     public function __debugInfo()
     {
         $conn = $this->connection();
+        $associations = $this->_associations ?: false;
+        $behaviors = $this->_behaviors ?: false;
         return [
             'registryAlias' => $this->registryAlias(),
             'table' => $this->table(),
             'alias' => $this->alias(),
             'entityClass' => $this->entityClass(),
-            'associations' => $this->_associations->keys(),
-            'behaviors' => $this->_behaviors->loaded(),
+            'associations' => $associations ? $associations->keys() : false,
+            'behaviors' => $behaviors ? $behaviors->loaded() : false,
             'defaultConnection' => $this->defaultConnectionName(),
             'connectionName' => $conn ? $conn->configName() : null
         ];