Merge pull request #15285 from colemanw/jsencode
[civicrm-core.git] / CRM / Contact / Page / ImageFile.php
index f5ec151d0deef320f0e59cf0b614f8c7162bdf2f..a567356a53cf35afa016939fd710e37a58f9be28 100644 (file)
@@ -32,7 +32,9 @@
  */
 class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
   /**
-   * @var int Time to live (seconds).
+   * Time to live (seconds).
+   *
+   * @var int
    *
    * 12 hours: 12 * 60 * 60 = 43200
    */
@@ -45,14 +47,14 @@ class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
    */
   public function run() {
     if (!preg_match('/^[^\/]+\.(jpg|jpeg|png|gif)$/i', $_GET['photo'])) {
-      CRM_Core_Error::fatal('Malformed photo name');
+      throw new CRM_Core_Exception(ts('Malformed photo name'));
     }
 
     // FIXME Optimize performance of image_url query
     $sql = "SELECT id FROM civicrm_contact WHERE image_url like %1;";
-    $params = array(
-      1 => array("%" . $_GET['photo'], 'String'),
-    );
+    $params = [
+      1 => ["%" . $_GET['photo'], 'String'],
+    ];
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     $cid = NULL;
     while ($dao->fetch()) {
@@ -69,7 +71,7 @@ class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
       CRM_Utils_System::civiExit();
     }
     else {
-      CRM_Core_Error::fatal('Photo does not exist');
+      throw new CRM_Core_Exception(ts('Photo does not exist'));
     }
   }