From deb6d87e725df4231cf068d2f56ec916985eb5e0 Mon Sep 17 00:00:00 2001 From: Daniel Thee Roperto Date: Tue, 8 Nov 2016 11:56:11 +1100 Subject: [PATCH] Issue #73 - Could not reproduce the issue but this fix should work. - Added a fixed timestamp to get both planned/past outages, unlikely to happen outsite debugging environment but it could have a timing problem when fetching each list of outages. - Changed the query to get ended queries to be a the conditions of NOT a past outage. I believe the old query was equivalent but that should rule out a query problem. --- classes/dml/outagedb.php | 2 +- manage.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index cad6f73..1098a91 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -256,7 +256,7 @@ class outagedb { $rs = $DB->get_recordset_select( 'auth_outage', - ':datetime1 >= stoptime OR (finished IS NOT NULL AND :datetime2 >= finished)', + 'NOT (:datetime1 < stoptime AND (finished IS NULL OR :datetime2 < finished))', ['datetime1' => $time, 'datetime2' => $time], 'stoptime DESC, starttime DESC, title ASC', '*'); diff --git a/manage.php b/manage.php index 775d47b..510661c 100644 --- a/manage.php +++ b/manage.php @@ -34,9 +34,12 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php')); echo $OUTPUT->header(); +// Give it a consistent time so all outages are listed. Useful when debugging. +$now = time(); + renderer::get()->output_view('manage.php', [ - 'unended' => outagedb::get_all_unended(), - 'ended' => outagedb::get_all_ended(), + 'unended' => outagedb::get_all_unended($now), + 'ended' => outagedb::get_all_ended($now), ]); echo $OUTPUT->footer();