From 474144e6ba90c5cb5bb99ad03c81aba71ccfa8c1 Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 28 Oct 2008 17:50:36 +0000 Subject: Introducing the Elgg garbage collector. git-svn-id: https://code.elgg.org/elgg/trunk@2336 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/garbagecollector/start.php | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 mod/garbagecollector/start.php (limited to 'mod/garbagecollector/start.php') diff --git a/mod/garbagecollector/start.php b/mod/garbagecollector/start.php new file mode 100644 index 000000000..f92248cc0 --- /dev/null +++ b/mod/garbagecollector/start.php @@ -0,0 +1,80 @@ +dbprefix}metastrings where + ( + (id not in (select name_id from {$CONFIG->dbprefix}metadata)) AND + (id not in (select value_id from {$CONFIG->dbprefix}metadata)) AND + (id not in (select name_id from {$CONFIG->dbprefix}annotations)) AND + (id not in (select value_id from {$CONFIG->dbprefix}annotations)) + )"; + if (delete_data($query)!==false) { + $resulttext .= elgg_echo('garbagecollector:ok'); + } else + $resulttext .= elgg_echo('garbagecollector:error'); + + $resulttext .= "\n"; + + // Now we optimize all tables + $tables = get_db_tables(); + foreach ($tables as $table) { + $resulttext .= sprintf(elgg_echo('garbagecollector:optimize'), $table); + + if (update_data("optimize table $table")!==false) + $resulttext .= elgg_echo('garbagecollector:ok'); + else + $resulttext .= elgg_echo('garbagecollector:error'); + + $resulttext .= "\n"; + } + + $resulttext .= elgg_echo('garbagecollector:done'); + + return $returnvalue . $resulttext; + } + + // Initialise plugin + register_elgg_event_handler('init','system','garbagecollector_init'); +?> \ No newline at end of file -- cgit v1.2.3