From bf8c71b7fd9c38c6192f0130dd569b17548b5378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Tue, 9 Jul 2013 07:37:35 +0200 Subject: [PATCH] MDL-40571 work around block editing hacks on admin page --- admin/index.php | 5 +++-- lib/adminlib.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/admin/index.php b/admin/index.php index 9acf551fdd6..1e9e810aa91 100644 --- a/admin/index.php +++ b/admin/index.php @@ -47,10 +47,11 @@ if (!function_exists('iconv')) { 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 @@ -449,7 +450,7 @@ if (during_initial_install()) { // 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))); } diff --git a/lib/adminlib.php b/lib/adminlib.php index 4a76f82c164..5f4d0b24468 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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')); }