From c740ac7fd58b5f4597bde987ae9263f3d05febd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Fri, 4 May 2007 09:41:37 +0000 Subject: #127539: progressive operation support, refactoring update.php code to a generic batch API to support runnning operations in multiple HTTP requests - update.php is already on the batch API - node access rebuilding is in the works - automatic locale importing is in the works Thanks to Yves Chedemois (yched) for the good code quality, very wide awareness of issues related to batches, and the fantastic turnaround times. Hats off. --- modules/system/page.tpl.php | 2 +- modules/system/system.install | 18 ++++++++++++++++++ modules/system/system.module | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/system/page.tpl.php b/modules/system/page.tpl.php index fce977e5f..5bf9e423b 100644 --- a/modules/system/page.tpl.php +++ b/modules/system/page.tpl.php @@ -41,7 +41,7 @@

- + diff --git a/modules/system/system.install b/modules/system/system.install index f409de7fa..7cf9b1979 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -190,6 +190,15 @@ function system_install() { UNIQUE KEY authname (authname) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {batch} ( + bid int(11) NOT NULL, + sid varchar(64) NOT NULL, + timestamp int(11) NOT NULL, + batch longtext, + PRIMARY KEY (bid), + KEY sid (sid) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {blocks} ( module varchar(64) DEFAULT '' NOT NULL, delta varchar(32) NOT NULL default '0', @@ -666,6 +675,15 @@ function system_install() { UNIQUE (authname) )"); + db_query("CREATE TABLE {batch} ( + bid int NOT NULL default '0', + sid varchar(64) NOT NULL default '', + timestamp int NOT NULL default '0', + batch text, + PRIMARY KEY (bid), + )"); + db_query("CREATE INDEX {batch}_sid_idx ON {batch} (sid)"); + db_query("CREATE TABLE {blocks} ( module varchar(64) DEFAULT '' NOT NULL, delta varchar(32) NOT NULL default '0', diff --git a/modules/system/system.module b/modules/system/system.module index fab91e2d6..a18439e07 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -327,6 +327,12 @@ function system_menu() { 'page callback' => 'system_sql', 'type' => MENU_CALLBACK, ); + // Default page for batch operations + $items['batch'] = array( + 'page callback' => 'system_batch_page', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); return $items; } @@ -2459,5 +2465,22 @@ function theme_system_admin_by_module($menu_items) { function system_cron() { // Cleanup the flood db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600); + // Cleanup the batch table + db_query('DELETE FROM {batch} WHERE timestamp < %d', time() - 864000); } +/** + * Default page callback for batches. + */ +function system_batch_page() { + require_once './includes/batch.inc'; + $output = _batch_page(); + if ($output === FALSE) { + drupal_access_denied(); + } + else { + // Force a page without blocks or messages to + // display a list of collected messages later. + print theme('page', $output, FALSE, FALSE); + } +} -- cgit v1.2.3