Slimplify functions down as per Tim's review comments
authorSeamus Lee <seamuslee001@gmail.com>
Sat, 8 Jun 2019 03:07:16 +0000 (13:07 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Sat, 8 Jun 2019 07:38:39 +0000 (17:38 +1000)
CRM/Utils/System.php
CRM/Utils/System/Base.php
CRM/Utils/System/WordPress.php

index 96bec632d6e8ccaeb15f39916091059478147cf2..d52e3d5ef446f4ffe07da7835480b070bc1524ac 100644 (file)
@@ -1867,8 +1867,7 @@ class CRM_Utils_System {
    * @param \Psr\Http\Message\ResponseInterface $response
    */
   public static function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
-    $config = CRM_Core_Config::singleton();
-    $config->userSystem->sendResponse($response);
+    $config = CRM_Core_Config::singleton()->userSystem->sendResponse($response);
   }
 
 }
index 6bc5290ac947c2206afad34c80ce3641c504a73a..e913fee17cca7f08710a9b9effdb1f97994a5c34 100644 (file)
@@ -955,12 +955,9 @@ abstract class CRM_Utils_System_Base {
       // PHP 5.4+
       http_response_code($response->getStatusCode());
     }
-    else {
-      // @todo should we remove this given we are no longer supporting < PHP 5.6 however keeping
-      // in for the moment for compatability with the original AssetBuilder code.
-      header('X-PHP-Response-Code: ' . $response->getStatusCode(), TRUE, $reponse->getStatusCode());
+    foreach ($response->getHeaders() as $name => $values) {
+      CRM_Utils_System::setHttpHeader($name, implode(', ', (array) $values));
     }
-    CRM_Utils_System::setHttpHeader('Content-Type', $response->getHeaderLine('Content-Type'));
     echo $response->getBody();
     CRM_Utils_System::civiExit();
   }
index 31ce2eccc9f144aca08f45a4bea180b5012043a0..a74e1e3de02b4d216b5c2a29d7ccb141d4528498 100644 (file)
@@ -871,16 +871,9 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
   public function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
     // use WordPress function status_header to ensure 404 response is sent
     status_header($response->getStatusCode());
-    if (function_exists('http_response_code')) {
-      // PHP 5.4+
-      http_response_code($response->getStatusCode());
+    foreach ($response->getHeaders() as $name => $values) {
+      CRM_Utils_System::setHttpHeader($name, implode(', ', (array) $values));
     }
-    else {
-      // @todo should we remove this given we are no longer supporting < PHP 5.6 however keeping
-      // in for the moment for compatability with the original AssetBuilder code.
-      header('X-PHP-Response-Code: ' . $response->getStatusCode(), TRUE, $response->getStatusCode());
-    }
-    CRM_Utils_System::setHttpHeader('Content-Type', $response->getHeaderLine('Content-Type'));
     echo $response->getBody();
     CRM_Utils_System::civiExit();
   }