Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-29274

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

    Details

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

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

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

              Show
              salvetore Michael de Raadt added a comment - Increasing the priority on this as it has now been replicated.
              salvetore Michael de Raadt made changes -
              Priority Minor [ 4 ] Critical [ 2 ]
              cfollin Chris Follin made changes -
              Labels triaged moodlerooms partner triaged
              salvetore Michael de Raadt made changes -
              Fix Version/s STABLE Sprint 18 [ 11650 ]
              Fix Version/s STABLE backlog [ 10463 ]
              rajeshtaneja Rajesh Taneja made changes -
              Assignee moodle.com [ moodle.com ] Rajesh Taneja [ rajeshtaneja ]
              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
              rajeshtaneja Rajesh Taneja made changes -
              Status Open [ 1 ] Waiting for peer review [ 10012 ]
              poltawski 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
              poltawski 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
              poltawski 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()
              poltawski Dan Poltawski made changes -
              Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

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

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

              Looks good!

              Show
              poltawski Dan Poltawski added a comment - Looks good!
              poltawski Dan Poltawski made changes -
              Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
              Hide
              rajeshtaneja 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
              rajeshtaneja 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.
              rajeshtaneja Rajesh Taneja made changes -
              Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
              poltawski Dan Poltawski made changes -
              Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
              Hide
              poltawski Dan Poltawski added a comment -

              Looks good

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

              Thanks Dan

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks Dan
              rajeshtaneja 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
              stronk7 Eloy Lafuente (stronk7) made changes -
              Currently in integration Yes [ 10041 ]
              stronk7 Eloy Lafuente (stronk7) made changes -
              Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
              Integrator stronk7
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Integrated, thanks! (20, 21 & master)

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Integrated, thanks! (20, 21 & master)
              stronk7 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 ]
              salvetore Michael de Raadt made changes -
              Tester phalacee
              phalacee Jason Fowler made changes -
              Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
              Hide
              phalacee Jason Fowler added a comment -

              All good

              Show
              phalacee Jason Fowler added a comment - All good
              phalacee Jason Fowler made changes -
              Status Testing in progress [ 10011 ] Tested [ 10006 ]
              Hide
              stronk7 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
              stronk7 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
              stronk7 Eloy Lafuente (stronk7) made changes -
              Status Tested [ 10006 ] Closed [ 6 ]
              Resolution Fixed [ 1 ]
              Currently in integration Yes [ 10041 ]
              Integration date 01/Mar/12
              Hide
              stuart 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
              stuart 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
              jodell 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
              jodell 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
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks for pointing that James,

              I am creating a new bug to fix this regression.

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

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/Mar/12