mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-60815 theme: fix loading editor styles
This commit is contained in:
parent
f5b956679e
commit
bb8bb8e41c
@ -897,6 +897,14 @@ class theme_config {
|
||||
global $CFG;
|
||||
$rev = theme_get_revision();
|
||||
if ($rev > -1) {
|
||||
$themesubrevision = theme_get_sub_revision_for_theme($this->name);
|
||||
|
||||
// Provide the sub revision to allow us to invalidate cached theme CSS
|
||||
// on a per theme basis, rather than globally.
|
||||
if ($themesubrevision && $themesubrevision > 0) {
|
||||
$rev .= "_{$themesubrevision}";
|
||||
}
|
||||
|
||||
$url = new moodle_url("/theme/styles.php");
|
||||
if (!empty($CFG->slasharguments)) {
|
||||
$url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
|
||||
|
@ -153,4 +153,26 @@ class core_theme_config_testcase extends advanced_testcase {
|
||||
$this->assertTrue(core_useragent::set_user_device_type('tablet'));
|
||||
$this->assertTrue(core_useragent::set_user_device_type('featurephone'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that the editor_css_url contains the theme revision and the
|
||||
* theme subrevision if not in theme designer mode.
|
||||
*/
|
||||
public function test_editor_css_url_has_revision_and_subrevision() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$theme = theme_config::load(theme_config::DEFAULT_THEME);
|
||||
$themename = $theme->name;
|
||||
$themerevision = 1234;
|
||||
$themesubrevision = 5678;
|
||||
|
||||
$CFG->themedesignermode = false;
|
||||
$CFG->themerev = $themerevision;
|
||||
|
||||
theme_set_sub_revision_for_theme($themename, $themesubrevision);
|
||||
$url = $theme->editor_css_url();
|
||||
|
||||
$this->assertRegExp("/{$themerevision}_{$themesubrevision}/", $url->out(false));
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +69,7 @@ $values = explode('_', $rev);
|
||||
$rev = min_clean_param(array_shift($values), 'INT');
|
||||
$themesubrev = array_shift($values);
|
||||
|
||||
if (is_null($themesubrev)) {
|
||||
// Default to the current theme subrevision if one isn't
|
||||
// provided in the URL.
|
||||
$themesubrev = theme_get_sub_revision_for_theme($themename);
|
||||
} else {
|
||||
if (!is_null($themesubrev)) {
|
||||
$themesubrev = min_clean_param($themesubrev, 'INT');
|
||||
}
|
||||
|
||||
@ -144,12 +140,12 @@ make_localcache_directory('theme', false);
|
||||
|
||||
if ($type === 'editor') {
|
||||
$csscontent = $theme->get_css_content_editor();
|
||||
css_store_css($theme, $candidatesheet, $csscontent, false);
|
||||
|
||||
if ($cache) {
|
||||
css_store_css($theme, $candidatesheet, $csscontent, false);
|
||||
css_send_cached_css($candidatesheet, $etag);
|
||||
} else {
|
||||
css_send_uncached_css(file_get_contents($candidatesheet));
|
||||
css_send_uncached_css($csscontent);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user