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

Repository OneDrive - 7 day clean up is not correctly implemented

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.4.1, 3.5.1
    • Fix Version/s: None
    • Component/s: Repositories
    • Labels:
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE

      Description

      The One-Drive Repository lib.php -> add_temp_writer_to_file() function does not use the 7 day $expires datetime object, and can be removed.

      Further analysis show the cleanup is done by a separate scheduled task defined in repository/onedrive/classes/remove_temp_access_task.php.

          protected function add_temp_writer_to_file(\repository_onedrive\rest $client, $fileid, $email) {
              // Expires in 7 days.
              $expires = new DateTime();
              $expires->add(new DateInterval("P7D"));
       
              $updateeditor = [
                  'recipients' => [[ 'email' => $email ]],
                  'roles' => ['write'],
                  'requireSignIn' => true,
                  'sendInvitation' => false
              ];
              $params = ['fileid' => $fileid];
              $response = $client->call('create_permission', $params, json_encode($updateeditor));
              if (empty($response->value[0]->id)) {
                  $details = 'Cannot add user ' . $email . ' as a writer for document: ' . $fileid;
                  throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
              }
              // Store the permission id in the DB. Scheduled task will remove this permission after 7 days.
              if ($access = repository_onedrive\access::get_record(['permissionid' => $response->value[0]->id, 'itemid' => $fileid ])) {
                  // Update the timemodified.
                  $access->update();
              } else {
                  $record = (object) [ 'permissionid' => $response->value[0]->id, 'itemid' => $fileid ];
                  $access = new repository_onedrive\access(0, $record);
                  $access->create();
              }
              return true;
          }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zig Zig Tan (Inactive)
              Participants:
              Component watchers:
              Adrian Greeve, Mihail Geshoski, Peter Dias
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: