(dev/core#178) Redis - Be a little more conservative about sharing error info
[civicrm-core.git] / CRM / Utils / Cache / Redis.php
index 07279d530de987f039fc4f9e3e56a1f6c76bf04f..4c6259a7fdc338b18c07f8f662ab6c4bd693111f 100644 (file)
@@ -117,7 +117,13 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface {
    */
   public function set($key, &$value) {
     if (!$this->_cache->set($this->_prefix . $key, serialize($value), $this->_timeout)) {
-      CRM_Core_Error::fatal("Redis set failed, wondering why?, $key", $value);
+      if (PHP_SAPI === 'cli' || (Civi\Core\Container::isContainerBooted() && CRM_Core_Permission::check('view debug output'))) {
+        CRM_Core_Error::fatal("Redis set ($key) failed: " . $this->_cache->getLastError());
+      }
+      else {
+        Civi::log()->error("Redis set ($key) failed: " . $this->_cache->getLastError());
+        CRM_Core_Error::fatal("Redis set ($key) failed");
+      }
       return FALSE;
     }
     return TRUE;