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

The guest_user function should always return a user

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6.2
    • Fix Version/s: None
    • Component/s: User management
    • Labels:
    • Affected Branches:
      MOODLE_36_STABLE

      Description

      When a Moodle site is misconfigured, it is possible for the function `guest_user` to return `false` instead of a user object, although most of the code I've seen assumes that `guest_user` will always return a valid user.

      This is likely happening when `$CFG->siteguest` was overridden but invalid, as deleting the guest user should not be possible.

      I would suggest to either change `guest_user` to always return a valid user object, and throw an exception when it cannot find one, or check that `siteguest` is valid when it is set in the config file.

      (This was identified from a bug reported in Level up!)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fred Frédéric Massart
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: