diff options
Diffstat (limited to 'mod/garbagecollector/start.php')
-rw-r--r-- | mod/garbagecollector/start.php | 101 |
1 files changed, 47 insertions, 54 deletions
diff --git a/mod/garbagecollector/start.php b/mod/garbagecollector/start.php index 26a462207..6267ab1ba 100644 --- a/mod/garbagecollector/start.php +++ b/mod/garbagecollector/start.php @@ -1,71 +1,64 @@ <?php - /** - * Elgg garbage collector. - * - * @package ElggGarbageCollector - */ +/** + * Elgg garbage collector. + * + * @package ElggGarbageCollector + */ - /** - * Initialise the plugin. - * - */ - function garbagecollector_init() - { - $period = get_plugin_setting('period','garbagecollector'); - switch ($period) - { - case 'weekly': - case 'monthly' : - case 'yearly' : - break; - default: $period = 'monthly'; - } +elgg_register_event_handler('init', 'system', 'garbagecollector_init'); - // Register cron hook - elgg_register_plugin_hook_handler('cron', $period, 'garbagecollector_cron'); +function garbagecollector_init() { + $period = get_plugin_setting('period', 'garbagecollector'); + switch ($period) { + case 'weekly': + case 'monthly': + case 'yearly': + break; + default: + $period = 'monthly'; } - /** - * Cron job - * - */ - function garbagecollector_cron($hook, $entity_type, $returnvalue, $params) - { - global $CONFIG; + // Register cron hook + elgg_register_plugin_hook_handler('cron', $period, 'garbagecollector_cron'); +} - echo elgg_echo('garbagecollector'); +/** + * Cron job + */ +function garbagecollector_cron($hook, $entity_type, $returnvalue, $params) { + global $CONFIG; - // Garbage collect metastrings - echo elgg_echo('garbagecollector:gc:metastrings'); + echo elgg_echo('garbagecollector'); - if (delete_orphaned_metastrings()!==false) { - echo elgg_echo('garbagecollector:ok'); - } else - echo elgg_echo('garbagecollector:error'); + // Garbage collect metastrings + echo elgg_echo('garbagecollector:gc:metastrings'); - echo "\n"; + if (delete_orphaned_metastrings() !== false) { + echo elgg_echo('garbagecollector:ok'); + } else { + echo elgg_echo('garbagecollector:error'); + } - // Now, because we are nice, trigger a plugin hook to let other plugins do some GC - $rv = true; - $period = get_plugin_setting('period','garbagecollector'); - elgg_trigger_plugin_hook('gc', 'system', array('period' => $period)); + echo "\n"; - // Now we optimize all tables - $tables = get_db_tables(); - foreach ($tables as $table) { - echo elgg_echo('garbagecollector:optimize', array($table)); + // Now, because we are nice, trigger a plugin hook to let other plugins do some GC + $rv = true; + $period = get_plugin_setting('period','garbagecollector'); + elgg_trigger_plugin_hook('gc', 'system', array('period' => $period)); - if (optimize_table($table)!==false) - echo elgg_echo('garbagecollector:ok'); - else - echo elgg_echo('garbagecollector:error'); + // Now we optimize all tables + $tables = get_db_tables(); + foreach ($tables as $table) { + echo elgg_echo('garbagecollector:optimize', array($table)); - echo "\n"; + if (optimize_table($table) !== false) { + echo elgg_echo('garbagecollector:ok'); + } else { + echo elgg_echo('garbagecollector:error'); } - echo elgg_echo('garbagecollector:done'); + echo "\n"; } - // Initialise plugin - elgg_register_event_handler('init','system','garbagecollector_init'); -?>
\ No newline at end of file + echo elgg_echo('garbagecollector:done'); +} |