From 7aa1b99d189a74644be5a4082b26cb6c9978cbb8 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Wed, 31 Jul 2013 15:59:04 -0700 Subject: [PATCH] CRM-13141 restructured code to handle empty 200 result from public extensions directory. ---------------------------------------- * CRM-13141: Manage Extensions throws an erroneous fatal error - Failed Fetching List - when there are no extensions available for a particular install version http://issues.civicrm.org/jira/browse/CRM-13141 --- CRM/Extension/Browser.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/CRM/Extension/Browser.php b/CRM/Extension/Browser.php index 70eaba90b6..c3407daf82 100644 --- a/CRM/Extension/Browser.php +++ b/CRM/Extension/Browser.php @@ -217,31 +217,29 @@ class CRM_Extension_Browser { return array(); } + $exts = array(); list ($status, $extdir) = CRM_Utils_HttpClient::singleton()->get($this->getRepositoryUrl() . $this->indexPath); if ($extdir === FALSE || $status !== CRM_Utils_HttpClient::STATUS_OK) { CRM_Core_Session::setStatus(ts('The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests or contact CiviCRM team on CiviCRM forum.
', array(1 => $this->getRepositoryUrl())), ts('Connection Error'), 'error'); - } - - $lines = explode("\n", $extdir); - - foreach ($lines as $ln) { - if (preg_match("@\(.*)\@i", $ln, $out)) { - // success - $extsRaw[] = $out; - $key = strip_tags($out[1]); - if (substr($key, -4) == '.xml') { - $exts[] = array('key' => substr($key, 0, -4)); + } else if (empty($exts)) { + // CRM-13141 There may not be any compatible extensions available for the requested CiviCRM version + CMS. If so, $extdir is empty so just return a notification. + $config = CRM_Core_Config::singleton(); + CRM_Core_Session::setStatus(ts('There are currently no extensions on the CiviCRM public extension directory which are compatible with version %2 (requested extensions from here). If you want to install an extension which is not marked as compatible, you may be able to download and install extensions manually (depending on access to your web server).
', array(1 => $this->getRepositoryUrl(), 2 => $config->civiVersion, 3 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Extensions')), ts('No Extensions Available for this Version'), 'info'); + } else { + $lines = explode("\n", $extdir); + + foreach ($lines as $ln) { + if (preg_match("@\(.*)\@i", $ln, $out)) { + // success + $extsRaw[] = $out; + $key = strip_tags($out[1]); + if (substr($key, -4) == '.xml') { + $exts[] = array('key' => substr($key, 0, -4)); + } } } } - if (empty($exts)) { - if ($extdir !== FALSE) { - CRM_Core_Session::setStatus(ts('Could not retrieve a list of extensions from the CiviCRM public directory at %1 - please contact CiviCRM team on CiviCRM forum.
', array(1 => $this->getRepositoryUrl())), ts('Failed Fetching List'), 'error'); - } - $exts = array(); - } - ini_restore('allow_url_fopen'); ini_restore('default_socket_timeout'); -- 2.25.1