Skip to content

Commit

Permalink
Merge branch 'MDL-78615' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov authored and andrewnicols committed Aug 29, 2023
2 parents 84b62bb + 8462e78 commit b327210
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cache/classes/local/administration_display_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

namespace core_cache\local;

defined('MOODLE_INTERNAL') || die();
use cache_store, cache_factory, cache_config_writer, cache_helper;
use core\output\notification;

/**
* A cache helper for administration tasks
Expand Down Expand Up @@ -505,9 +505,8 @@ public function action_editstore(): array {
* Performs the deletestore action.
*
* @param string $action the action calling to this function.
* @return void
*/
public function action_deletestore(string $action) {
public function action_deletestore(string $action): void {
global $OUTPUT, $PAGE, $SITE;
$notifysuccess = true;
$storeinstancesummaries = $this->get_store_instance_summaries();
Expand All @@ -517,10 +516,10 @@ public function action_deletestore(string $action) {

if (!array_key_exists($store, $storeinstancesummaries)) {
$notifysuccess = false;
$notifications[] = array(get_string('invalidstore', 'cache'), false);
$notification = get_string('invalidstore', 'cache');
} else if ($storeinstancesummaries[$store]['mappings'] > 0) {
$notifysuccess = false;
$notifications[] = array(get_string('deletestorehasmappings', 'cache'), false);
$notification = get_string('deletestorehasmappings', 'cache');
}

if ($notifysuccess) {
Expand All @@ -544,6 +543,8 @@ public function action_deletestore(string $action) {
$writer->delete_store_instance($store);
redirect($PAGE->url, get_string('deletestoresuccess', 'cache'), 5);
}
} else {
redirect($PAGE->url, $notification, null, notification::NOTIFY_ERROR);
}
}

Expand Down Expand Up @@ -731,9 +732,8 @@ public function action_newlockinstance(): array {
* Performs the delete lock action.
*
* @param string $action the action calling this function.
* @return void
*/
public function action_deletelock(string $action) {
public function action_deletelock(string $action): void {
global $OUTPUT, $PAGE, $SITE;
$notifysuccess = true;
$locks = $this->get_lock_summaries();
Expand All @@ -742,10 +742,10 @@ public function action_deletelock(string $action) {
$confirm = optional_param('confirm', false, PARAM_BOOL);
if (!array_key_exists($lock, $locks)) {
$notifysuccess = false;
$notifications[] = array(get_string('invalidlock', 'cache'), false);
$notification = get_string('invalidlock', 'cache');
} else if ($locks[$lock]['uses'] > 0) {
$notifysuccess = false;
$notifications[] = array(get_string('deletelockhasuses', 'cache'), false);
$notification = get_string('deletelockhasuses', 'cache');
}
if ($notifysuccess) {
if (!$confirm) {
Expand All @@ -768,6 +768,8 @@ public function action_deletelock(string $action) {
$writer->delete_lock_instance($lock);
redirect($PAGE->url, get_string('deletelocksuccess', 'cache'), 5);
}
} else {
redirect($PAGE->url, $notification, null, notification::NOTIFY_ERROR);
}
}

Expand Down

0 comments on commit b327210

Please sign in to comment.