From fe2577d19792e6b78c1821ed503fe78456035a6d 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 c54e8388791..32f22c40c63 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); } @@ -443,7 +444,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 26c0d0fd2ac..3156783e5d5 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -6364,10 +6364,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')); }