Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
fc7c985b
Commit
fc7c985b
authored
Jan 24, 2012
by
Dries Buytaert
Browse files
- Patch
#1264728
by yched: Refresh field 'active' state in module_enable() / _disable().
parent
e341d8ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/field/field.install
View file @
fc7c985b
...
...
@@ -103,10 +103,9 @@ function field_schema() {
'active'
=>
array
(
'active'
),
'storage_active'
=>
array
(
'storage_active'
),
'deleted'
=>
array
(
'deleted'
),
// Used by field_
modules_disabled
().
// Used by field_
sync_field_status
().
'module'
=>
array
(
'module'
),
'storage_module'
=>
array
(
'storage_module'
),
// Used by field_associate_fields().
'type'
=>
array
(
'type'
),
'storage_type'
=>
array
(
'storage_type'
),
),
...
...
core/modules/field/field.module
View file @
fc7c985b
...
...
@@ -362,11 +362,12 @@ function field_theme() {
/**
* Implements hook_cron().
*
* Purges some deleted Field API data, if any exists.
*/
function
field_cron
()
{
// Refresh the 'active' status of fields.
field_sync_field_status
();
// Do a pass of purging on deleted Field API data, if any exists.
$limit
=
variable_get
(
'field_purge_batch_size'
,
10
);
field_purge_batch
(
$limit
);
}
...
...
@@ -412,10 +413,29 @@ function field_system_info_alter(&$info, $file, $type) {
* Implements hook_flush_caches().
*/
function
field_flush_caches
()
{
// Refresh the 'active' status of fields.
field_sync_field_status
();
// Request a flush of our cache table.
return
array
(
'field'
);
}
/**
* Implements hook_modules_enabled().
*/
function
field_modules_enabled
(
$modules
)
{
// Refresh the 'active' status of fields.
field_sync_field_status
();
}
/**
* Implements hook_modules_disabled().
*/
function
field_modules_disabled
(
$modules
)
{
// Refresh the 'active' status of fields.
field_sync_field_status
();
}
/**
* Refreshes the 'active' and 'storage_active' columns for fields.
*/
...
...
@@ -449,18 +469,18 @@ function field_sync_field_status() {
function
field_associate_fields
(
$module
)
{
// Associate field types.
$field_types
=
(
array
)
module_invoke
(
$module
,
'field_info'
);
f
oreach
(
$field_types
as
$name
=>
$field_info
)
{
i
f
(
$field_types
)
{
db_update
(
'field_config'
)
->
fields
(
array
(
'module'
=>
$module
,
'active'
=>
1
))
->
condition
(
'type'
,
$name
)
->
condition
(
'type'
,
array_keys
(
$field_types
)
)
->
execute
();
}
// Associate storage backends.
$storage_types
=
(
array
)
module_invoke
(
$module
,
'field_storage_info'
);
f
oreach
(
$storage_types
as
$name
=>
$storage_info
)
{
i
f
(
$storage_types
)
{
db_update
(
'field_config'
)
->
fields
(
array
(
'storage_module'
=>
$module
,
'storage_active'
=>
1
))
->
condition
(
'storage_type'
,
$name
)
->
condition
(
'storage_type'
,
array_keys
(
$storage_types
)
)
->
execute
();
}
}
...
...
core/modules/field/tests/field.test
View file @
fc7c985b
...
...
@@ -2357,7 +2357,6 @@ class FieldCrudTestCase extends FieldTestCase {
$this
->
assertTrue
(
$field_definition
<=
$field
,
t
(
'The field was properly read.'
));
module_disable
(
$modules
,
FALSE
);
drupal_flush_all_caches
();
$fields
=
field_read_fields
(
array
(
'field_name'
=>
$field_name
),
array
(
'include_inactive'
=>
TRUE
));
$this
->
assertTrue
(
isset
(
$fields
[
$field_name
])
&&
$field_definition
<
$field
,
t
(
'The field is properly read when explicitly fetching inactive fields.'
));
...
...
@@ -2370,7 +2369,6 @@ class FieldCrudTestCase extends FieldTestCase {
$module
=
array_shift
(
$modules
);
module_enable
(
array
(
$module
),
FALSE
);
drupal_flush_all_caches
();
}
// Check that the field is active again after all modules have been
...
...
core/modules/taxonomy/taxonomy.test
View file @
fc7c985b
...
...
@@ -375,7 +375,6 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
field_create_instance
(
$this
->
instance
);
module_disable
(
array
(
'taxonomy'
));
drupal_flush_all_caches
();
require_once
DRUPAL_ROOT
.
'/core/includes/install.inc'
;
drupal_uninstall_modules
(
array
(
'taxonomy'
));
module_enable
(
array
(
'taxonomy'
));
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment