Skip to content
Snippets Groups Projects

Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

Merged Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit
4 unresolved threads
4 unresolved threads

Closes #3412542

Merge request reports

Merge train pipeline #73362 passed

Merge train pipeline passed for 3c6ac05f

Approved by
Code Quality is loading
Test summary results are being parsed

Merged by Ricardo Sanz AnteRicardo Sanz Ante 1 year ago (Jan 8, 2024 8:58am UTC)

Merge details

  • Changes merged into 1.0.x with 3c6ac05f (commits were squashed).
  • Did not delete the source branch.
  • Auto-merge enabled

Pipeline #73367 passed

Pipeline passed for 3c6ac05f on 1.0.x

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
198 198 break;
199 199
200 200 case 'number_to_keep':
201 $elements_to_delete = [];
202 $number_of_backups = count($backup_list);
203
204 if ($number_of_backups > $limit) {
205 $elements_to_delete = array_slice($backup_list, 0, -$limit, TRUE);
201 // Do not delete backups if the count of backups is minus than
  • 200 200 case 'number_to_keep':
    201 $elements_to_delete = [];
    202 $number_of_backups = count($backup_list);
    203
    204 if ($number_of_backups > $limit) {
    205 $elements_to_delete = array_slice($backup_list, 0, -$limit, TRUE);
    201 // Do not delete backups if the count of backups is minus than
    202 // the limit.
    203 if ($limit < 1 || count($backup_list) < $limit) {
    204 return [];
    206 205 }
    207 foreach ($elements_to_delete as $uuid => $backup_time) {
    208 $backups_to_delete[$uuid]['date'] = date(\DateTimeInterface::ATOM, $backup_time);
    206
    207 // Calculate the number of backups to delete.
    208 $number_backups_to_delete = count($backup_list) - $limit;
  • 198 198 break;
    199 199
    200 200 case 'number_to_keep':
    201 $elements_to_delete = [];
    202 $number_of_backups = count($backup_list);
    203
    204 if ($number_of_backups > $limit) {
    205 $elements_to_delete = array_slice($backup_list, 0, -$limit, TRUE);
    201 // Do not delete backups if the count of backups is minus than
    202 // the limit.
    203 if ($limit < 1 || count($backup_list) < $limit) {
  • 202 $number_of_backups = count($backup_list);
    203
    204 if ($number_of_backups > $limit) {
    205 $elements_to_delete = array_slice($backup_list, 0, -$limit, TRUE);
    201 // Do not delete backups if the count of backups is minus than
    202 // the limit.
    203 if ($limit < 1 || count($backup_list) < $limit) {
    204 return [];
    206 205 }
    207 foreach ($elements_to_delete as $uuid => $backup_time) {
    208 $backups_to_delete[$uuid]['date'] = date(\DateTimeInterface::ATOM, $backup_time);
    206
    207 // Calculate the number of backups to delete.
    208 $number_backups_to_delete = count($backup_list) - $limit;
    209
    210 $count = 0;
    • I would use $backups_to_delete for the loop to avoid creating another variable ($count) for readability reasons. Also, let's break early:

      // Calculate the number of backups to delete.
      $number_backups_to_delete = count($backup_list) - $limit;
      foreach ($backup_list as $uuid => $backup_time) {
        if ($number_backups_to_delete === 0) {
          break;
        }
        $backups_to_delete[$uuid]['date'] = date(\DateTimeInterface::ATOM, $backup_time);
        $number_backups_to_delete--;
      }
    • eduardo morales alberti changed this line in version 3 of the diff

      changed this line in version 3 of the diff

    • Please register or sign in to reply
  • added 1 commit

    • 6a5ff87b - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • added 1 commit

    • 73784e1e - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • added 1 commit

    • 48a6a3ac - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • added 1 commit

    • f741e812 - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • added 1 commit

    • 0cdd6684 - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • added 1 commit

    • 0aba0ded - Issue #3412542 by Eduardo Morales Alberti: Backups are deleted due a bad contion on the limit

    Compare with previous version

  • Ricardo Sanz Ante approved this merge request

    approved this merge request

  • Ricardo Sanz Ante started a merge train

    started a merge train

  • Please register or sign in to reply
    Loading