From a3627bb77d45d67ee99dd176fea395aef3e3728c Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 1 Oct 2006 16:17:30 +0000 Subject: [PATCH] incorrect context used in rss_client block upgrade code MDL-6707 - part of the upgrade code is now rerun in existing installations - new upgrades should be ok, the cleanup of stale contexts and overrides will be done later as part on normal maintenance from cron --- blocks/rss_client/block_rss_client.php | 2 +- blocks/rss_client/db/mysql.php | 13 +++++++++---- blocks/rss_client/db/postgres7.php | 11 ++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php index 8f78f10bc3f..d64a71a541f 100644 --- a/blocks/rss_client/block_rss_client.php +++ b/blocks/rss_client/block_rss_client.php @@ -19,7 +19,7 @@ function init() { $this->title = get_string('feedstitle', 'block_rss_client'); - $this->version = 2006091100; + $this->version = 2006100101; } function preferred_width() { diff --git a/blocks/rss_client/db/mysql.php b/blocks/rss_client/db/mysql.php index 3940e88be6f..91effa998e2 100644 --- a/blocks/rss_client/db/mysql.php +++ b/blocks/rss_client/db/mysql.php @@ -18,10 +18,10 @@ function rss_client_upgrade($oldversion) { if ($oldversion < 2006091100) { - + // We need a new field to store whether an RSS feed is shared or private. table_column('block_rss_client', '', 'shared', 'integer'); - + // Admin feeds used to be displayed to everybody (shared feeds). $admins = get_admins(); if (!empty($admins)) { @@ -42,7 +42,12 @@ function rss_client_upgrade($oldversion) { } } } - + } + +/// see MDL-6707 for more info about problem that was here + + if ($oldversion < 2006100101) { + // Upgrade block to use the Roles System. $block = get_record('block', 'name', 'rss_client'); @@ -65,7 +70,7 @@ function rss_client_upgrade($oldversion) { } foreach ($blockinstances as $bi) { - $context = get_context_instance(CONTEXT_MODULE, $bi->id); + $context = get_context_instance(CONTEXT_BLOCK, $bi->id); if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) { diff --git a/blocks/rss_client/db/postgres7.php b/blocks/rss_client/db/postgres7.php index 2659cb09656..e4e4b3e9606 100644 --- a/blocks/rss_client/db/postgres7.php +++ b/blocks/rss_client/db/postgres7.php @@ -20,10 +20,10 @@ function rss_client_upgrade($oldversion) { if ($oldversion < 2006091100) { - + // We need a new field to store whether an RSS feed is shared or private. table_column('block_rss_client', '', 'shared', 'integer'); - + // Admin feeds used to be displayed to everybody (shared feeds). $admins = get_admins(); if (!empty($admins)) { @@ -44,6 +44,11 @@ function rss_client_upgrade($oldversion) { } } } + } + +/// see MDL-6707 for more info about problem that was here + + if ($oldversion < 2006100101) { // Upgrade block to use the Roles System. $block = get_record('block', 'name', 'rss_client'); @@ -67,7 +72,7 @@ function rss_client_upgrade($oldversion) { } foreach ($blockinstances as $bi) { - $context = get_context_instance(CONTEXT_MODULE, $bi->id); + $context = get_context_instance(CONTEXT_BLOCK, $bi->id); if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) {