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/languages/en.php | 36 ++++++++++ mod/garbagecollector/manifest.xml | 9 +++ mod/garbagecollector/start.php | 80 ++++++++++++++++++++++ .../default/settings/garbagecollector/edit.php | 20 ++++++ 4 files changed, 145 insertions(+) create mode 100644 mod/garbagecollector/languages/en.php create mode 100644 mod/garbagecollector/manifest.xml create mode 100644 mod/garbagecollector/start.php create mode 100644 mod/garbagecollector/views/default/settings/garbagecollector/edit.php (limited to 'mod/garbagecollector') diff --git a/mod/garbagecollector/languages/en.php b/mod/garbagecollector/languages/en.php new file mode 100644 index 000000000..21d5288a6 --- /dev/null +++ b/mod/garbagecollector/languages/en.php @@ -0,0 +1,36 @@ + 'How often should the Elgg garbage collector run?', + + 'garbagecollector:weekly' => 'Once a week', + 'garbagecollector:monthly' => 'Once a month', + 'garbagecollector:yearly' => 'Once a year', + + 'garbagecollector' => "GARBAGE COLLECTOR\n", + 'garbagecollector:done' => "DONE\n", + 'garbagecollector:optimize' => "Optimizing %s ", + + 'garbagecollector:error' => "ERROR", + 'garbagecollector:ok' => "OK", + + 'garbagecollector:gc:metastrings' => 'Cleaning up unlinked metastrings: ', + + ); + + add_translation("en",$english); +?> \ No newline at end of file diff --git a/mod/garbagecollector/manifest.xml b/mod/garbagecollector/manifest.xml new file mode 100644 index 000000000..5533bc537 --- /dev/null +++ b/mod/garbagecollector/manifest.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file 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 diff --git a/mod/garbagecollector/views/default/settings/garbagecollector/edit.php b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php new file mode 100644 index 000000000..19ae3d245 --- /dev/null +++ b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php @@ -0,0 +1,20 @@ +period; + if (!$period) $period = 'monthly'; + +?> +

+ + + 'params[period]', + 'options_values' => array( + 'weekly' => elgg_echo('garbagecollector:weekly'), + 'monthly' => elgg_echo('garbagecollector:monthly'), + 'yearly' => elgg_echo('garbagecollector:yearly'), + ), + 'value' => $period + )); + ?> +

-- cgit v1.2.3