From f3a87cf4c56278ddf6298806de476329f45dcf11 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 2 May 2019 14:44:35 +1200 Subject: [PATCH] [cleanup] Remove deprecated pattern &CRM_Core_Config::singleton() --- CRM/Activity/BAO/ICalendar.php | 3 +-- CRM/Utils/System.php | 6 ++---- CRM/Utils/System/Base.php | 3 +-- tests/phpunit/CRM/Activity/BAO/ActivityTest.php | 3 +-- tools/bin/scripts/cli.php | 4 ++-- tools/bin/scripts/memcache.php | 4 ++-- tools/scripts/civimail-spooler/civimail-spooler.php | 2 +- tools/scripts/solr/createSolrJSON.php | 2 +- tools/scripts/solr/createSolrXML.php | 2 +- tools/scripts/solr/createSyncJSON.php | 2 +- 10 files changed, 13 insertions(+), 18 deletions(-) diff --git a/CRM/Activity/BAO/ICalendar.php b/CRM/Activity/BAO/ICalendar.php index 4ebc2b0b54..cb2cb014ef 100644 --- a/CRM/Activity/BAO/ICalendar.php +++ b/CRM/Activity/BAO/ICalendar.php @@ -67,8 +67,7 @@ class CRM_Activity_BAO_ICalendar { public function addAttachment(&$attachments, $contacts) { // Check preferences setting if (Civi::settings()->get('activity_assignee_notification_ics')) { - $config = &CRM_Core_Config::singleton(); - $this->icsfile = tempnam($config->customFileUploadDir, 'ics'); + $this->icsfile = tempnam(CRM_Core_Config::singleton()->customFileUploadDir, 'ics'); if ($this->icsfile !== FALSE) { rename($this->icsfile, $this->icsfile . '.ics'); $this->icsfile .= '.ics'; diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 6733d57f7e..e7af2239c0 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -215,8 +215,7 @@ class CRM_Utils_System { $print = FALSE, $maintenance = FALSE ) { - $config = &CRM_Core_Config::singleton(); - return $config->userSystem->theme($content, $print, $maintenance); + return CRM_Core_Config::singleton()->userSystem->theme($content, $print, $maintenance); } /** @@ -1613,8 +1612,7 @@ class CRM_Utils_System { $addLanguagePart = TRUE, $removeLanguagePart = FALSE ) { - $config = &CRM_Core_Config::singleton(); - return $config->userSystem->languageNegotiationURL($url, $addLanguagePart, $removeLanguagePart); + return CRM_Core_Config::singleton()->userSystem->languageNegotiationURL($url, $addLanguagePart, $removeLanguagePart); } /** diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 0ad46528d4..a83754f7cf 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -254,10 +254,9 @@ abstract class CRM_Utils_System_Base { } $out = $content; - $config = &CRM_Core_Config::singleton(); if ( !$print && - $config->userFramework == 'WordPress' + CRM_Core_Config::singleton()->userFramework == 'WordPress' ) { if (!function_exists('is_admin')) { throw new \Exception('Function "is_admin()" is missing, even though WordPress is the user framework.'); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 1f49256bb8..3a1dde23b4 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -1163,8 +1163,7 @@ $text public function testSendSMSWithoutPermission() { $dummy = NULL; $session = CRM_Core_Session::singleton(); - $config = &CRM_Core_Config::singleton(); - $config->userPermissionClass->permissions = array('access CiviCRM'); + CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM'); CRM_Activity_BAO_Activity::sendSMS( $dummy, diff --git a/tools/bin/scripts/cli.php b/tools/bin/scripts/cli.php index 29b8704da0..9ac2f36482 100644 --- a/tools/bin/scripts/cli.php +++ b/tools/bin/scripts/cli.php @@ -88,8 +88,8 @@ class civicrm_CLI { function authenticate($user, $pass) { session_start(); require_once 'CRM/Core/Config.php'; - - $config = &CRM_Core_Config::singleton(); + // Does calling this do anything here? + CRM_Core_Config::singleton(); // this does not return on failure // require_once 'CRM/Utils/System.php'; diff --git a/tools/bin/scripts/memcache.php b/tools/bin/scripts/memcache.php index c341602256..918dc7a486 100644 --- a/tools/bin/scripts/memcache.php +++ b/tools/bin/scripts/memcache.php @@ -5,8 +5,8 @@ require_once 'CRM/Utils/Cache.php'; define('CIVICRM_USE_MEMCACHE', 1); -$config = &CRM_Core_Config::singleton(); -$cache = &CRM_Utils_Cache::singleton(); +$config = CRM_Core_Config::singleton(); +$cache = CRM_Utils_Cache::singleton(); $cache->set('CRM_Core_Config' .CRM_Core_Config::domainID(), $config); CRM_Core_Error::debug('get', $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID())); diff --git a/tools/scripts/civimail-spooler/civimail-spooler.php b/tools/scripts/civimail-spooler/civimail-spooler.php index 63bb5a83a5..85ad8fd3da 100644 --- a/tools/scripts/civimail-spooler/civimail-spooler.php +++ b/tools/scripts/civimail-spooler/civimail-spooler.php @@ -17,7 +17,7 @@ require_once "$config_file"; require_once "CRM/Core/Config.php"; '); -$config = &CRM_Core_Config::singleton(); +$config = CRM_Core_Config::singleton(); /* Temporary permissioning hack for now */ diff --git a/tools/scripts/solr/createSolrJSON.php b/tools/scripts/solr/createSolrJSON.php index bbe6eeae6c..005c6555c7 100644 --- a/tools/scripts/solr/createSolrJSON.php +++ b/tools/scripts/solr/createSolrJSON.php @@ -373,7 +373,7 @@ function run(&$contactIDs) { } } -$config = &CRM_Core_Config::singleton(); +$config = CRM_Core_Config::singleton(); $config->userFramework = 'Soap'; $config->userFrameworkClass = 'CRM_Utils_System_Soap'; $config->userHookClass = 'CRM_Utils_Hook_Soap'; diff --git a/tools/scripts/solr/createSolrXML.php b/tools/scripts/solr/createSolrXML.php index a00b15a4bf..f11a20a653 100644 --- a/tools/scripts/solr/createSolrXML.php +++ b/tools/scripts/solr/createSolrXML.php @@ -244,7 +244,7 @@ function run(&$contactIDs) { } } -$config = &CRM_Core_Config::singleton(); +$config = CRM_Core_Config::singleton(); $config->userFramework = 'Soap'; $config->userFrameworkClass = 'CRM_Utils_System_Soap'; $config->userHookClass = 'CRM_Utils_Hook_Soap'; diff --git a/tools/scripts/solr/createSyncJSON.php b/tools/scripts/solr/createSyncJSON.php index 540978056c..f4b3bf62e6 100644 --- a/tools/scripts/solr/createSyncJSON.php +++ b/tools/scripts/solr/createSyncJSON.php @@ -526,7 +526,7 @@ function run(&$values, &$contactIDs, &$allContactIDs) { } } -$config = &CRM_Core_Config::singleton(); +$config = CRM_Core_Config::singleton(); $config->userFramework = 'Soap'; $config->userFrameworkClass = 'CRM_Utils_System_Soap'; $config->userHookClass = 'CRM_Utils_Hook_Soap'; -- 2.25.1