Merge branch 'w37_MDL-35318_m24_stringrevisions' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2012-09-10 20:39:19 +02:00
commit a8cdd8758b
5 changed files with 66 additions and 10 deletions

View file

@ -129,8 +129,10 @@ class tinymce_texteditor extends texteditor {
$fontselectlist = empty($config->fontselectlist) ? '' : $config->fontselectlist; $fontselectlist = empty($config->fontselectlist) ? '' : $config->fontselectlist;
// TODO: MDL-35318 somehow implement cache invalidation - we need to get lang revision somehow and sync purging.
$langrev = -1; $langrev = -1;
if (!empty($CFG->cachejs)) {
$langrev = get_string_manager()->get_revision();
}
$params = array( $params = array(
'moodle_config' => $config, 'moodle_config' => $config,

View file

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012090700; // The current plugin version (Date: YYYYMMDDXX) $plugin->version = 2012090900; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012083100; // Requires this Moodle version $plugin->requires = 2012083100; // Requires this Moodle version
$plugin->component = 'editor_tinymce'; // Full name of the plugin (used for diagnostics) $plugin->component = 'editor_tinymce'; // Full name of the plugin (used for diagnostics)
$plugin->release = '3.6.0'; // This is NOT a directory name, see lib.php if you need to know where is the editor code! $plugin->release = '3.6.0'; // This is NOT a directory name, see lib.php if you need to know where is the editor code!

View file

@ -6371,8 +6371,16 @@ interface string_manager {
/** /**
* Invalidates all caches, should the implementation use any * Invalidates all caches, should the implementation use any
* @param bool $phpunitreset true means called from our PHPUnit integration test reset
*/ */
public function reset_caches(); public function reset_caches($phpunitreset = false);
/**
* Returns string revision counter, this is incremented after any
* string cache reset.
* @return int lang string revision counter, -1 if unknown
*/
public function get_revision();
} }
@ -6938,8 +6946,9 @@ class core_string_manager implements string_manager {
/** /**
* Clears both in-memory and on-disk caches * Clears both in-memory and on-disk caches
* @param bool $phpunitreset true means called from our PHPUnit integration test reset
*/ */
public function reset_caches() { public function reset_caches($phpunitreset = false) {
global $CFG; global $CFG;
require_once("$CFG->libdir/filelib.php"); require_once("$CFG->libdir/filelib.php");
@ -6949,11 +6958,41 @@ class core_string_manager implements string_manager {
// clear the in-memory cache of loaded strings // clear the in-memory cache of loaded strings
$this->cache = array(); $this->cache = array();
if (!$phpunitreset) {
// Increment the revision counter.
$langrev = get_config('core', 'langrev');
$next = time();
if ($langrev !== false and $next <= $langrev and $langrev - $next < 60*60) {
// This resolves problems when reset is requested repeatedly within 1s,
// the < 1h condition prevents accidental switching to future dates
// because we might not recover from it.
$next = $langrev+1;
}
set_config('langrev', $next);
}
// clear the cache containing the list of available translations // clear the cache containing the list of available translations
// and re-populate it again // and re-populate it again
fulldelete($this->menucache); fulldelete($this->menucache);
$this->get_list_of_translations(true); $this->get_list_of_translations(true);
} }
/**
* Returns string revision counter, this is incremented after any
* string cache reset.
* @return int lang string revision counter, -1 if unknown
*/
public function get_revision() {
global $CFG;
if (!$this->usediskcache) {
return -1;
}
if (isset($CFG->langrev)) {
return (int)$CFG->langrev;
} else {
return -1;
}
}
} }
@ -7168,8 +7207,20 @@ class install_string_manager implements string_manager {
/** /**
* This implementation does not use any caches * This implementation does not use any caches
* @param bool $phpunitreset true means called from our PHPUnit integration test reset
*/ */
public function reset_caches() {} public function reset_caches($phpunitreset = false) {
// Nothing to do.
}
/**
* Returns string revision counter, this is incremented after any
* string cache reset.
* @return int lang string revision counter, -1 if unknown
*/
public function get_revision() {
return -1;
}
} }

View file

@ -609,7 +609,8 @@ class phpunit_util {
// reset all static caches // reset all static caches
accesslib_clear_all_caches(true); accesslib_clear_all_caches(true);
get_string_manager()->reset_caches(); get_string_manager()->reset_caches(true);
reset_text_filters_cache(true);
events_get_handlers('reset'); events_get_handlers('reset');
textlib::reset_caches(); textlib::reset_caches();
if (class_exists('repository')) { if (class_exists('repository')) {

View file

@ -1227,14 +1227,16 @@ function format_text($text, $format = FORMAT_MOODLE, $options = NULL, $courseid_
/** /**
* Resets all data related to filters, called during upgrade or when filter settings change. * Resets all data related to filters, called during upgrade or when filter settings change.
* *
* @global object * @param bool $phpunitreset true means called from our PHPUnit integration test reset
* @global object
* @return void * @return void
*/ */
function reset_text_filters_cache() { function reset_text_filters_cache($phpunitreset = false) {
global $CFG, $DB; global $CFG, $DB;
$DB->delete_records('cache_text'); if (!$phpunitreset) {
$DB->delete_records('cache_text');
}
$purifdir = $CFG->cachedir.'/htmlpurifier'; $purifdir = $CFG->cachedir.'/htmlpurifier';
remove_dir($purifdir, true); remove_dir($purifdir, true);
} }