MDL-45724 cache: added cache API warnings to the admin notifications page

This commit is contained in:
Sam Hemelryk
2014-07-21 09:49:45 +12:00
parent 7bc4ca8b88
commit f7a54f619a
6 changed files with 61 additions and 16 deletions
+24
View File
@@ -735,4 +735,28 @@ class cache_helper {
}
return $stores;
}
/**
* Returns an array of warnings from the cache API.
*
* The warning returned here are for things like conflicting store instance configurations etc.
* These get shown on the admin notifications page for example.
*
* @param array|null $stores An array of stores to get warnings for, or null for all.
* @return string[]
*/
public static function warnings(array $stores = null) {
global $CFG;
if ($stores === null) {
require_once($CFG->dirroot.'/cache/locallib.php');
$stores = cache_administration_helper::get_store_instance_summaries();
}
$warnings = array();
foreach ($stores as $store) {
if (!empty($store['warnings'])) {
$warnings = array_merge($warnings, $store['warnings']);
}
}
return $warnings;
}
}
+5 -1
View File
@@ -345,7 +345,11 @@ abstract class cache_store implements cache_store_interface {
* This should be used to notify things like configuration conflicts etc.
* The warnings returned here will be displayed on the cache configuration screen.
*
* @return string[] Returns an array of warnings (strings)
* @return array[] Returns an array of arrays with the format:
* $notifications = array(
* array('This is a success message', true),
* array('This is a failure message', false),
* );
*/
public function get_warnings() {
return array();