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

cron task fails : \\core\\task\\delete_unconfirmed_users_task

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • Hide
      1. Note to tester: On 26 you will need to devise another way to force this section of cron to run. I suggest commenting everything else.
      1. Enable self registration
      2. Register 2 new users 'userA' and 'userB'
      3. Edit mdl_user and set the field firstaccess to 1 for those 2 new users
      4. Do not confirm their accounts
      5. From the admin interface, delete userA
      6. Execute:

        php admin/tool/task/cli/schedule_task.php --execute=\\core\\task\\delete_unconfirmed_users_task
        

      7. Make sure that the script displays a success message
        • Confirm that the userA is still in the database
        • Confirm that the userB has been deleted from the database
      Show
      Note to tester: On 26 you will need to devise another way to force this section of cron to run. I suggest commenting everything else. Enable self registration Register 2 new users 'userA' and 'userB' Edit mdl_user and set the field firstaccess to 1 for those 2 new users Do not confirm their accounts From the admin interface, delete userA Execute: php admin/tool/task/cli/schedule_task.php --execute=\\core\\task\\delete_unconfirmed_users_task Make sure that the script displays a success message Confirm that the userA is still in the database Confirm that the userB has been deleted from the database

      admin/tool/task/cli/schedule_task.php --execute=\\core\\task
      delete_unconfirmed_users_task
      ends at with output:
      1
      Scheduled task: Delete unconfirmed users
      ... used 4 dbqueries
      ... used 0.1089289188385 seconds
      Task failed: Invalid user

      discovered during MDLSITE-3002 testing on study.
      also in regular cron runs:
      Execute scheduled task: Delete unconfirmed users
      ... started 07:00:06. Current memory use 19.9MB.
      ... used 4 dbqueries
      ... used 0.24109411239624 seconds
      Scheduled task failed: Delete unconfirmed users,Invalid user

      public function execute() {
              global $CFG, $DB;
       
              $timenow = time();
       
              // Delete users who haven't confirmed within required period.
              if (!empty($CFG->deleteunconfirmed)) {
                  $cuttime = $timenow - ($CFG->deleteunconfirmed * 3600);
                  $rs = $DB->get_recordset_sql ("SELECT *
                                                   FROM {user}
                                                  WHERE confirmed = 0 AND firstaccess > 0
                                                        AND firstaccess < ?", array($cuttime));
                  foreach ($rs as $user) {
                      delete_user($user); // We MUST delete user properly first.
                      $DB->delete_records('user', array('id' => $user->id)); // This is a bloody hack, but it might work.
                      mtrace(" Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
                  }
                  $rs->close();
              }
          }
      

      no idea why 'invalid user' but this seems non critical for MDLSITE-3002 .. going ahead there.

            fred Frédéric Massart
            nebgor Aparup Banerjee
            Simey Lameze Simey Lameze
            Damyon Wiese Damyon Wiese
            Ankit Agarwal Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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