Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
eb40b5a4
Commit
eb40b5a4
authored
12 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
fix failing settings test by allowing more cache clearing
interim commit setting test passing but regression on api test
parent
5b887f26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/BAO/Domain.php
+1
-0
1 addition, 0 deletions
CRM/Core/BAO/Domain.php
CRM/Core/BAO/Setting.php
+28
-6
28 additions, 6 deletions
CRM/Core/BAO/Setting.php
tests/phpunit/CRM/Core/BAO/SettingTest.php
+15
-4
15 additions, 4 deletions
tests/phpunit/CRM/Core/BAO/SettingTest.php
with
44 additions
and
10 deletions
CRM/Core/BAO/Domain.php
+
1
−
0
View file @
eb40b5a4
...
...
@@ -101,6 +101,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain {
static
function
setDomain
(
$domainID
){
CRM_Core_Config
::
domainID
(
$domainID
);
self
::
getDomain
(
$domainID
);
CRM_Core_Config
::
singleton
(
TRUE
,
TRUE
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/BAO/Setting.php
+
28
−
6
View file @
eb40b5a4
...
...
@@ -75,31 +75,45 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
* @static
* @access public
*/
static
function
inCache
(
$group
,
static
function
inCache
(
$group
,
$name
,
$componentID
=
NULL
,
$contactID
=
NULL
,
$load
=
FALSE
,
$domainID
=
NULL
$domainID
=
NULL
,
$force
=
FALSE
)
{
if
(
!
isset
(
self
::
$_cache
))
{
self
::
$_cache
=
array
();
}
$cacheKey
=
"CRM_Setting_
{
$group
}
_
{
$componentID
}
_
{
$contactID
}
_
{
$domainID
}
"
;
if
(
$load
&&
!
isset
(
self
::
$_cache
[
$cacheKey
])
(
$force
||
!
isset
(
self
::
$_cache
[
$cacheKey
])
)
)
{
// check in civi cache if present (typically memcache)
$globalCache
=
CRM_Utils_Cache
::
singleton
();
$result
=
$globalCache
->
get
(
$cacheKey
);
if
(
$result
)
{
self
::
$_cache
[
$cacheKey
]
=
$result
;
}
}
return
isset
(
self
::
$_cache
[
$cacheKey
])
?
$cacheKey
:
NULL
;
}
/**
* Allow key o be cleared
* @param string $cacheKey
*/
static
function
flushCache
(
$cacheKey
){
unset
(
self
::
$_cache
[
$cacheKey
]);
$globalCache
=
CRM_Utils_Cache
::
singleton
();
$globalCache
->
delete
(
$cacheKey
);
}
static
function
setCache
(
$values
,
$group
,
...
...
@@ -200,7 +214,6 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
$cacheKey
=
self
::
setCache
(
$values
,
$group
,
$componentID
,
$contactID
,
$domainID
);
}
return
$name
?
CRM_Utils_Array
::
value
(
$name
,
self
::
$_cache
[
$cacheKey
],
$defaultValue
)
:
self
::
$_cache
[
$cacheKey
];
}
...
...
@@ -234,6 +247,12 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
$result
[
$domainID
]
=
array
();
foreach
(
$fieldsToGet
as
$name
=>
$value
)
{
if
(
!
empty
(
$fields
[
'values'
][
$name
][
'prefetch'
])){
if
(
isset
(
$params
[
'filters'
])
&&
isset
(
$params
[
'filters'
][
'prefetch'
])
&&
$params
[
'filters'
][
'prefetch'
]
==
0
){
// we are filtering out the prefetches from the return array
// so we will skip
continue
;
}
$configKey
=
CRM_Utils_Array
::
value
(
'config_key'
,
$fields
[
'values'
][
$name
],
$name
);
if
(
isset
(
$config
->
$configKey
)){
$setting
=
$config
->
$configKey
;
...
...
@@ -245,7 +264,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
$fields
[
'values'
][
$name
][
'group_name'
],
$name
,
CRM_Utils_Array
::
value
(
'component_id'
,
$params
),
CRM_Utils_Array
::
value
(
'default_value'
,
$params
)
,
null
,
CRM_Utils_Array
::
value
(
'contact_id'
,
$params
),
$domainID
);
...
...
@@ -283,7 +302,6 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
$createdID
=
NULL
,
$domainID
=
NULL
)
{
if
(
empty
(
$domainID
))
{
$domainID
=
CRM_Core_Config
::
domainID
();
}
...
...
@@ -635,8 +653,10 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
$apiParams
=
array
(
'version'
=>
3
,
'domain_id'
=>
'all'
,
'filters'
=>
array
(
'prefetch'
=>
0
),
);
$existing
=
civicrm_api
(
'setting'
,
'get'
,
$apiParams
);
if
(
!
empty
(
$existing
[
'values'
]))
{
$allSettings
=
civicrm_api
(
'setting'
,
'getfields'
,
array
(
'version'
=>
3
));
foreach
(
$existing
[
'values'
]
as
$domainID
=>
$domainSettings
)
{
...
...
@@ -657,6 +677,8 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
* Note that where the key name is being changed the 'legacy_key' will give us the old name
*/
static
function
convertConfigToSetting
(
$name
,
$domainID
=
null
)
{
// we have to force this here in case more than one domain is in play.
// whenever there is a possibility of more than one domain we must force it
$config
=
CRM_Core_Config
::
singleton
();
if
(
empty
(
$domainID
))
{
$domainID
=
CRM_Core_Config
::
domainID
();
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Core/BAO/SettingTest.php
+
15
−
4
View file @
eb40b5a4
...
...
@@ -121,19 +121,30 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
*
**/
function
testConvertAndFillSettings
()
{
$sql
=
" DELETE FROM civicrm_setting WHERE name = 'max_attachments'"
;
CRM_Core_DAO
::
executeQuery
(
$sql
);
$settings
=
array
(
'maxAttachments'
=>
6
);
CRM_Core_BAO_ConfigSetting
::
add
(
$settings
);
$config
=
CRM_Core_Config
::
singleton
(
TRUE
,
TRUE
);
$this
->
assertEquals
(
6
,
$config
->
maxAttachments
);
$checkSQL
=
"SELECT count(*) FROM civicrm_domain WHERE config_backend LIKE '%
Max
%' AND id = 1
$checkSQL
=
"SELECT count(*) FROM civicrm_domain WHERE config_backend LIKE '%
\"
maxAttachments
\"
;i:6
%' AND id = 1
"
;
$checkresult
=
CRM_Core_DAO
::
singleValueQuery
(
$checkSQL
);
$this
->
assertEquals
(
1
,
$checkresult
,
"Check that maxAttachments has been saved to database not just stored in config"
);
$sql
=
" DELETE FROM civicrm_setting WHERE name = 'max_attachments'"
;
$currentDomain
=
CRM_Core_Config
::
domainID
();
<<<<<<<
Updated
upstream
CRM_Core_DAO
::
executeQuery
(
$sql
);
CRM_Core_BAO_Setting
::
inCache
(
'CiviCRM Preferences'
,
'max_attachments'
,
NULL
,
NULL
,
TRUE
,
$currentDomain
,
TRUE
);
CRM_Core_BAO_Setting
::
updateSettingsFromMetaData
();
=======
>>>>>>>
Stashed
changes
CRM_Core_DAO
::
executeQuery
(
$sql
);
// we are setting up an artificial situation here as we are trying to drive out
// previous memory of this setting so we need to flush it out
$cachekey
=
CRM_Core_BAO_Setting
::
inCache
(
'CiviCRM Preferences'
,
'max_attachments'
,
NULL
,
NULL
,
TRUE
,
$currentDomain
);
CRM_Core_BAO_Setting
::
flushCache
(
$cachekey
);
CRM_Core_BAO_Setting
::
updateSettingsFromMetaData
();
//check current domain
$value
=
civicrm_api
(
'setting'
,
'getvalue'
,
array
(
'version'
=>
3
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment