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

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.9.6, 3.10.3, 3.11, 4.0
    • Fix Version/s: 3.9.7, 3.10.4
    • Component/s: Repositories
    • Labels:

      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

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Peer reviewer:
            Sujith Haridasan Sujith Haridasan
            Integrator:
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Tester:
            CiBoT CiBoT
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/May/21

                Time Tracking

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