CRM-14126 - CRM_Extension - Add pleasant warning and log message if open_basedir...
authorTim Otten <totten@civicrm.org>
Mon, 3 Feb 2014 20:09:58 +0000 (12:09 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 3 Feb 2014 20:09:58 +0000 (12:09 -0800)
----------------------------------------
 * CRM-14126: HttpClient.php library used by CiviCRM issues a PHP warning when open_basedir is set
   http://issues.civicrm.org/jira/browse/CRM-14126

CRM/Extension/Downloader.php
CRM/Utils/HttpClient.php

index 3c40f0bc30af6ed2218646ec15f3dafbdba338da..4a6274efc5227e9031e1d3125f96cc0a80c8be15 100644 (file)
@@ -84,6 +84,11 @@ class CRM_Extension_Downloader {
       );
     }
 
+    if (empty($errors) && ! CRM_Utils_HttpClient::singleton()->isRedirectSupported()) {
+      CRM_Core_Session::setStatus(ts('WARNING: The downloader may be unable to download files which require HTTP redirection. This may be a configuration issue with PHP\'s open_basedir or safe_mode.'));
+      CRM_Core_Error::debug_log_message('WARNING: The downloader may be unable to download files which require HTTP redirection. This may be a configuration issue with PHP\'s open_basedir or safe_mode.');
+    }
+
     return $errors;
   }
 
index c94b605fd9445f260a5e8962c50a593b6fcb945f..d7c5422fc7030d726082f7db59c67555d4ca7e61 100644 (file)
@@ -189,7 +189,7 @@ class CRM_Utils_HttpClient {
     curl_setopt($ch, CURLOPT_HEADER, FALSE);
     curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
-    if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') {
+    if ($this->isRedirectSupported()) {
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
     }
     if ($this->connectionTimeout !== NULL) {
@@ -202,4 +202,8 @@ class CRM_Utils_HttpClient {
     return array($ch, $caConfig);
   }
 
+  public function isRedirectSupported() {
+    return ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off';
+  }
+
 }