public function _on_execute() { midcom::get('dbclassloader')->load_classes('midcom', 'core_classes.inc', null, true); $qb = midcom_core_temporary_object::new_query_builder(); $qb->add_constraint('timestamp', '<', time() - $GLOBALS['midcom_config']['midcom_temporary_resource_timeout']); $qb->set_limit(500); $result = $qb->execute(); foreach ($result as $tmp) { if (!$tmp->delete()) { // Print and log error $msg = "Failed to delete temporary object {$tmp->id}, last Midgard error was: " . midcom_connection::get_error_string(); $this->print_error($msg); debug_add($msg, MIDCOM_LOG_ERROR); debug_print_r('Tried to delete this object:', $tmp); } else { debug_add("Deleted temporary object {$tmp->id}."); } } }