Skip to content

First pass -- VaultPress deactivation if Rewind is running.#8378

Merged
dereksmart merged 6 commits intomasterfrom
add/vaultpress-deactivation-if-rewind
Dec 20, 2017
Merged

First pass -- VaultPress deactivation if Rewind is running.#8378
dereksmart merged 6 commits intomasterfrom
add/vaultpress-deactivation-if-rewind

Conversation

@georgestephanis
Copy link
Copy Markdown
Contributor

I may (probably will) need to revisit where in the $features array I'm checking to see if Rewind is enabled.

WIP.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any thoughts on an early-abort-over-nested pattern, even though we can't avoid some nesting here?

if ( false !== $rewind_enabled ) {
	return $rewind_enabled;
}

jetpack_require_lib( … )
…
set_transient( … )

return $rewind_enabled;

anyway no big deal just noticed this and how the "main code" was nested

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Eh, I'm not huge on it either way, this is just how I'd always structured transient checks in the past. I'm not emotionally invested either direction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is the topic of the conversation 😄

I think that you are checking the right values here, but we have overlap in terms between the Rewind system and Jetpack itself, so this is the content of the review

this code is checking if a site has "anything to do with Rewind" including that it could have Rewind activated but it's missing the necessary plan.

this does not verify that Rewind is actively backing up and protecting a site, which is probably okay for the purposes we are wanting - know whether or not to prompt to deactivate VaultPress (because if it's missing the plan then VaultPress is probably also missing the plan and if it should be backing up but isn't it's likely due to some external problem)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dmsnell what do you think about setting a transient/option with the response from the /rewind endpoint that we're using for the UI?

https://github.com/Automattic/jetpack/blob/master/_inc/lib/class.core-rest-api-endpoints.php#L656-L672

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could also have it return a different string 'available' or 'enabled' based on its status and test against those.

I don't care which, but we need to decide the conditions for it appearing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, in EITHER case we don't want VaultPress active, because they should be using rewind. So the original code is GTG on that front

Copy link
Copy Markdown
Contributor

@dereksmart dereksmart Dec 19, 2017

Choose a reason for hiding this comment

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

Yeah, the /rewind endpoint we're getting in that link above includes a response that we're using to determine it. I think it's the way to go.

array(
	'reason' => 'host_not_supported',
	'state' => 'active', // Can also be 'available' or 'unavailable'
	'downloads' => array(),
	'last_updated' => 1513366050
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'state' => 'active', // Can also be 'available' or 'unavailable'

^^^ we will want to make sure we stick to the actively confusing definitions because our terms overlap with different meanings - p9rlnk-1r-p2

what do you think about setting a transient/option with the response

it's probably about time we look at latency and performance issues and address it appropriately. I doubt putting it in the API call is better than putting it in get_status() and trusted_get_status() but I don't know if you are talking about a transient on the Jetpack side

@dereksmart dereksmart force-pushed the add/vaultpress-deactivation-if-rewind branch from 829399e to 16f64f3 Compare December 20, 2017 15:12
'plugin' => $plugin_file,
);
$deactivate_url = wp_nonce_url( add_query_arg( $query_args, admin_url( 'plugins.php' ) ), "deactivate-plugin_{$plugin_file}" );
deactivate_plugins( $plugin_file );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"Murder most foul…" -- Shakespeare, Hamlet, Act 1 Scene V

@georgestephanis
Copy link
Copy Markdown
Contributor Author

georgestephanis commented Dec 20, 2017

There was 1 failure:

  1. WP_Test_Jetpack_Sync_Queue::test_queue_lag

Failed asserting that 23 matches expected 6.

/tmp/wordpress-latest/src/wp-content/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-queue.php:61

Restarting job now -- could have just been cranky?

@dereksmart dereksmart added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Dec 20, 2017
Copy link
Copy Markdown
Contributor

@dereksmart dereksmart left a comment

Choose a reason for hiding this comment

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

Made some changes, works well for me

@georgestephanis
Copy link
Copy Markdown
Contributor Author

georgestephanis commented Dec 20, 2017

Are we okay with it only being deactivated off of admin_init() ? I think that's good as it avoids race conditions for busy sites (the deactivation wouldn't happen on front-end visits), and the deactivation only happening on admin_notices also avoids anything triggering on login pages.

@dereksmart
Copy link
Copy Markdown
Contributor

I think that's good

@georgestephanis I agree!

@dereksmart dereksmart added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Dec 20, 2017
@dereksmart dereksmart added this to the vp-rewind-pressable milestone Dec 20, 2017
@dereksmart dereksmart merged commit e6d331b into master Dec 20, 2017
@dereksmart dereksmart deleted the add/vaultpress-deactivation-if-rewind branch December 20, 2017 17:32
dereksmart pushed a commit that referenced this pull request Dec 20, 2017
* First pass -- VaultPress deactivation if Rewind is running.

I may (probably will) need to revisit where in the `$features` array I'm checking to see if Rewind is enabled.

* Add the file to the included list for 3rd-party

* Retool to new method to check for Rewind availability.

* Update is_rewind_enabled() method to read the correct data for determining status of Rewind

* VaultPress Murder

* faulty logic
deactivate_plugins( $plugin_file );
?>
<div class="notice notice-success">
<h2 style="margin-bottom: 0.25em;"><?php _e( 'Jetpack is now handling your backups.', 'jetpack' ); ?></h2>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The headline "Jetpack is now handling your backups" is not necessarily true if Rewind is available but inactive.

It sounds like (in the other thread) there is consensus that we want VaultPress disabled if Rewind is available, even if isn't active, so I don't want to tell users we're handling their backups if it's possible we're not. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This message should only show if Rewind is actually configured, but we will confirm that in testing leading up to our wide launch.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants