Moodle

MDL-10573 breaks sticky blocks

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9, 2.0
  • Component/s: Blocks
  • Labels:
    None
  • Environment:
    moodle 1.9
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

The specific code is in this revision: http://moodle.cvs.sourceforge.net/moodle/moodle/blocks/moodleblock.class.php?r1=1.88&r2=1.89

get_context_instance(); doesn't work for sticky blocks (MDL-10977).

The result is that sticky blocks won't show and you'll get an error message like 'Error: could not insert new context level "80", instance "1".'

Issue Links

Activity

Hide
Alan Trick added a comment -

was caused by

Show
Alan Trick added a comment - was caused by
Hide
Dan Poltawski added a comment -

Hi, Is this issue still present in latest 1.9?

I can't seem to reproduce it, so if you could give steps that would be useful.

Show
Dan Poltawski added a comment - Hi, Is this issue still present in latest 1.9? I can't seem to reproduce it, so if you could give steps that would be useful.
Hide
Stephen Bourget added a comment -

I'm no longer seeing this issue on my Moodle 1.9 test site.
It was appearing up until recently for any block that had it's own access.php file

Show
Stephen Bourget added a comment - I'm no longer seeing this issue on my Moodle 1.9 test site. It was appearing up until recently for any block that had it's own access.php file
Hide
Alan Trick added a comment -

It just happens when upgrading to 1.9. When I reported this bug we were only using one block (calendar_month). Since then we added the news_items block (on our 1.8 installation). I just did another upgrade today and the caledar_month block had problems, but the news_items block was fine. Going to /admin/stickyblocks.php?pt=my-index and removing the block and adding it again fixes the error.

Show
Alan Trick added a comment - It just happens when upgrading to 1.9. When I reported this bug we were only using one block (calendar_month). Since then we added the news_items block (on our 1.8 installation). I just did another upgrade today and the caledar_month block had problems, but the news_items block was fine. Going to /admin/stickyblocks.php?pt=my-index and removing the block and adding it again fixes the error.
Hide
JDS added a comment - - edited

I have 05/Dec/07 1.9 beta version, and I confirm that this problems is still there.

Show
JDS added a comment - - edited I have 05/Dec/07 1.9 beta version, and I confirm that this problems is still there.
Hide
Robert Russo added a comment -

also this causes the issue where you cannot see the editing controls for the block.

case 'course-view':
if (!has_capability('moodle/site:manageblocks', $blockcontext)) { return null; }

Show
Robert Russo added a comment - also this causes the issue where you cannot see the editing controls for the block. case 'course-view': if (!has_capability('moodle/site:manageblocks', $blockcontext)) { return null; }
Hide
Robert Russo added a comment -

it seems as if all 3 function is_empty() are to blame.

function is_empty() {

$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);

if ( !has_capability('moodle/block:view', $context) ) { return true; }

$this->get_content();
return (empty($this->content->items) && empty($this->content->footer));
}

Removing this:

if ( !has_capability('moodle/block:view', $context) ) { return true; } }

resolves all issues, this still needs to be fixed correctly and not just hacked out.

Show
Robert Russo added a comment - it seems as if all 3 function is_empty() are to blame. function is_empty() { $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id); if ( !has_capability('moodle/block:view', $context) ) { return true; } $this->get_content(); return (empty($this->content->items) && empty($this->content->footer)); } Removing this: if ( !has_capability('moodle/block:view', $context) ) { return true; } } resolves all issues, this still needs to be fixed correctly and not just hacked out.
Hide
Petr Škoda (skodak) added a comment -

should be fixed now, please test - the pinned blocks now use system context
thanks for the report

Show
Petr Škoda (skodak) added a comment - should be fixed now, please test - the pinned blocks now use system context thanks for the report

People

Vote (3)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: