Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a3f776f4
Commit
a3f776f4
authored
Sep 09, 2009
by
Dries
Browse files
- Patch
#571934
by bjaspan: Fixed omissions in field_delete_(){field,instance}().
parent
933be163
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/field/field.api.php
View file @
a3f776f4
...
...
@@ -1265,17 +1265,14 @@ function hook_field_create_instance($instance) {
/**
* Act on a field being deleted.
*
* This hook is invoked just before the field is deleted.
*
* TODO: Not implemented.
* This hook is invoked just after field is deleted.
*
* @param $field
* The field
being
deleted.
* The field
just
deleted.
*/
function
hook_field_delete_field
(
$field
)
{
}
/**
* Act on a field instance being updated.
*
...
...
@@ -1293,12 +1290,10 @@ function hook_field_update_instance($instance) {
/**
* Act on a field instance being deleted.
*
* This hook is invoked just before the instance is deleted.
*
* TODO: Not implemented.
* This hook is invoked just after the instance is deleted.
*
* @param $instance
* The instance just
upda
ted.
* The instance just
dele
ted.
*/
function
hook_field_delete_instance
(
$instance
)
{
}
...
...
modules/field/field.crud.inc
View file @
a3f776f4
...
...
@@ -379,15 +379,17 @@ function field_read_fields($params = array(), $include_additional = array()) {
* The field name to delete.
*/
function
field_delete_field
(
$field_name
)
{
// Delete all non-deleted instances.
$field
=
field_info_field
(
$field_name
);
if
(
isset
(
$field
[
'bundles'
]))
{
foreach
(
$field
[
'bundles'
]
as
$bundle
)
{
field_delete_instance
(
$field_name
,
$bundle
);
}
}
// Mark field storage for deletion.
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_delete_field'
,
$field_name
);
// Mark any instances of the field for deletion.
db_update
(
'field_config_instance'
)
->
fields
(
array
(
'deleted'
=>
1
))
->
condition
(
'field_name'
,
$field_name
)
->
execute
();
// Mark the field for deletion.
db_update
(
'field_config'
)
->
fields
(
array
(
'deleted'
=>
1
))
...
...
@@ -396,6 +398,8 @@ function field_delete_field($field_name) {
// Clear the cache.
field_cache_clear
(
TRUE
);
module_invoke_all
(
'field_delete_field'
,
$field
);
}
/**
...
...
@@ -683,6 +687,9 @@ function field_read_instances($params = array(), $include_additional = array())
* The bundle for the instance which will be deleted.
*/
function
field_delete_instance
(
$field_name
,
$bundle
)
{
// Save the instance for hook_field_delete_instance before it is deleted.
$instance
=
field_info_instance
(
$field_name
,
$bundle
);
// Mark the field instance for deletion.
db_update
(
'field_config_instance'
)
->
fields
(
array
(
'deleted'
=>
1
))
...
...
@@ -694,6 +701,8 @@ function field_delete_instance($field_name, $bundle) {
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_delete_instance'
,
$field_name
,
$bundle
);
// Clear the cache.
field_cache_clear
();
module_invoke_all
(
'field_delete_instance'
,
$instance
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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