Skip to content

Commit

Permalink
MDL-56347 caching: Better class variables for notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-russ authored and Rajesh Taneja committed Oct 25, 2016
1 parent ca08b73 commit a14e796
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cache/tests/fixtures/lib.php
Expand Up @@ -535,6 +535,11 @@ public static function phpunit_disable() {
parent::disable();
}

/**
* @var bool Whether the warning notice about alternative cache store used has been displayed.
*/
protected $altcachestorenotice = false;

/**
* Creates a store instance given its name and configuration.
*
Expand All @@ -547,8 +552,6 @@ public static function phpunit_disable() {
*/
public function create_store_from_config($name, array $details, cache_definition $definition) {

static $noticeshown = false;

if (isset($details['use_test_store'])) {
// name, plugin, alt
$class = 'cachestore_'.$details['plugin'];
Expand All @@ -562,10 +565,10 @@ public function create_store_from_config($name, array $details, cache_definition
}

// Notify user that alternative store is being used, so action can be taken.
if (!$noticeshown) {
if (!$this->altcachestorenotice) {
echo PHP_EOL . "++ WARNING: " . 'Failed to use "' . $details['plugin'] . '" cache store, alt "' .
$details['alt']['plugin'] . '" cache store is used.' . PHP_EOL . PHP_EOL;
$noticeshown = true;
$this->altcachestorenotice = true;
}
$details = $details['alt'];
$details['class'] = 'cachestore_'.$details['plugin'];
Expand Down

0 comments on commit a14e796

Please sign in to comment.