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

User "My Home" records are not being cleaned up on user deletion

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • master_MDL-43797
    • Hide

      To test this, you need to have access to database to make sure that records are being removed.

      1. On fresh Moodle install create a test user (testuser)
      2. Log in as "testuser" and customise the blocks on their My Moodle page
      3. Run this SQL on the database "SELECT * FROM mdl_my_pages;" and the result should look similar to this (where the last record is a page for "testuser" with user id 3):

      id userid name private sortorder
      1   __default 0 0
      2   __default 1 0
      3 3 __default 1 0

      4. Delete "testuser"

      5. Run the SQL again, make sure that the record with userid 3 was removed:

      id userid name private sortorder
      1   __default 0 0
      2   __default 1 0
      Show
      To test this, you need to have access to database to make sure that records are being removed. 1. On fresh Moodle install create a test user (testuser) 2. Log in as "testuser" and customise the blocks on their My Moodle page 3. Run this SQL on the database "SELECT * FROM mdl_my_pages;" and the result should look similar to this (where the last record is a page for "testuser" with user id 3): id userid name private sortorder 1   __default 0 0 2   __default 1 0 3 3 __default 1 0 4. Delete "testuser" 5. Run the SQL again, make sure that the record with userid 3 was removed: id userid name private sortorder 1   __default 0 0 2   __default 1 0

      Removal of all block instances on user pages is being handled by delete_context(CONTEXT_USER, $user->id) when user is deleted. However, if a user had a customised "My Home" page, a record will still remains in database.

      It looks like all we need to do is add:

      $DB->delete_records('my_pages', array('userid' => $user->id, 'private' => 1));

      to delete_user() method. We will submit proposed fix in a bit.

            ybozhko Yuliya Bozhko
            ybozhko Yuliya Bozhko
            Rossiani Wijaya Rossiani Wijaya
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Michael de Raadt Michael de Raadt
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.