Moodle
  1. Moodle
  2. MDL-29274

People block returns wrong context to user/index.php if block added to module

    Details

    • Rank:
      18815

      Description

      try adding the people block to a forum. then click on the participants link inside it..
      it throws a context error. This seems to be a regression, it was reported and fixed in MDL-13252.

        Issue Links

          Activity

          Aparup Banerjee created issue -
          Aparup Banerjee made changes -
          Field Original Value New Value
          Link This issue is a clone of MDL-13252 [ MDL-13252 ]
          Michael de Raadt made changes -
          Fix Version/s STABLE backlog [ 10463 ]
          Labels triaged
          Michael de Raadt made changes -
          Link This issue is duplicated by MDL-29452 [ MDL-29452 ]
          Hide
          Michael de Raadt added a comment -

          Increasing the priority on this as it has now been replicated.

          Show
          Michael de Raadt added a comment - Increasing the priority on this as it has now been replicated.
          Michael de Raadt made changes -
          Priority Minor [ 4 ] Critical [ 2 ]
          Chris Follin made changes -
          Labels triaged moodlerooms partner triaged
          Michael de Raadt made changes -
          Fix Version/s STABLE Sprint 18 [ 11650 ]
          Fix Version/s STABLE backlog [ 10463 ]
          Rajesh Taneja made changes -
          Assignee moodle.com [ moodle.com ] Rajesh Taneja [ rajeshtaneja ]
          Rajesh Taneja made changes -
          Pull Master Diff URL https://github.com/rajeshtaneja/moodle/compare/master...wip-mdl-29274
          Pull Master Branch wip-mdl-29274
          Pull from Repository git://github.com/rajeshtaneja/moodle.git
          Rajesh Taneja made changes -
          Status Open [ 1 ] Waiting for peer review [ 10012 ]
          Dan Poltawski made changes -
          Original Estimate 0 minutes [ 0 ]
          Remaining Estimate 0 minutes [ 0 ]
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Peer reviewer poltawski
          Hide
          Dan Poltawski added a comment -

          Hi Raj,

          If you look at the docs for get_course_context() method it says:

          @deprecated since 2.2, use $context->get_course_context() instead
          

          So instead you can do:
          $this->page->context->get_course_context()

          Show
          Dan Poltawski added a comment - Hi Raj, If you look at the docs for get_course_context() method it says: @deprecated since 2.2, use $context->get_course_context() instead So instead you can do: $this->page->context->get_course_context()
          Dan Poltawski made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Hide
          Rajesh Taneja added a comment -

          Thanks for pointing that Dan,
          Branches updated and up for another review

          Show
          Rajesh Taneja added a comment - Thanks for pointing that Dan, Branches updated and up for another review
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Dan Poltawski made changes -
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Hide
          Dan Poltawski added a comment -

          Looks good!

          Show
          Dan Poltawski added a comment - Looks good!
          Dan Poltawski made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Hide
          Rajesh Taneja added a comment -

          Sorry Dan,
          I have updated the branch again. I encountered one regression while upgrading site.
          If this block is placed on front page and we try to upgrade, context passed is SYSTEM_CONTEXT and it fails.
          So I have updated the code which will take care of it.

          Once more for your review.

          Show
          Rajesh Taneja added a comment - Sorry Dan, I have updated the branch again. I encountered one regression while upgrading site. If this block is placed on front page and we try to upgrade, context passed is SYSTEM_CONTEXT and it fails. So I have updated the code which will take care of it. Once more for your review.
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Dan Poltawski made changes -
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Hide
          Dan Poltawski added a comment -

          Looks good

          Show
          Dan Poltawski added a comment - Looks good
          Dan Poltawski made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Hide
          Rajesh Taneja added a comment -

          Thanks Dan

          Show
          Rajesh Taneja added a comment - Thanks Dan
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Pull 2.1 Branch wip-mdl-29274-m21
          Pull 2.2 Diff URL https://github.com/rajeshtaneja/moodle/compare/MOODLE_22_STABLE...wip-mdl-29274-m22
          Pull 2.1 Diff URL https://github.com/rajeshtaneja/moodle/compare/MOODLE_21_STABLE...wip-mdl-29274-m21
          Pull 2.2 Branch wip-mdl-29274-m22
          Eloy Lafuente (stronk7) made changes -
          Currently in integration Yes [ 10041 ]
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator stronk7
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks! (20, 21 & master)

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks! (20, 21 & master)
          Eloy Lafuente (stronk7) made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Affects Version/s 2.2.1 [ 11456 ]
          Affects Version/s 2.1.4 [ 11452 ]
          Fix Version/s 2.1.5 [ 11553 ]
          Fix Version/s 2.2.2 [ 11552 ]
          Michael de Raadt made changes -
          Tester phalacee
          Jason Fowler made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Hide
          Jason Fowler added a comment -

          All good

          Show
          Jason Fowler added a comment - All good
          Jason Fowler made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Well,

          I wish I said it every time
          you do the things you do.
          You always lend a helping hand,
          and I'm filled with gratitude.

          You are strong and generous
          for each and everyone one of us.
          I am eternally grateful,
          I cannot say thanks enough.

          Sorry for the (un)cool bit above, lol. Closing this as fixed. Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Well, I wish I said it every time you do the things you do. You always lend a helping hand, and I'm filled with gratitude. You are strong and generous for each and everyone one of us. I am eternally grateful, I cannot say thanks enough. Sorry for the (un)cool bit above, lol. Closing this as fixed. Ciao
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Integration date 01/Mar/12
          Hide
          Peter Ruthven-Stuart added a comment - - edited

          Hello,

          I am preparing to upgrade from 2.0.7+ to 2.2.1+ via 2.1.4., and am now practising on a clone of my moodle system.

          The upgrade from 2.0.7 to 2.1.4+ went OK. However, when trying to access a course containing a 'People' block I get the following error:

          Fatal error: Call to undefined method stdClass::get_course_context() in /Library/WebServer/Documents/moodle22/blocks/participants/block_participants.php on line 23

          Commenting out line 23 'fixes' the problem; the course page loads, but there is no 'participants' link in the people block. Note, this error does not appear in the 2.0.7 system which was updated this morning (4th March).

          Comparing the two files (block_participants.php) in the 2.0.7 and 2.1.4 installations I see there have been some small changes, and in the version 2.0.7 file there is a reference to MDL-13252, which bought me here.

          UPDATE: I continued on to upgrade to 2.2.1+, and the 'Fatal error' message reported above no longer appears.

          MySQL: 5.1.42
          PHP: 5.3.8

          Show
          Peter Ruthven-Stuart added a comment - - edited Hello, I am preparing to upgrade from 2.0.7+ to 2.2.1+ via 2.1.4., and am now practising on a clone of my moodle system. The upgrade from 2.0.7 to 2.1.4+ went OK. However, when trying to access a course containing a 'People' block I get the following error: Fatal error: Call to undefined method stdClass::get_course_context() in /Library/WebServer/Documents/moodle22/blocks/participants/block_participants.php on line 23 Commenting out line 23 'fixes' the problem; the course page loads, but there is no 'participants' link in the people block. Note, this error does not appear in the 2.0.7 system which was updated this morning (4th March). Comparing the two files (block_participants.php) in the 2.0.7 and 2.1.4 installations I see there have been some small changes, and in the version 2.0.7 file there is a reference to MDL-13252, which bought me here. UPDATE: I continued on to upgrade to 2.2.1+, and the 'Fatal error' message reported above no longer appears. MySQL: 5.1.42 PHP: 5.3.8
          Hide
          James O'Dell added a comment -

          This problem may be solved for 2.2. But NOT for 2.1. People Block uses the function 'get_course_context'
          Moodle 2.1 expects the object 'context', while Moodle 2.2 expects a 'boolean'

          ---- 2.1
          ---- /**
          ---- * Find course context
          ---- * @param object $context - course or lower context
          ---- * @return object context of the enclosing course, throws exception when related course context found
          ---- */
          ---- function get_course_context($context) {

          ---- 2.2
          ---- /**
          ---- * Is this context part of any course? If yes return course context.
          ---- *
          ---- * @param bool $strict true means throw exception if not found, false means return false if not found
          ---- * @return course_context context of the enclosing course, null if not found or exception
          ---- */
          ---- public function get_course_context($strict = true) {

          The 'fix', which shows up in both Moodle 2.1 repositories(git and cvs) uses '$this->page->context->get_course_context(false)' - a boolean.

          Currently if you update to moodle 2.1.4+ (Build: 20120301) you can expect any course which has the 'People'
          block to display an entirely blank page.

          If you go back the previous version where '$currentcontext = $this->page->context;' and it works again.

          Some one needs to fix the repositories for Moodle 2.1 ...

          Imho, poor regression testing for Moodle 2.1 core stable!

          Show
          James O'Dell added a comment - This problem may be solved for 2.2. But NOT for 2.1. People Block uses the function 'get_course_context' Moodle 2.1 expects the object 'context', while Moodle 2.2 expects a 'boolean' ---- 2.1 ---- /** ---- * Find course context ---- * @param object $context - course or lower context ---- * @return object context of the enclosing course, throws exception when related course context found ---- */ ---- function get_course_context($context) { ---- 2.2 ---- /** ---- * Is this context part of any course? If yes return course context. ---- * ---- * @param bool $strict true means throw exception if not found, false means return false if not found ---- * @return course_context context of the enclosing course, null if not found or exception ---- */ ---- public function get_course_context($strict = true) { The 'fix', which shows up in both Moodle 2.1 repositories(git and cvs) uses '$this->page->context->get_course_context(false)' - a boolean. Currently if you update to moodle 2.1.4+ (Build: 20120301) you can expect any course which has the 'People' block to display an entirely blank page. If you go back the previous version where '$currentcontext = $this->page->context;' and it works again. Some one needs to fix the repositories for Moodle 2.1 ... Imho, poor regression testing for Moodle 2.1 core stable!
          Hide
          Rajesh Taneja added a comment -

          Thanks for pointing that James,

          I am creating a new bug to fix this regression.

          Show
          Rajesh Taneja added a comment - Thanks for pointing that James, I am creating a new bug to fix this regression.
          Rajesh Taneja made changes -
          Link This issue caused a regression MDL-31894 [ MDL-31894 ]
          Eloy Lafuente (stronk7) made changes -
          Fix Version/s STABLE Sprint 18 [ 11650 ]

            People

            • Votes:
              13 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: