Skip to content

Restore even if cannot set writable permissions. Fixes #437 - #447

Open
bwmarkle wants to merge 6 commits into
masterfrom
issue-437
Open

Restore even if cannot set writable permissions. Fixes #437#447
bwmarkle wants to merge 6 commits into
masterfrom
issue-437

Conversation

@bwmarkle

@bwmarkle bwmarkle commented Feb 10, 2021

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Changes pre-restore failure handling for a critical path; restores may proceed with permission issues that previously blocked the operation, though unzip and later steps can still fail.

Overview
Archive restore no longer stops when set_writable_permissions fails (with ZipArchive available). The failure message is still written to the restore log, but the flow proceeds to unzip—matching the existing behavior when ZipArchive is missing.

This addresses cases where permission prep failed even though the restore could still complete successfully.

Reviewed by Cursor Bugbot for commit 69c3568. Bugbot is set up for automated code reviews on this repo. Configure here.

@bwmarkle

Copy link
Copy Markdown
Contributor Author

@cssjoe says:

the message changed to:
Total Upkeep - Restoration failed
Could not copy file.: wp-config.php
I chown 0:0 wp-config.php for the test restore.
It still says it failed. Should it say success with errors, or partially restored?

I'm going to put this PR on hold so we can get some releases out today.

  1. Looks like I missed some logic that needs to be accounted for.
  2. Thus far, only 1 report. Edge case?

@codecov-io

codecov-io commented Feb 16, 2021

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.46%. Comparing base (6d78a90) to head (32c9ba5).
⚠️ Report is 82 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #447   +/-   ##
=========================================
  Coverage     25.46%   25.46%           
  Complexity     2920     2920           
=========================================
  Files           202      202           
  Lines         14698    14697    -1     
=========================================
  Hits           3743     3743           
+ Misses        10955    10954    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cssjoe

cssjoe commented Mar 5, 2021

Copy link
Copy Markdown
Member

This may need better result messages.

  • Completes successfully
  • Completed with errors; partially restored -- Maybe have an expandable file list
  • Could not restore -- with the reason(s)

@cssjoe

cssjoe commented Aug 3, 2026

Copy link
Copy Markdown
Member

Status update (Aug 2026 triage): Still open and still relevant — master still aborts restore when set_writable_permissions() fails (with ZipArchive). Prior hold notes about clearer result messaging (“completed with errors” / partial restore) still apply before merge. PR is mergeable; needs a product decision on messaging, then rebase/merge or a refreshed PR.

@cssjoe cssjoe mentioned this pull request Aug 3, 2026
@cssjoe
cssjoe requested a review from a team September 1, 2026 15:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Permission prep stops after first failure
    • Changed set_writable_permissions to collect all chmod errors instead of returning false on first failure, ensuring all archive files get permission checks before restore continues.

Create PR

Or push these changes by commenting:

@cursor push 2055cf0cfb
Preview (2055cf0cfb)
diff --git a/admin/class-boldgrid-backup-admin-restore-helper.php b/admin/class-boldgrid-backup-admin-restore-helper.php
--- a/admin/class-boldgrid-backup-admin-restore-helper.php
+++ b/admin/class-boldgrid-backup-admin-restore-helper.php
@@ -261,12 +261,11 @@
 						__( 'Permission denied. Unable to restore the following file: %1$s', 'boldgrid-backup' ),
 						$full_path
 					);
-					return false;
 				}
 			}
 		}
 
-		return true;
+		return empty( $this->errors );
 	}
 
 	/**

You can send follow-ups to the cloud agent here.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 69c3568. Configure here.

if ( ! $this->restore_helper->set_writable_permissions( $info['filepath'] ) ) {
$error_message = $this->restore_helper->get_last_error();
$this->logger->add( $error_message );
return [ 'error' => $error_message ];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Permission prep stops after first failure

Medium Severity

set_writable_permissions still returns on the first chmod failure, so later archive paths are never prepared. Restore now continues into unzip_file anyway, which can then fail on files that would have been writable if permission prep had finished.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 69c3568. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants