From 86448e8d0ce8977c791d659515faf3606af6e470 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 4 Dec 2015 20:58:52 -0500 Subject: [PATCH] CRM-17637 - Remove useless singleton method --- CRM/Utils/Check/Env.php | 2 +- CRM/Utils/VersionCheck.php | 23 -------------------- tests/phpunit/CRM/Utils/versionCheckTest.php | 4 ++-- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 882e5da066..7b4a9d9112 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -293,7 +293,7 @@ class CRM_Utils_Check_Env { $messages = array(); if (Civi::settings()->get('versionCheck')) { - $vc = CRM_Utils_VersionCheck::singleton(); + $vc = new CRM_Utils_VersionCheck(); $newerVersion = $vc->isNewerVersionAvailable(); if ($newerVersion['version']) { diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index eff22b5506..0b013bf638 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -42,14 +42,6 @@ class CRM_Utils_VersionCheck { // cachefile expiry time (in seconds) - one day CACHEFILE_EXPIRE = 86400; - /** - * We only need one instance of this object, so we use the - * singleton pattern and cache the instance in this variable - * - * @var object - */ - static private $_singleton = NULL; - /** * The version of the current (local) installation * @@ -119,21 +111,6 @@ class CRM_Utils_VersionCheck { } } - /** - * Static instance provider. - * - * Method providing static instance of CRM_Utils_VersionCheck, - * as in Singleton pattern - * - * @return CRM_Utils_VersionCheck - */ - public static function &singleton() { - if (!isset(self::$_singleton)) { - self::$_singleton = new CRM_Utils_VersionCheck(); - } - return self::$_singleton; - } - /** * Finds the release info for a minor version. * @param string $version diff --git a/tests/phpunit/CRM/Utils/versionCheckTest.php b/tests/phpunit/CRM/Utils/versionCheckTest.php index f65faffe4e..a85cd2e04f 100644 --- a/tests/phpunit/CRM/Utils/versionCheckTest.php +++ b/tests/phpunit/CRM/Utils/versionCheckTest.php @@ -108,7 +108,7 @@ class CRM_Utils_versionCheckTest extends CiviUnitTestCase { * @param mixed $expectedResult */ public function testNewerVersion($localVersion, $versionInfo, $expectedResult) { - $vc = CRM_Utils_VersionCheck::singleton(); + $vc = new CRM_Utils_VersionCheck(); // These values are set by the constructor but for testing we override them $vc->localVersion = $localVersion; $vc->localMajorVersion = $vc->getMajorVersion($localVersion); @@ -154,7 +154,7 @@ class CRM_Utils_versionCheckTest extends CiviUnitTestCase { * @param bool $expectedResult */ public function testSecurityUpdate($localVersion, $versionInfo, $expectedResult) { - $vc = CRM_Utils_VersionCheck::singleton(); + $vc = new CRM_Utils_VersionCheck(); // These values are set by the constructor but for testing we override them $vc->localVersion = $localVersion; $vc->localMajorVersion = $vc->getMajorVersion($localVersion); -- 2.25.1