diff --git a/admin/blocks.php b/admin/blocks.php
index 3b296beeb9f..9e89eb65c56 100644
--- a/admin/blocks.php
+++ b/admin/blocks.php
@@ -182,7 +182,12 @@
$settings = ''.$strsettings.'';
}
- $count = count_records('block_instance', 'blockid', $blockid);
+ // MDL-11167, blocks can be placed on mymoodle, or the blogs page
+ // and it should not show up on course search page
+ $count = count_records_sql('SELECT COUNT(*)
+ FROM '.$CFG->prefix.'block_instance
+ WHERE blockid = '.$blockid.' AND
+ pagetype = "course-view"');
if ($count>0) {
$blocklist = "wwwroot}/course/search.php?blocklist=$blockid&sesskey={$USER->sesskey}\" ";
$blocklist .= "title=\"$strshowblockcourse\" >$count";
diff --git a/course/search.php b/course/search.php
index c7ff0d658f3..a497cee6985 100644
--- a/course/search.php
+++ b/course/search.php
@@ -131,7 +131,9 @@
$courses = array();
foreach ($blocks as $block) {
$courseid = $block->pageid;
- if ($courseid==0) {
+ // MDL-11167, blocks can be placed on mymoodle, or the blogs page
+ // and it should not show up on course search page
+ if ($courseid==0 || $block->pagetype != 'course-view') {
continue;
}
if (!$course = get_record('course', 'id', $courseid)) {