DevinWalker / wp-rollback

Rollback any WordPress.org plugin or theme to a previous (or newer) version.
https://wprollback.com
81 stars 22 forks source link

Check for file permissions on plugin/theme before attempting to rollback? #55

Open georgestephanis opened 2 years ago

georgestephanis commented 2 years ago

Bug Report

User Story

Sometimes plugins and themes are managed by the host, and the WordPress install doesn't have the permissions to install them. When this happens, the Rollback can attempt to disable the plugins (which can result in the deletion of theme/plugin settings on a deactivation hook), and then break when it can't upgrade anyway -- leaving the site in a worse state than it began in.

Current Behavior

On Pressable, Jetpack and WooCommerce and some core themes (and likely a couple other plugins) are managed by the host and symlinked into sites that don't have write access to the files. This will break when someone tries to rollback Jetpack, and can result in data loss.

Expected Behavior

I would expect some variety of preflight checks before a rollback is attempted to ensure that WordPress has file permissions to modify the theme or plugin in question.

Bug Type

This bug describes functionality that never worked as expected.

Steps to Reproduce

  1. Set a plugin's folder as root to not have write permissions.
  2. Try to rollback.
  3. See that not only does it fail but plugin settings may be lost as well as the plugin not reactivating.

Possible Solution

Add a pre-flight check before attempting a rollback to check for file permissions, potentially using wp_is_writable()

Acceptance Criteria

Environment

Irrelevant.

Operating System
  • Platform: Mac OS X | Microsoft Windows | Linux | Android | iOS
  • Version: X.X.X
Browser
  • Name: Chrome | Firefox | Safari | IE | Edge
  • Version: X.X.X
WordPress System Info