From fc54e5c809b53013481d8874376b1fae0db95237 Mon Sep 17 00:00:00 2001 From: Qihui Chan Date: Sun, 15 May 2022 16:02:32 +1000 Subject: [PATCH] [fix] phpunit test --- classes/dml/outagecache.php | 10 ++++++---- classes/dml/outagedb.php | 4 ++-- version.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/classes/dml/outagecache.php b/classes/dml/outagecache.php index 62a7585..0398cdb 100644 --- a/classes/dml/outagecache.php +++ b/classes/dml/outagecache.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - - namespace auth_outage\dml; defined('MOODLE_INTERNAL') || die(); @@ -42,7 +40,7 @@ class outagecache{ /** * Set active outage cache. * - * @param outage|null $next_outage Next outage to save. + * @param outage|null $next_outage Next outage to save, null for not setting outage. */ public static function set_active_outage_cache($next_outage = null) { $cache = \cache::make('auth_outage', 'cache_active_outage_data'); @@ -51,6 +49,8 @@ class outagecache{ /** * Get active outage cache. + * + * @return outage|null Return the outage or null if cache not setted. */ public static function get_active_outage_cache() { $cache = \cache::make('auth_outage', 'cache_active_outage_data'); @@ -60,7 +60,7 @@ class outagecache{ /** * Set onging outage cache. * - * @param outage|null $next_outage Onging outage to save. + * @param outage|null $onging_outage Onging outage to save, null for not setting outage. */ public static function set_ongoing_outage_cache($onging_outage = null) { $cache = \cache::make('auth_outage', 'cache_ongoing_outage_data'); @@ -69,6 +69,8 @@ class outagecache{ /** * Get onging outage cache. + * + * @return outage|null Return the outage or null if cache not setted. */ public static function get_ongoing_outage_cache() { $cache = \cache::make('auth_outage', 'cache_ongoing_outage_data'); diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index b7b0b35..5801cd6 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -151,7 +151,7 @@ class outagedb { } // Set the next starting outage to cache after an outage is saved in db. - outagecache::set_active_outage_cache(self::get_next_starting()); + outagecache::set_active_outage_cache(self::get_ongoing() ?? self::get_next_starting()); // Trigger outages modified events. outagelib::prepare_next_outage(true); @@ -193,7 +193,7 @@ class outagedb { calendar::delete($id); // Set the next starting outage to cache after an outage is deleted in db. - outagecache::set_active_outage_cache(self::get_next_starting()); + outagecache::set_active_outage_cache(self::get_ongoing() ?? self::get_next_starting()); // Trigger events. outagelib::prepare_next_outage(); diff --git a/version.php b/version.php index ca2033e..6b9e46d 100644 --- a/version.php +++ b/version.php @@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = "auth_outage"; -$plugin->version = 2022120500; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022120502; // The current plugin version (Date: YYYYMMDDXX). $plugin->release = 2022120500; // Human-readable release information. $plugin->requires = 2017111309; // 2017111309 = T13, but this really requires 3.9 and higher. $plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!