Skip to content

Commit

Permalink
MDL-40571 work around block editing hacks on admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 12, 2013
1 parent 07bbbcf commit bf8c71b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions admin/index.php
Expand Up @@ -47,10 +47,11 @@

define('NO_OUTPUT_BUFFERING', true);

if (empty($_GET['cache']) and empty($_POST['cache'])) {
if (empty($_GET['cache']) and empty($_POST['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey'])) {
// Prevent caching at all cost when visiting this page directly,
// we redirect to self once we known no upgrades are necessary.
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
// Note2: the sesskey is present in all block editing hacks, we can not redirect there, so enable caching.
define('CACHE_DISABLE_ALL', true);

// Force OPcache reset if used, we do not want any stale caches
Expand Down Expand Up @@ -449,7 +450,7 @@

// Now we can be sure everything was upgraded and caches work fine,
// redirect if necessary to make sure caching is enabled.
if (!$cache) {
if (!$cache and !optional_param('sesskey', '', PARAM_RAW)) {
redirect(new moodle_url($PAGE->url, array('cache' => 1)));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/adminlib.php
Expand Up @@ -6343,10 +6343,10 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
if ($PAGE->user_allowed_editing()) {
if ($PAGE->user_is_editing()) {
$caption = get_string('blockseditoff');
$url = new moodle_url($PAGE->url, array('adminedit'=>'0'));
$url = new moodle_url($PAGE->url, array('adminedit'=>'0', 'sesskey'=>sesskey()));
} else {
$caption = get_string('blocksediton');
$url = new moodle_url($PAGE->url, array('adminedit'=>'1'));
$url = new moodle_url($PAGE->url, array('adminedit'=>'1', 'sesskey'=>sesskey()));
}
$PAGE->set_button($OUTPUT->single_button($url, $caption, 'get'));
}
Expand Down

0 comments on commit bf8c71b

Please sign in to comment.