Merge pull request #3749 from civicrm/4.4
[civicrm-core.git] / CRM / Utils / API / ReloadOption.php
index 4b7577f5154d0c4ccec4a606c817a5959a46d6c0..c1fa5583aee109b5d01e95fd14ecafbba99f7e15 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  * @endcode
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  */
 
 require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_ReloadOption
+ */
 class CRM_Utils_API_ReloadOption implements API_Wrapper {
 
   /**
@@ -72,7 +76,7 @@ class CRM_Utils_API_ReloadOption implements API_Wrapper {
    */
   public function toApiOutput($apiRequest, $result) {
     $reloadMode = NULL;
-    if ($apiRequest['action'] === 'create' && isset($apiRequest['params'], $apiRequest['params']['options']$apiRequest['params']['options']['reload'])) {
+    if ($apiRequest['action'] === 'create' && isset($apiRequest['params'], $apiRequest['params']['options']) && is_array($apiRequest['params']['options']) && isset($apiRequest['params']['options']['reload'])) {
       if (!CRM_Utils_Array::value('is_error', $result, FALSE)) {
         $reloadMode = $apiRequest['params']['options']['reload'];
       }
@@ -82,6 +86,7 @@ class CRM_Utils_API_ReloadOption implements API_Wrapper {
       case NULL:
       case '0':
       case 'null':
+      case '':
         return $result;
 
       case '1':
@@ -106,7 +111,7 @@ class CRM_Utils_API_ReloadOption implements API_Wrapper {
         return $result;
 
       default:
-        throw new API_Exception("Unknown reload mode");
+        throw new API_Exception("Unknown reload mode " . $reloadMode);
     }
   }