Merge pull request #13267 from seamuslee001/copywrite_year_update
[civicrm-core.git] / CRM / Core / Error.php
index cffb07980b6a8e65459f5c42d00f4f9711fca1cd..163a1b44d3be97becc043098d084b55665635074 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -30,7 +30,7 @@
  * PEAR_ErrorStack and use that framework
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 
 require_once 'PEAR/ErrorStack.php';
@@ -106,7 +106,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
    * @param bool $throwPEAR_Error
    * @param string $stackClass
    *
-   * @return object
+   * @return CRM_Core_Error
    */
   public static function &singleton($package = NULL, $msgCallback = FALSE, $contextCallback = FALSE, $throwPEAR_Error = FALSE, $stackClass = 'PEAR_ErrorStack') {
     if (self::$_singleton === NULL) {
@@ -149,6 +149,9 @@ class CRM_Core_Error extends PEAR_ErrorStack {
       $message = implode($separator, $message);
       return $message;
     }
+    elseif (is_a($error, 'Civi\Payment\Exception\PaymentProcessorException')) {
+      return $error->getMessage();
+    }
     return NULL;
   }
 
@@ -326,7 +329,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
    */
   public static function fatal($message = NULL, $code = NULL, $email = NULL) {
     $vars = array(
-      'message' => htmlspecialchars($message),
+      'message' => $message,
       'code' => $code,
     );
 
@@ -1027,6 +1030,19 @@ class CRM_Core_Error extends PEAR_ErrorStack {
     return FALSE;
   }
 
+  /**
+   * Output a deprecated function warning to log file.  Deprecated class:function is automatically generated from calling function.
+   *
+   * @param $newMethod
+   *   description of new method (eg. "buildOptions() method in the appropriate BAO object").
+   */
+  public static function deprecatedFunctionWarning($newMethod) {
+    $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
+    $callerFunction = isset($dbt[1]['function']) ? $dbt[1]['function'] : NULL;
+    $callerClass = isset($dbt[1]['class']) ? $dbt[1]['class'] : NULL;
+    Civi::log()->warning("Deprecated function $callerClass::$callerFunction, use $newMethod.", array('civi.tag' => 'deprecated'));
+  }
+
 }
 
 $e = new PEAR_ErrorStack('CRM');