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

Duplicate ra's in $USER->access

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 2.0
    • Component/s: Roles / Access
    • Labels:
      None
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      I very often see duplicate ra's in $USER->access. For example (just the first few lines):

      Array
      (
      ::::[ra] => Array
      :::::::
      ::::::::::::[/1/154/184] => Array
      :::::::::::::::
      :::::::::::::::::::::[0] => 5
      :::::::::::::::::::::[1] => 5

      Duplicate ra's double the work of calculating permissions without changing the result. Sometimes there are more than two duplicates. I recently helped a user debug a problem and there were SEVEN duplicates of two different roles! This is a major efficiency issue.

      Martin Langhoff suggested the fix below, but it does not eliminate the problem.


      Change the last line of the SQL query in get_user_access_sitewide() and load_subcontext() (both functions in lib/accesslib.php

      ORDER BY ctx.depth ASC, ctx.path ASC, ra.roleid ASC

      (Added ASC to make the order unambiguous. Different DBs default to
      different defaults, so what works in mySQL might break subtly in Oracle.)

        Attachments

        1. accesslib.patch.txt
          2 kB
          Eloy Lafuente (stronk7)
        2. another duplicate ra.png
          8 kB
          John Isner

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

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