Skip to content

Commit 7a00bd3

Browse files
committed
Add drush function to delete stubs.
1 parent 92e29c6 commit 7a00bd3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

os2web_cp_service.drush.inc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function os2web_cp_service_drush_command() {
1515
'arguments' => array(),
1616
'aliases' => array('cp-up'),
1717
);
18+
$items['cp-cleanup'] = array(
19+
'description' => 'Delete all refenreces which are broken to a Stub.',
20+
'arguments' => array(),
21+
'aliases' => array('cp-cl'),
22+
);
1823
return $items;
1924
}
2025

@@ -53,3 +58,23 @@ function drush_os2web_cp_service_cp_update_ref() {
5358
}
5459
}
5560
}
61+
62+
/**
63+
* Implements drush_COMMAND().
64+
*/
65+
function drush_os2web_cp_service_cp_cleanup() {
66+
67+
$nodes = db_query("SELECT *
68+
FROM node n
69+
WHERE n.type = 'os2web_cp_service_cp_document'
70+
AND n.title = 'Stub'
71+
AND n.nid IN (
72+
SELECT field_os2web_cp_service_doc_ref_target_id
73+
FROM field_data_field_os2web_cp_service_doc_ref
74+
)");
75+
76+
foreach ($nodes as $node) {
77+
node_delete(nid);
78+
drush_log(t('Deleted stub: :node', array(':node' => $node->nid)), 'success');
79+
}
80+
}

0 commit comments

Comments
 (0)