From 2683ce94205cc4c1585c1015bdafe8a605f2a916 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 30 Apr 2013 15:12:03 -0700 Subject: [PATCH] Refactor cache flush CRM-12464 ---------------------------------------- * CRM-12464: Search improvements in 4.4 http://issues.civicrm.org/jira/browse/CRM-12464 --- CRM/Core/PseudoConstant.php | 4 ++-- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/api/v3/AddressTest.php | 2 +- tests/phpunit/api/v3/ConstantTest.php | 2 +- tests/phpunit/api/v3/PhoneTest.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 6bd6d44bc5..af97571dd1 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -529,8 +529,8 @@ class CRM_Core_PseudoConstant { * @param boolean $name pseudoconstant to be flushed * */ - public static function flush($name) { - if (isset(self::$$name)) { + public static function flush($name = 'cache') { + if (property_exists(self, $name)) { self::$$name = NULL; } } diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 4166b792b7..021c725ae1 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1442,7 +1442,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $locationType->copyValues($params); $locationType->save(); // clear getfields cache - CRM_Core_PseudoConstant::flush('locationType'); + CRM_Core_PseudoConstant::flush(); civicrm_api('phone', 'getfields', array('version' => 3, 'cache_clear' => 1)); return $locationType; } diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index bfdeda5b7c..da6ecf27c1 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -47,7 +47,7 @@ class api_v3_AddressTest extends CiviUnitTestCase { $this->_contactID = $this->organizationCreate(); $this->_locationType = $this->locationTypeCreate(); - CRM_Core_PseudoConstant::flush('locationType'); + CRM_Core_PseudoConstant::flush(); $this->_params = array( 'contact_id' => $this->_contactID, diff --git a/tests/phpunit/api/v3/ConstantTest.php b/tests/phpunit/api/v3/ConstantTest.php index e54686cbdc..2d7a809e9e 100644 --- a/tests/phpunit/api/v3/ConstantTest.php +++ b/tests/phpunit/api/v3/ConstantTest.php @@ -121,7 +121,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase { */ public function testLocationTypeGet() { // needed to get rid of cached values from previous tests - CRM_Core_PseudoConstant::flush('locationType'); + CRM_Core_PseudoConstant::flush(); diff --git a/tests/phpunit/api/v3/PhoneTest.php b/tests/phpunit/api/v3/PhoneTest.php index 8ea4954cbf..8260cf5be2 100644 --- a/tests/phpunit/api/v3/PhoneTest.php +++ b/tests/phpunit/api/v3/PhoneTest.php @@ -49,7 +49,7 @@ class api_v3_PhoneTest extends CiviUnitTestCase { $this->_contactID = $this->organizationCreate(); $loc = $this->locationTypeCreate(); $this->_locationType = $loc->id; - CRM_Core_PseudoConstant::flush('locationType'); + CRM_Core_PseudoConstant::flush(); $this->quickCleanup(array('civicrm_phone')); $this->_params = array( 'contact_id' => $this->_contactID, -- 2.25.1