]> source.dussan.org Git - nextcloud-server.git/commitdiff
getData() always needs to return an array, backport of #6988
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 10 Feb 2014 14:55:47 +0000 (15:55 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 10 Feb 2014 14:55:47 +0000 (15:55 +0100)
lib/ocs/result.php

index 8ab378d79c530091387f0c61ab393c68243a1620..8bd51add7e64677d6109d05a1764349d46f915b2 100644 (file)
@@ -29,7 +29,13 @@ class OC_OCS_Result{
         * @param $data mixed the data to return
         */
        public function __construct($data=null, $code=100, $message=null) {
-               $this->data = $data;
+               if ($data === null) {
+                       $this->data = array();
+               } elseif (!is_array($data)) {
+                       $this->data = array($this->data);
+               } else {
+                       $this->data = $data;
+               }
                $this->statusCode = $code;
                $this->message = $message;
        }
@@ -49,7 +55,7 @@ class OC_OCS_Result{
        public function setItemsPerPage(int $items) {
                $this->perPage = $items;
        }
-       
+
        /**
         * get the status code
         * @return int
@@ -57,7 +63,7 @@ class OC_OCS_Result{
        public function getStatusCode() {
                return $this->statusCode;
        }
-       
+
        /**
         * get the meta data for the result
         * @return array
@@ -76,15 +82,15 @@ class OC_OCS_Result{
                return $meta;
 
        }
-       
+
        /**
         * get the result data
-        * @return array|string|int 
+        * @return array
         */
        public function getData() {
                return $this->data;
        }
-       
+
        /**
         * return bool if the method succedded
         * @return bool