CRM_Core_Page_File - Fix warning when using filename mode
authorTim Otten <totten@civicrm.org>
Fri, 22 Feb 2019 08:22:03 +0000 (00:22 -0800)
committerTim Otten <totten@civicrm.org>
Fri, 22 Feb 2019 08:22:03 +0000 (00:22 -0800)
The idea here is that `id+eid+fcs` and `filename` are two separate modes.
In `filename` mode, you don't need warnings about the missing `fcs`.

CRM/Core/Page/File.php

index 2a9ec348fbada425c99610ce04a1dbac6e8f337d..b13dd9d66a264c10ce13364ed6b885e2e759f689 100644 (file)
@@ -49,17 +49,19 @@ class CRM_Core_Page_File extends CRM_Core_Page {
     if (empty($fileName) && (empty($entityId) || empty($fileId))) {
       CRM_Core_Error::statusBounce("Cannot access file: Must pass either \"Filename\" or the combination of \"Entity ID\" + \"File ID\"");
     }
-    $hash = CRM_Utils_Request::retrieve('fcs', 'Alphanumeric', $this);
-    if (!CRM_Core_BAO_File::validateFileHash($hash, $entityId, $fileId) && empty($fileName)) {
-      CRM_Core_Error::statusBounce('URL for file is not valid');
+
+    if (empty($fileName)) {
+      $hash = CRM_Utils_Request::retrieve('fcs', 'Alphanumeric', $this);
+      if (!CRM_Core_BAO_File::validateFileHash($hash, $entityId, $fileId)) {
+        CRM_Core_Error::statusBounce('URL for file is not valid');
+      }
+
+      list($path, $mimeType) = CRM_Core_BAO_File::path($fileId, $entityId);
     }
-    if (!empty($fileName)) {
+    else {
       $mimeType = '';
       $path = CRM_Core_Config::singleton()->customFileUploadDir . $fileName;
     }
-    else {
-      list($path, $mimeType) = CRM_Core_BAO_File::path($fileId, $entityId);
-    }
     $mimeType = CRM_Utils_Request::retrieveValue('mime-type', 'String', $mimeType, FALSE);
 
     if (!$path) {