-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API endpoints and Jetpack Backup package for managing Helper Scripts #13830
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
This is an automated check which relies on |
be288b5
to
3578e5d
Compare
thingalon, Your synced wpcom patch D34452-code has been updated. |
Rebased to master. |
Related discussion: p9ue0y-81-p2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really test this without a VP sandbox, so my comments will mostly be nitpicking.
What do you think about doing some cleanup in uninstall.php
to make sure we always clean after ourselves if someone deletes the plugin from their site?
There are quite a few PHPCS errors and warning that will stop you from committing changes to those files. Could you fix those errors?
json-endpoints/jetpack/class.jetpack-json-api-delete-backup-helper-script.php
Outdated
Show resolved
Hide resolved
json-endpoints/jetpack/class.jetpack-json-api-delete-backup-helper-script.php
Outdated
Show resolved
Hide resolved
json-endpoints/jetpack/class.jetpack-json-api-delete-backup-helper-script.php
Outdated
Show resolved
Hide resolved
json-endpoints/jetpack/class.jetpack-json-api-install-backup-helper-script.php
Outdated
Show resolved
Hide resolved
json-endpoints/jetpack/class.jetpack-json-api-install-backup-helper-script.php
Outdated
Show resolved
Hide resolved
json-endpoints/jetpack/class.jetpack-json-api-install-backup-helper-script.php
Outdated
Show resolved
Hide resolved
55a2e0a
to
2b2eb7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how readable and both self-documented and well-documented this code is. Thanks for the great work!
I haven't tested it, but I've left some drive-by comments and questions in case they can be useful.
|
||
use Automattic\Jetpack\Backup\Helper_Script_Manager; | ||
|
||
class Jetpack_JSON_API_Install_Backup_Helper_Script_Endpoint extends Jetpack_JSON_API_Endpoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered creating those endpoints as v2 endpoints (like this one)? I thought we try to create new endpoints with this mechanism, rather than the legacy v1 one.
Just in case it's helpful, this post is a good place to read more about the different types of endpoints: PCYsg-aqU-p2
for ( $attempt = 0; $attempt < $max_attempts; $attempt++ ) { | ||
$file_key = wp_generate_password( 10, false ); | ||
$relative_file_path = trailingslashit( $relative_temp_dir ) . 'jp-helper-' . $file_key . '.php'; | ||
$absolute_file_path = trailingslashit( ABSPATH ) . $relative_file_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be \ABSPATH
because we're in a different namespace from the global one here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably better to be explicit. This instance of ABSPATH was refactored out based on previous feedback just as your comments were added -- but I've added \ to the new instance of ABSPATH (and similar constants) in the latest version.
Thanks for the feedback! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Also, noting that we should be able to use the constants
package to safely check and retrieve constants.
Thanks for the review @jeherve
Good idea; added. Thanks! :)
Cleaned up! Thanks :) |
a622cb4
to
f82df05
Compare
…lated to Jetpack Backup
…content and upload locations without making assumptions
…ace, remove two unused variables
f82df05
to
67039aa
Compare
Rebased to |
Failing Travis build because of the wrong filenames in whitelist was the problem. |
… check for it in the global namespace.
7e46b32
to
34b187e
Compare
I've re-tested using latest patches D34445-code and 975-gh-jetpack-backups. The helper script uploads and a backup runs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't test all of this since I don't have a VP sandbox, but the Jetpack side looks good. I'm merging this now to make testing easier.
Conversation at p9ue0y-81-p2 is still ongoing so keeping an eye on that too.
D34452-code, D34445-code, and 975-gh-jetpack-backups will also need to be merged.
* 7.9: Changelog * Update version number * Update stable tag and tested up to * Changelog: add #13530 * changelog: add #13578 * Changelog: add #13598 * Changelog: add entry for numerous block preview changes * Changelog: add #13599 * changelog: add #13541 * Changelog: add #13542 * Changelog: add #13331 * Changelog: add #13558 * Changelog: add #13409 * Changelog: add #13582 * Changelog: add #13600 * Changelog: add #13601 * Changelog: add #13595 * Changelog: add #12695 * Changelog: add #13009 * Changelog: add #13649 * Changelog: add #13450 * Changelog: add #13507 * Changelog: add #13658 * Changelog: add #13687 * changelog: add #13683 * Changelog: add #9323 * Changelog: add #13681 * Fix typos in readme * Add link to WordPress Beta Tester plugin * Changelog: add #13630 * Changelog: add #13695 * Changelog: add #13659 * Changelog: add #13716 * Changelog: add #13664 * Changelog: add #13682 * Changelog: add #13362 * Changelog: add #13563 * Add testing list for #13563 * Changelog: add #13735 * Changelog: add #13752 * Changelog: add #13624 * Changelog: add #13756 * Changelog: add #13745 * Changelog: add #13728 * Changelog: add #13779 * Changelog: add #13699 * Changelog: add #13804 * Changelog: add #13761 * Changelog: add #13637 * Changelog: add #13517 * Changelog: add #13521 * Changelog: add #13729 * Testing list: add testing instructions for #13729 * Changelog: add sync changes * Changelog: add #13807 * Changelog: add #13654 * Changelog: add #13795 * Changelog: add #13801 * Changelog: add #13818 * Changelog: add #13725 * Changelog: add #13831 * Changelog: add #13516 * Testing list: add Twenty Twenty instructions * Changelog: add #13799 * Changelog: add #13805 * Changelog: add #13688 * Changelog: add #13830
- Project: https://[private link] - P2 post about this prototype: https://[private link] - Related Jetpack PR: #13830 - Related Rewind PR: https://github.com/Automattic/jetpack-backups/pull/975 This adds two new API endpoints for calling out to a Jetpack site, to install or delete a Helper Script. It also locks these new API endpoints down to require access through a Rewind API token, ensuring this is not called from any other source. This commit was generated from D34445-code.
* Add endpoints for Jetpack Backup Helper Script methods - Project: https://[private link] - P2 post about this prototype: https://[private link] - Related Jetpack PR: #13830 - Related Rewind PR: Automattic/jetpack-backups#975 This adds two new API endpoints for calling out to a Jetpack site, to install or delete a Helper Script. It also locks these new API endpoints down to require access through a Rewind API token, ensuring this is not called from any other source. This commit was generated from D34445-code. * Make the require_rewind_auth parameter optional
…13922) * Add endpoints for Jetpack Backup Helper Script methods - Project: https://[private link] - P2 post about this prototype: https://[private link] - Related Jetpack PR: #13830 - Related Rewind PR: Automattic/jetpack-backups#975 This adds two new API endpoints for calling out to a Jetpack site, to install or delete a Helper Script. It also locks these new API endpoints down to require access through a Rewind API token, ensuring this is not called from any other source. This commit was generated from D34445-code. * Make the require_rewind_auth parameter optional
Project details: pa0RFL-oP-p2
Prototype P2 post: pa0RFL-ra-p2
Related wpcom patch: D34445-code
Related transport patch: 975-gh-jetpack-backups
This PR adds support for Jetpack Backup Helper Scripts. It includes two new API endpoints; one for installing a Jetpack Backup Helper Script, and one for deleting them. It also adds a scheduled action to cleanup any expired Helper Scripts after any get installed.
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
This adds support for Zero-Config Backups to Jetpack.
Testing instructions:
See instructions on the transport patch: 975-gh-jetpack-backups
Proposed changelog entry for your changes: