Permalink
Browse files

Slightly simplify cron interface

  • Loading branch information...
flack committed Oct 8, 2017
1 parent 8f34216 commit a6f8e16fcaac4dd1f1ea74b7a8d4737968cf05a4
@@ -47,21 +47,13 @@ public function _on_initialize()
return true;
}
/**
* Execute the handler, this calls the corresponding event handler.
*/
public function execute()
{
$this->_on_execute();
}
/**
* This is the actual handler operation, it is called only after successful operation.
* You should use the print_error() helper of this class in case you need to notify
* the user of any errors. As long as everything goes fine, you should not print anything
* to avoid needles cron mailings.
* to avoid needless cron mailings.
*/
abstract public function _on_execute();
abstract public function execute();
/**
* Echo the error message to the client, automatically appending
@@ -11,7 +11,7 @@
*/
class midcom_cron_loginservice extends midcom_baseclasses_components_cron_handler
{
public function _on_execute()
public function execute()
{
if (midcom::get()->config->get('auth_login_session_timeout')) {
$qb = new midgard_query_builder('midcom_core_login_session_db');
@@ -39,7 +39,7 @@ public function get_classes()
return $classes;
}
public function _on_execute()
public function execute()
{
$cut_off = $this->get_cutoff();
debug_add('Purging entries deleted before ' . gmdate('Y-m-d H:i:s', $cut_off) . "\n");
@@ -20,7 +20,7 @@ class midcom_services_at_cron_check extends midcom_baseclasses_components_cron_h
*
* @todo: refactor to use more modern MidCOM interfaces and better sanity-checking
*/
public function _on_execute()
public function execute()
{
$qb = midcom_services_at_entry_dba::new_query_builder();
$qb->add_constraint('start', '<=', time());
@@ -16,7 +16,7 @@ class midcom_services_at_cron_clean extends midcom_baseclasses_components_cron_h
/**
* Loads all entries that need to be processed and processes them.
*/
public function _on_execute()
public function execute()
{
$qb = midcom_services_at_entry_dba::new_query_builder();
// (to be) start(ed) AND last touched over two days ago
@@ -50,7 +50,7 @@
* return true;
* }
*
* function _on_execute()
* function execute()
* {
* $this->print_error("Executing...");
* $this->print_error(strftime('%x %X'));
@@ -13,7 +13,7 @@
*/
class net_nehmer_comments_cron_atom extends midcom_baseclasses_components_cron_handler
{
public function _on_execute()
public function execute()
{
if (!$this->_config->get('atom_comments_import_enable')) {
debug_add('Import of Atom comment feeds disabled, aborting', MIDCOM_LOG_INFO);
@@ -15,7 +15,7 @@ class net_nemein_rss_cron_fetchfeeds extends midcom_baseclasses_components_cron_
/**
* Fetches subscribed feeds and imports them
*/
public function _on_execute()
public function execute()
{
if (!midcom::get()->auth->request_sudo('net.nemein.rss')) {
$this->print_error("Could not get sudo, aborting operation, see error log for details");
@@ -15,7 +15,7 @@ class net_nemein_tag_cron_clean extends midcom_baseclasses_components_cron_handl
/**
* Find all old temporary reports and clear them.
*/
public function _on_execute()
public function execute()
{
midcom::get()->auth->request_sudo('net.nemein.tag');
$qb_tags = net_nemein_tag_tag_dba::new_query_builder();
@@ -37,7 +37,7 @@ public function _on_initialize()
* for each participant (who is task resource) towards
* said task.
*/
public function _on_execute()
public function execute()
{
if (!midcom::get()->auth->request_sudo('org.openpsa.calendar')) {
$this->print_error("Could not get sudo, aborting operation, see error log for details");
@@ -16,7 +16,7 @@ class org_openpsa_contacts_cron_duplicates_clean extends midcom_baseclasses_comp
/**
* Find hanging duplicate marks (that no longer point anywhere) and clear them
*/
public function _on_execute()
public function execute()
{
if (!$this->_config->get('enable_duplicate_search')) {
debug_add('Duplicate operations disabled, aborting', MIDCOM_LOG_INFO);
@@ -15,7 +15,7 @@ class org_openpsa_contacts_cron_duplicates_mark extends midcom_baseclasses_compo
/**
* Find possible duplicates and mark them
*/
public function _on_execute()
public function execute()
{
if (!$this->_config->get('enable_duplicate_search')) {
debug_add('Duplicate search disabled, aborting', MIDCOM_LOG_INFO);
@@ -16,7 +16,7 @@ class org_openpsa_directmarketing_cron_cleanup extends midcom_baseclasses_compon
/**
* Find all old entries and delete them.
*/
public function _on_execute()
public function execute()
{
if (!$this->_config->get('delete_older')) {
return;
@@ -29,7 +29,7 @@ public function _on_initialize()
/**
* Find all old send tokens and clear them.
*/
public function _on_execute()
public function execute()
{
//Disable limits, TODO: think if this could be done in smaller chunks to save memory.
midcom::get()->disable_limits();
@@ -16,7 +16,7 @@ class org_openpsa_directmarketing_cron_updatemembers extends midcom_baseclasses_
/**
* Loads all (not-archived) smart campaigns and schedules a separate background update for each
*/
public function _on_execute()
public function execute()
{
$qb = org_openpsa_directmarketing_campaign_dba::new_query_builder();
$qb->add_constraint('archived', '=', 0);
@@ -30,7 +30,7 @@ public function _on_initialize()
/**
* Find all old temporary reports and clear them.
*/
public function _on_execute()
public function execute()
{
//Disable limits, TODO: think if this could be done in smaller chunks to save memory.
midcom::get()->disable_limits();

0 comments on commit a6f8e16

Please sign in to comment.