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

Repository get_instances silently uses the system context if you pass the wrong thing

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.9.6, 3.10.3, 3.11, 4.0
    • 3.9.7, 3.10.4
    • Repositories

    Description

      Steps to reproduce:

      1. Accidentally write the code

      $repositories = repository::get_instances(['currentcontext' => $context->id]);
      

      Actual result: it seems to work, until some time later things mysteriously don't work and you have to spend a lot of time debugging it.

      Expected result (once you realise it is buggy): A debugging notice like "'currentcontext' passed to repository::get_instances was not a context object. Using system context instead, but you should probably fix your code."

      Attachments

        Activity

          People

            timhunt Tim Hunt
            timhunt Tim Hunt
            Sujith Haridasan Sujith Haridasan
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            CiBoT CiBoT
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10/May/21

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 26 minutes
                26m