X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FVersionCheck.php;h=eb72bd94518a904b816b8c3d11311746722e40ea;hb=cced0f6e4c2e244beca8ac97fc14e3806167c85e;hp=2c8cbd9cc4c46613f8a37e31d32cc913df09365e;hpb=52c503aac03bba16dff98f57d5647fb98168e9b7;p=civicrm-core.git diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index 2c8cbd9cc4..eb72bd9451 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_VersionCheck { const @@ -48,7 +48,7 @@ class CRM_Utils_VersionCheck { * * @var array */ - public $versionInfo = array(); + public $versionInfo = []; /** * @var bool @@ -58,7 +58,7 @@ class CRM_Utils_VersionCheck { /** * @var array */ - public $cronJob = array(); + public $cronJob = []; /** * @var string @@ -70,7 +70,7 @@ class CRM_Utils_VersionCheck { * * @var array */ - protected $stats = array(); + protected $stats = []; /** * Path to cache file @@ -149,11 +149,11 @@ class CRM_Utils_VersionCheck { $siteKey = md5(defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : ''); // Calorie-free pingback for alphas - $this->stats = array('version' => $this->localVersion); + $this->stats = ['version' => $this->localVersion]; // Non-alpha versions get the full treatment if ($this->localVersion && !strpos($this->localVersion, 'alpha')) { - $this->stats += array( + $this->stats += [ 'hash' => md5($siteKey . $config->userFrameworkBaseURL), 'uf' => $config->userFramework, 'lang' => $config->lcMessages, @@ -162,7 +162,7 @@ class CRM_Utils_VersionCheck { 'PHP' => phpversion(), 'MySQL' => CRM_CORE_DAO::singleValueQuery('SELECT VERSION()'), 'communityMessagesUrl' => Civi::settings()->get('communityMessagesUrl'), - ); + ]; $this->getDomainStats(); $this->getPayProcStats(); $this->getEntityStats(); @@ -177,7 +177,7 @@ class CRM_Utils_VersionCheck { $dao = new CRM_Financial_DAO_PaymentProcessor(); $dao->is_active = 1; $dao->find(); - $ppTypes = array(); + $ppTypes = []; // Get title for all processor types // FIXME: This should probably be getName, but it has always returned translated label so we stick with that for now as it would affect stats @@ -193,7 +193,7 @@ class CRM_Utils_VersionCheck { * Add info to the 'entities' array */ private function getEntityStats() { - $tables = array( + $tables = [ 'CRM_Activity_DAO_Activity' => 'is_test = 0', 'CRM_Case_DAO_Case' => 'is_deleted = 0', 'CRM_Contact_DAO_Contact' => 'is_deleted = 0', @@ -216,17 +216,17 @@ class CRM_Utils_VersionCheck { 'CRM_Pledge_DAO_Pledge' => 'is_test = 0', 'CRM_Pledge_DAO_PledgeBlock' => NULL, 'CRM_Mailing_Event_DAO_Delivered' => NULL, - ); + ]; foreach ($tables as $daoName => $where) { $dao = new $daoName(); if ($where) { $dao->whereAdd($where); } $short_name = substr($daoName, strrpos($daoName, '_') + 1); - $this->stats['entities'][] = array( + $this->stats['entities'][] = [ 'name' => $short_name, 'size' => $dao->count(), - ); + ]; } } @@ -238,11 +238,11 @@ class CRM_Utils_VersionCheck { // Core components $config = CRM_Core_Config::singleton(); foreach ($config->enableComponents as $comp) { - $this->stats['extensions'][] = array( + $this->stats['extensions'][] = [ 'name' => 'org.civicrm.component.' . strtolower($comp), 'enabled' => 1, 'version' => $this->stats['version'], - ); + ]; } // Contrib extensions $mapper = CRM_Extension_System::singleton()->getMapper(); @@ -250,11 +250,11 @@ class CRM_Utils_VersionCheck { $dao->find(); while ($dao->fetch()) { $info = $mapper->keyToInfo($dao->full_name); - $this->stats['extensions'][] = array( + $this->stats['extensions'][] = [ 'name' => $dao->full_name, 'enabled' => $dao->is_active, 'version' => isset($info->version) ? $info->version : NULL, - ); + ]; } } @@ -265,21 +265,21 @@ class CRM_Utils_VersionCheck { // Start with default value NULL, then check to see if there's a better // value to be had. $this->stats['domain_isoCode'] = NULL; - $params = array( + $params = [ 'id' => CRM_Core_Config::domainID(), - ); + ]; $domain_result = civicrm_api3('domain', 'getsingle', $params); if (!empty($domain_result['contact_id'])) { - $address_params = array( + $address_params = [ 'contact_id' => $domain_result['contact_id'], 'is_primary' => 1, 'sequential' => 1, - ); + ]; $address_result = civicrm_api3('address', 'get', $address_params); if ($address_result['count'] == 1 && !empty($address_result['values'][0]['country_id'])) { - $country_params = array( + $country_params = [ 'id' => $address_result['values'][0]['country_id'], - ); + ]; $country_result = civicrm_api3('country', 'getsingle', $country_params); if (!empty($country_result['iso_code'])) { $this->stats['domain_isoCode'] = $country_result['iso_code']; @@ -293,13 +293,13 @@ class CRM_Utils_VersionCheck { * Store results in the cache file */ private function pingBack() { - $params = array( - 'http' => array( + $params = [ + 'http' => [ 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($this->stats), - ), - ); + ], + ]; $ctx = stream_context_create($params); $rawJson = file_get_contents($this->pingbackUrl, FALSE, $ctx); $versionInfo = $rawJson ? json_decode($rawJson, TRUE) : NULL; @@ -348,12 +348,12 @@ class CRM_Utils_VersionCheck { * Lookup version_check scheduled job */ private function getJob() { - $jobs = civicrm_api3('Job', 'get', array( + $jobs = civicrm_api3('Job', 'get', [ 'sequential' => 1, 'api_action' => "version_check", 'api_entity' => "job", - )); - $this->cronJob = CRM_Utils_Array::value(0, $jobs['values'], array()); + ]); + $this->cronJob = CRM_Utils_Array::value(0, $jobs['values'], []); } }