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

Impossible to assign a user a role in a context if the context does not already exist

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Web Services
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      If a user a created through a web service, and then we want to assign a role to another user in the user's context (e.g., to add a "Parent" or "Guardian" role), then this is not possible, because no context record, and thus no contextid, exists for that user's context.

      I am not sure if, when adding a user, the user context is automatically created, or if the user context is created when get_context_instance() is first called on that context.

      One solution is to just create the user context (perhaps by calling get_context_instance() and then doing nothing with the result) when the user record is created via a web service.

        Attachments

          Activity

            People

            Assignee:
            jerome Jérôme Mouneyrac
            Reporter:
            bazzymg Basil Gohar
            Tester:
            Nobody
            Participants:
            Component watchers:
            Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10