Use PSR-7 responses in UserExportGdprAction
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 Aug 2021 13:37:58 +0000 (15:37 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 11 Aug 2021 14:29:52 +0000 (16:29 +0200)
wcfsetup/install/files/lib/acp/action/UserExportGdprAction.class.php

index 568865fe1b7c935a52529e207864c7491985ada4..299a19cf7a117d6f8bdc61cb5c0a0b2903dfab2e 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace wcf\acp\action;
 
+use Laminas\Diactoros\Response\JsonResponse;
 use wcf\action\AbstractAction;
 use wcf\data\package\PackageCache;
 use wcf\data\user\cover\photo\DefaultUserCoverPhoto;
@@ -240,16 +241,16 @@ class UserExportGdprAction extends AbstractAction
 
         $this->data['@@generatedAt'] = TIME_NOW;
 
-        @\header('Content-type: application/json; charset=UTF-8');
-        @\header('Content-disposition: attachment; filename="user-export-gdpr-' . $this->user->userID . '.json"');
-
-        HeaderUtil::sendNoCacheHeaders();
-
-        echo \json_encode($this->data, \JSON_PRETTY_PRINT);
-
         $this->executed();
 
-        exit;
+        return HeaderUtil::withNoCacheHeaders(new JsonResponse(
+            $this->data,
+            200,
+            [
+                'content-disposition' => 'attachment; filename="user-export-gdpr-' . $this->user->userID . '.json"',
+            ],
+            JsonResponse::DEFAULT_JSON_FLAGS | \JSON_PRETTY_PRINT
+        ));
     }
 
     /**