Add conditions before calling update_maintenance_later() #172.

This commit is contained in:
Mikhail Golenkov
2020-02-04 16:11:17 +11:00
parent 10223da351
commit a906f993f0
2 changed files with 12 additions and 3 deletions

View File

@@ -135,7 +135,7 @@ class outagedb {
}
// Trigger outages modified events.
outagelib::prepare_next_outage();
outagelib::prepare_next_outage(true);
// All done, return the id.
return $outage->id;

View File

@@ -163,16 +163,25 @@ class outagelib {
/**
* Executed when outages are modified (created, updated or deleted).
*
* @param bool $reenablemaint should we re-enable maintenance mode for ongoing outage
* @throws coding_exception
* @throws file_exception
*/
public static function prepare_next_outage() {
public static function prepare_next_outage($reenablemaint = false) {
// If there is an ongoing outage, prepare it instead.
$outage = outagedb::get_ongoing();
if (is_null($outage)) {
$outage = outagedb::get_next_starting();
$ongoingoutage = false;
} else {
$ongoingoutage = true;
}
maintenance_static_page::create_from_outage($outage)->generate();
self::update_climaintenance_code($outage);
self::update_maintenance_later($outage);
if (!$ongoingoutage || $reenablemaint || is_null($outage)) {
self::update_maintenance_later($outage);
}
}
private static function check_wwwroot_accessible() {