Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3321

MRBS: PHP notice about contexts

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: Block: Mrbs
    • Labels:
      None
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      I upgraded a site to Moodle 2.2 and there were some changes to the API for the MRBS block. In particular,

      context_system::instance(): invalid $id parameter detected, should be 0

      line 5542 of /lib/accesslib.php: call to debugging()
      line 6813 of /lib/accesslib.php: call to context_system::instance()
      line 43 of /blocks/mrbs/block_mrbs.php: call to get_context_instance()
      line 280 of /blocks/moodleblock.class.php: call to block_mrbs->get_content()
      line 232 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      line 926 of /lib/blocklib.php: call to block_base->get_content_for_output()
      line 978 of /lib/blocklib.php: call to block_manager->create_block_contents()
      line 349 of /lib/blocklib.php: call to block_manager->ensure_content_created()
      line 10 of /theme/formal_white/layout/frontpage.php: call to block_manager->region_has_content()
      line 685 of /lib/outputrenderers.php: call to include()
      line 637 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line ? of unknownfile: call to core_renderer->header()
      line 1363 of /lib/setuplib.php: call to call_user_func_array()
      line 91 of /index.php: call to bootstrap_renderer->__call()
      line 91 of /index.php: call to bootstrap_renderer->header()

      The comments in lib/accesslib.php indicate that the get_context_instance has been deprecated so we should work on getting this changed before Moodle 2.3:

      /**

      • Get the context instance as an object. This function will create the
      • context instance if it does not exist yet.
        *
      • @deprecated since 2.2, use context_course::instance() or other relevant class instead
      • @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
      • @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
      • for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
      • @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
      • MUST_EXIST means throw exception if no record or multiple records found
      • @return context The context object.
        */

      Peace - Anthony

        Attachments

          Activity

            People

            Assignee:
            davosmith Davo Smith
            Reporter:
            aborrow Anthony Borrow
            Participants:
            Component watchers:
            Davo Smith
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: