Skip to content
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

Scheduled Updates: raise scheduled updates limit #37181

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Raised limit of schedules to 24.
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,6 @@ public function validate_schedule( $request ) {
$plugins = $request['plugins'];
usort( $plugins, 'strnatcasecmp' );

if ( empty( $request['schedule_id'] ) && count( $events ) >= 2 ) {
return new WP_Error( 'rest_forbidden', __( 'Sorry, you can not create more than two schedules at this time.', 'jetpack-scheduled-updates' ), array( 'status' => 403 ) );
}

foreach ( $events as $key => $event ) {

// We'll update this schedule, so none of the checks apply.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,35 +311,6 @@ public function test_creating_schedules_for_same_time() {
$this->assertSame( 'rest_forbidden', $result->get_data()['code'] );
}

/**
* Can't have more than two schedules.
*
* @covers ::validate_schedule
*/
public function test_creating_more_than_two_schedules() {
// Create two schedules.
wp_schedule_event( strtotime( 'next Monday 8:00' ), 'weekly', Scheduled_Updates::PLUGIN_CRON_HOOK, array( 'gutenberg/gutenberg.php' ) );
wp_schedule_event( strtotime( 'next Tuesday 9:00' ), 'daily', Scheduled_Updates::PLUGIN_CRON_HOOK, array( 'custom-plugin/custom-plugin.php' ) );

// Number 3.
$request = new WP_REST_Request( 'POST', '/wpcom/v2/update-schedules' );
$request->set_body_params(
array(
'plugins' => array(
'gutenberg/gutenberg.php',
'custom-plugin/custom-plugin.php',
),
'schedule' => $this->get_schedule( 'next Wednesday 10:00', 'daily' ),
)
);

wp_set_current_user( $this->admin_id );
$result = rest_do_request( $request );

$this->assertSame( 403, $result->get_status() );
$this->assertSame( 'rest_forbidden', $result->get_data()['code'] );
}

/**
* Removes plugins from the autoupdate list when creating a schedule.
*
Expand Down