? 232327-add-nodes-to-queue-for-deletion.patch ? bartik-move-secondary-links-889982.patch ? drupal-7.0-alpha1.he.po.po ? job.patch ? modules/node/.node.module.swp ? sites/default/files ? sites/default/settings.php Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1211 diff -u -p -r1.1211 common.inc --- includes/common.inc 27 Aug 2010 11:54:32 -0000 1.1211 +++ includes/common.inc 27 Aug 2010 15:58:26 -0000 @@ -2164,7 +2164,7 @@ function url($path = NULL, array $option * @param $path * The internal path or external URL being linked to, such as "node/34" or * "http://example.com/foo". - * @return + * @return * Boolean TRUE or FALSE, where TRUE indicates an external path. */ function url_is_external($path) { @@ -4714,7 +4714,6 @@ function drupal_cron_run() { // Return TRUE so other functions can check if it did run successfully $return = TRUE; } - foreach ($queues as $queue_name => $info) { $function = $info['worker callback']; $end = time() + (isset($info['time']) ? $info['time'] : 15); @@ -6896,7 +6895,7 @@ function entity_form_field_validate($ent * For some entity forms (e.g., forms with complex non-field data and forms that * simultaneously edit multiple entities), this behavior may be inappropriate, * so the #builder_function for such forms needs to implement the required - * functionality instead of calling this function. + * functionality instead of calling this function. */ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state) { $info = entity_get_info($entity_type); Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.892 diff -u -p -r1.892 comment.module --- modules/comment/comment.module 23 Aug 2010 14:53:50 -0000 1.892 +++ modules/comment/comment.module 27 Aug 2010 15:58:26 -0000 @@ -1578,6 +1578,14 @@ function comment_delete($cid) { * The comment to delete. */ function comment_delete_multiple($cids) { + if (count($cids) > 100) { + $jobs = array_chunk($cids, 100); + $cids = array_pop($jobs); + foreach ($jobs as $job) { + DrupalQueue::addJob('comment_delete_multiple', array($job)); + } + } + $comments = comment_load_multiple($cids); if ($comments) { Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.116 diff -u -p -r1.116 content_types.inc --- modules/node/content_types.inc 8 Aug 2010 13:02:37 -0000 1.116 +++ modules/node/content_types.inc 27 Aug 2010 15:58:26 -0000 @@ -430,7 +430,7 @@ function node_type_delete_confirm($form, $num_nodes = db_query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $type->type))->fetchField(); if ($num_nodes) { - $caption .= '

' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. If you remove this content type, you will not be able to edit the %type content and it may not display correctly.', '%type is used by @count pieces of content on your site. If you remove %type, you will not be able to edit the %type content and it may not display correctly.', array('%type' => $type->name)) . '

'; + $caption .= '

' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. If you remove this content type, your content will be deleted.', '%type is used by @count pieces of content on your site. If you remove %type, you will not be able to edit the %type content your content will be deleted. If you have a large amount of content the deletion will be queued and performed over time.', array('%type' => $type->name)) . '

'; } $caption .= '

' . t('This action cannot be undone.') . '

'; Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1293 diff -u -p -r1.1293 node.module --- modules/node/node.module 23 Aug 2010 22:15:34 -0000 1.1293 +++ modules/node/node.module 27 Aug 2010 15:58:26 -0000 @@ -163,6 +163,13 @@ function node_cron() { db_delete('history') ->condition('timestamp', NODE_NEW_LIMIT, '<') ->execute(); + + // Delete any nodes queued for deletion. + $queue = DrupalQueue::get('node_delete'); + if ($item = $queue->claimItem()) { + node_delete_multiple($item->data); + $queue->deleteItem($item); + } } /** @@ -1136,6 +1143,13 @@ function node_delete($nid) { */ function node_delete_multiple($nids) { if (!empty($nids)) { + if (count($nids) > 100) { + $jobs = array_chunk($nids, 100); + $nids = array_pop($jobs); + foreach ($jobs as $job) { + DrupalQueue::addJob('node_delete_multiple', array($job)); + } + } $nodes = node_load_multiple($nids, array()); foreach ($nodes as $nid => $node) { Index: modules/system/system.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v retrieving revision 1.187 diff -u -p -r1.187 system.api.php --- modules/system/system.api.php 22 Aug 2010 13:55:53 -0000 1.187 +++ modules/system/system.api.php 27 Aug 2010 15:58:26 -0000 @@ -423,7 +423,7 @@ function hook_cron() { * again an associative array. Possible keys are: * - 'worker callback': The name of the function to call. It will be called * with one argument, the item created via DrupalQueue::createItem() in - * hook_cron(). + * hook_cron(). If it returns TRUE, it will be queued for processing again. * - 'time': (optional) How much time Drupal should spend on calling this * worker in seconds. Defaults to 15. * Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.957 diff -u -p -r1.957 system.module --- modules/system/system.module 22 Aug 2010 13:52:58 -0000 1.957 +++ modules/system/system.module 27 Aug 2010 15:58:27 -0000 @@ -2857,6 +2857,25 @@ function system_cron() { } /** + * Implements hook_cron_queue_info(). + */ +function system_cron_queue_info() { + $queues['system_workers'] = array( + 'worker callback' => 'system_queue_worker', + 'time' => 15, + 'reliable' => TRUE, + ); + return $queues; +} + +/** + * Simple job queue worker. + */ +function system_queue_worker($data) { + return call_user_func_array($data['callback'], $data['arguments']); +} + +/** * Implements hook_flush_caches(). */ function system_flush_caches() { Index: modules/system/system.queue.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.queue.inc,v retrieving revision 1.13 diff -u -p -r1.13 system.queue.inc --- modules/system/system.queue.inc 14 Jun 2010 13:10:31 -0000 1.13 +++ modules/system/system.queue.inc 27 Aug 2010 15:58:27 -0000 @@ -93,6 +93,18 @@ class DrupalQueue { } return $queues[$name]; } + + /** + * Add a simple job to the queue. + * + * @param $callback + * The name of the function to be called when the queue is processed next. + * @param $arguments + * The arguments to the callback. + */ + public static function addJob($callback, $arguments = array()) { + return DrupalQueue::get('system_workers', TRUE)->createItem(array('callback' => $callback, 'arguments' => $arguments)); + } } interface DrupalQueueInterface { Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1196 diff -u -p -r1.1196 user.module --- modules/user/user.module 26 Aug 2010 09:14:33 -0000 1.1196 +++ modules/user/user.module 27 Aug 2010 15:58:27 -0000 @@ -2349,6 +2349,13 @@ function user_delete($uid) { */ function user_delete_multiple(array $uids) { if (!empty($uids)) { + if (count($uids) > 100) { + $jobs = array_chunk($uids, 100); + $uids = array_pop($jobs); + foreach ($jobs as $job) { + DrupalQueue::addJob('user_delete_multiple', array($job)); + } + } $accounts = user_load_multiple($uids, array()); foreach ($accounts as $uid => $account) {