]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/System.php
Merge pull request #13480 from Raroun/fix_13457
[friendica.git] / src / Core / System.php
index 48a4ce614168ad0eadf3c1a0ad493ce12b12a157..197e7b2ae6acd43af9785bf490bf4531e2e08b87 100644 (file)
@@ -311,27 +311,24 @@ class System
         * Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
         * of $st and an optional text <message> of $message and terminates the current process.
         *
-        * @param        $st
+        * @param mixed  $status
         * @param string $message
         * @throws \Exception
+        * @deprecated since 2023.09 Use BaseModule->httpExit() instead
         */
-       public static function xmlExit($st, $message = '')
+       public static function xmlExit($status, string $message = '')
        {
-               $result = ['status' => $st];
+               $result = ['status' => $status];
 
                if ($message != '') {
                        $result['message'] = $message;
                }
 
-               if ($st) {
-                       Logger::notice('xml_status returning non_zero: ' . $st . " message=" . $message);
+               if ($status) {
+                       Logger::notice('xml_status returning non_zero: ' . $status . " message=" . $message);
                }
 
-               DI::apiResponse()->setType(Response::TYPE_XML);
-               DI::apiResponse()->addContent(XML::fromArray(['result' => $result]));
-               self::echoResponse(DI::apiResponse()->generate());
-
-               self::exit();
+               self::httpExit(XML::fromArray(['result' => $result]), Response::TYPE_XML);
        }
 
        /**
@@ -373,6 +370,9 @@ class System
                self::exit();
        }
 
+       /**
+        * @deprecated since 2023.09 Use BaseModule->jsonError instead
+        */
        public static function jsonError($httpCode, $content, $content_type = 'application/json')
        {
                if ($httpCode >= 400) {
@@ -392,14 +392,12 @@ class System
         * @param mixed   $content      The input content
         * @param string  $content_type Type of the input (Default: 'application/json')
         * @param integer $options      JSON options
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws InternalServerErrorException
+        * @deprecated since 2023.09 Use BaseModule->jsonExit instead
         */
-       public static function jsonExit($content, $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) {
-               DI::apiResponse()->setType(Response::TYPE_JSON, $content_type);
-               DI::apiResponse()->addContent(json_encode($content, $options));
-               self::echoResponse(DI::apiResponse()->generate());
-
-               self::exit();
+       public static function jsonExit($content, string $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
+       {
+               self::httpExit(json_encode($content, $options), Response::TYPE_JSON, $content_type);
        }
 
        /**