From 3551c924bdbe5b68e4374eff13929549c0caba57 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 24 Mar 2011 22:13:37 +0100 Subject: [PATCH] improved handling when no public entities are available --- lib/Controller/EntityController.php | 9 +++------ lib/View/JSON.php | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Controller/EntityController.php b/lib/Controller/EntityController.php index a2044e6..690286b 100644 --- a/lib/Controller/EntityController.php +++ b/lib/Controller/EntityController.php @@ -61,11 +61,8 @@ class EntityController extends Controller { throw new \Exception('No entity found with UUID: ' . $uuid, 404); } } - elseif ($publicEntities = $this->filter(array('public' => TRUE))) { // public entities - return array('entities' => $publicEntities); - } - else { // no public entities available - return array('entities' => array()); + else { // public entities + return array('entities' => $this->filter(array('public' => TRUE))); } } @@ -121,7 +118,7 @@ class EntityController extends Controller { }); // send new cookie to browser - setcookie('vz_uuids', implode(';', array_unique($uuids)), 0, '/'); // TODO correct path + setcookie('vz_uuids', implode(';', array_unique($uuids)), 0, '/'); // TODO correct path } /** diff --git a/lib/View/JSON.php b/lib/View/JSON.php index e8b5f6f..53b2b33 100644 --- a/lib/View/JSON.php +++ b/lib/View/JSON.php @@ -240,6 +240,10 @@ class JSON extends View { * */ protected function addArray($data, &$refNode) { + if (is_null($refNode)) { + $refNode = array(); + } + foreach ($data as $index => $value) { if ($value instanceof Util\JSON || is_array($value)) { $this->addArray($value, $refNode[$index]);