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
d734f2f2
Commit
d734f2f2
authored
Sep 25, 2009
by
Dries
Browse files
- Patch
#581392
by sun, catch | mr.baileys: Fixed Add an API function for deleting revisions.
parent
8b0b496a
Changes
5
Hide whitespace changes
Inline
Side-by-side
modules/node/node.api.php
View file @
d734f2f2
...
...
@@ -281,7 +281,7 @@ function hook_node_delete($node) {
* @param $node
* The node the action is being performed on.
*/
function
hook_node_
delete_
revision
(
$node
)
{
function
hook_node_revision
_delete
(
$node
)
{
db_delete
(
'upload'
)
->
condition
(
'vid'
,
$node
->
vid
)
->
execute
();
if
(
!
is_array
(
$node
->
files
))
{
return
;
...
...
modules/node/node.module
View file @
d734f2f2
...
...
@@ -780,10 +780,11 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
* @return
* A fully-populated node object.
*/
function
node_load
(
$nid
,
$vid
=
array
(),
$reset
=
FALSE
)
{
$vid
=
isset
(
$vid
)
?
array
(
'vid'
=>
$vid
)
:
NULL
;
$node
=
node_load_multiple
(
array
(
$nid
),
$vid
,
$reset
);
return
$node
?
$node
[
$nid
]
:
FALSE
;
function
node_load
(
$nid
=
NULL
,
$vid
=
NULL
,
$reset
=
FALSE
)
{
$nids
=
(
isset
(
$nid
)
?
array
(
$nid
)
:
array
());
$conditions
=
(
isset
(
$vid
)
?
array
(
'vid'
=>
$vid
)
:
array
());
$node
=
node_load_multiple
(
$nids
,
$conditions
,
$reset
);
return
$node
?
reset
(
$node
)
:
FALSE
;
}
/**
...
...
@@ -1010,6 +1011,31 @@ function node_delete_multiple($nids) {
drupal_static_reset
(
'node_load_multiple'
);
}
/**
* Delete a node revision.
*
* @param $revision_id
* The revision ID to delete.
*/
function
node_revision_delete
(
$revision_id
)
{
if
(
$revision
=
node_load
(
NULL
,
$revision_id
))
{
// Prevent deleting the current revision.
$node
=
node_load
(
$revision
->
nid
);
if
(
$revision_id
==
$node
->
vid
)
{
return
FALSE
;
}
db_delete
(
'node_revision'
)
->
condition
(
'nid'
,
$revision
->
nid
)
->
condition
(
'vid'
,
$revision
->
vid
)
->
execute
();
module_invoke_all
(
'node_revision_delete'
,
$revision
);
field_attach_delete_revision
(
'node'
,
$revision
);
return
TRUE
;
}
return
FALSE
;
}
/**
* Generate an array for rendering the given node.
*
...
...
@@ -1484,13 +1510,12 @@ function node_user_cancel($edit, $account, $method) {
->
condition
(
'uid'
,
$account
->
uid
)
->
execute
()
->
fetchCol
();
foreach
(
$nodes
as
$nid
)
{
node_delete
(
$nid
);
}
node_delete_multiple
(
$nodes
);
// Delete old revisions.
db_delete
(
'node_revision'
)
->
condition
(
'uid'
,
$account
->
uid
)
->
execute
();
$revisions
=
db_query
(
'SELECT vid FROM {node_revision} WHERE uid = :uid'
,
array
(
':uid'
=>
$account
->
uid
))
->
fetchCol
();
foreach
(
$revisions
as
$revision
)
{
node_revision_delete
(
$revision
);
}
// Clean history.
db_delete
(
'history'
)
->
condition
(
'uid'
,
$account
->
uid
)
...
...
modules/node/node.pages.inc
View file @
d734f2f2
...
...
@@ -563,12 +563,8 @@ function node_revision_delete_confirm($form, $form_state, $node_revision) {
function
node_revision_delete_confirm_submit
(
$form
,
&
$form_state
)
{
$node_revision
=
$form
[
'#node_revision'
];
db_delete
(
'node_revision'
)
->
condition
(
'nid'
,
$node_revision
->
nid
)
->
condition
(
'vid'
,
$node_revision
->
vid
)
->
execute
();
module_invoke_all
(
'node_delete_revision'
,
$node_revision
);
field_attach_delete_revision
(
'node'
,
$node_revision
);
node_revision_delete
(
$node_revision
->
vid
);
watchdog
(
'content'
,
'@type: deleted %title revision %revision.'
,
array
(
'@type'
=>
$node_revision
->
type
,
'%title'
=>
$node_revision
->
title
,
'%revision'
=>
$node_revision
->
vid
));
drupal_set_message
(
t
(
'Revision from %revision-date of @type %title has been deleted.'
,
array
(
'%revision-date'
=>
format_date
(
$node_revision
->
revision_timestamp
),
'@type'
=>
node_type_get_name
(
$node_revision
),
'%title'
=>
$node_revision
->
title
)));
$form_state
[
'redirect'
]
=
'node/'
.
$node_revision
->
nid
;
...
...
modules/taxonomy/taxonomy.module
View file @
d734f2f2
...
...
@@ -865,8 +865,7 @@ function taxonomy_node_get_terms($node, $key = 'tid') {
* Save term associations for a given node.
*/
function
taxonomy_node_save
(
$node
,
$terms
)
{
taxonomy_node_delete_revision
(
$node
);
taxonomy_node_revision_delete
(
$node
);
// Free tagging vocabularies do not send their tids in the form,
// so we'll detect them here and process them independently.
...
...
@@ -1594,11 +1593,11 @@ function taxonomy_node_delete($node) {
}
/**
* Implement hook_node_
delete_
revision().
* Implement hook_node_revision
_delete
().
*
* Remove associations of a node to its terms.
*/
function
taxonomy_node_
delete_
revision
(
$node
)
{
function
taxonomy_node_revision
_delete
(
$node
)
{
db_delete
(
'taxonomy_term_node'
)
->
condition
(
'vid'
,
$node
->
vid
)
->
execute
();
...
...
modules/upload/upload.module
View file @
d734f2f2
...
...
@@ -412,9 +412,9 @@ function upload_node_delete($node) {
}
/**
* Implement hook_node_
delete_
revision().
* Implement hook_node_revision
_delete
().
*/
function
upload_node_
delete_
revision
(
$node
)
{
function
upload_node_revision
_delete
(
$node
)
{
db_delete
(
'upload'
)
->
condition
(
'vid'
,
$node
->
vid
)
->
execute
();
if
(
!
is_array
(
$node
->
files
))
{
return
;
...
...
Write
Preview
Markdown
is supported
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