Skip to content

Commit

Permalink
Closes #6329: Deprecate RUCSS Hooks (#6342)
Browse files Browse the repository at this point in the history
Co-authored-by: Rémy Perona <[email protected]>
Co-authored-by: Rémy Perona <[email protected]>
Co-authored-by: Gael Robin <[email protected]>
Co-authored-by: WordPress Fan <[email protected]>
Co-authored-by: Opeyemi Ibrahim <[email protected]>
Co-authored-by: Mathieu Lamiot <[email protected]>
Co-authored-by: WordPressFan <[email protected]>
  • Loading branch information
8 people authored Apr 30, 2024
1 parent 1b6f197 commit b86840b
Show file tree
Hide file tree
Showing 24 changed files with 359 additions and 53 deletions.
2 changes: 1 addition & 1 deletion assets/js/lcp-beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,4 @@ class RocketLcpBeacon {
}
}

RocketLcpBeacon.run();
RocketLcpBeacon.run();
2 changes: 1 addition & 1 deletion assets/js/lcp-beacon.js.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/wpr-admin.js.min.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inc/Engine/Activation/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static function activate_plugin() {
require WP_ROCKET_FUNCTIONS_PATH . 'i18n.php';
require WP_ROCKET_FUNCTIONS_PATH . 'htaccess.php';
require WP_ROCKET_FUNCTIONS_PATH . 'api.php';
require WP_ROCKET_FUNCTIONS_PATH . 'admin.php';

/**
* WP Rocket activation.
Expand Down
7 changes: 6 additions & 1 deletion inc/Engine/Common/Database/Queries/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ public function create_new_job( string $url, string $job_id = '', string $queue_
* @param mixed $is_success New job status: ID of inserted row if successfully added; false otherwise.
* @param string $timestamp Current timestamp.
*/
do_action( 'rocket_last_rucss_job_added_time', $result, current_time( 'mysql', true ) );
rocket_do_action_and_deprecated(
'rocket_last_saas_job_added_time',
[ $result, current_time( 'mysql', true ) ],
'3.16',
'rocket_last_rucss_job_added_time'
);

return $result;
}
Expand Down
11 changes: 8 additions & 3 deletions inc/Engine/Common/Database/Tables/AbstractTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ public function delete_old_rows() {
}

/**
* Filters the old RUCSS deletion interval
* Filters the old SaaS data deletion interval
*
* @param int $delete_interval Old RUCSS deletion interval in months
* @param int $delete_interval Old Saas data deletion interval in months
*/
$delete_interval = (int) apply_filters( 'rocket_saas_delete_interval', 1 );
$delete_interval = (int) rocket_apply_filter_and_deprecated(
'rocket_saas_delete_interval',
[ 1 ],
'3.16',
'rocket_rucss_delete_interval'
);

if ( $delete_interval <= 0 ) {
return false;
Expand Down
28 changes: 24 additions & 4 deletions inc/Engine/Common/JobManager/Cron/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ public function add_interval( $schedules ) {
*
* @param int $interval Interval in seconds.
*/
$interval = apply_filters( 'rocket_saas_pending_jobs_cron_interval', 1 * rocket_get_constant( 'MINUTE_IN_SECONDS', 60 ) );
$interval = rocket_apply_filter_and_deprecated(
'rocket_saas_pending_jobs_cron_interval',
[ 1 * rocket_get_constant( 'MINUTE_IN_SECONDS', 60 ) ],
'3.16',
'rocket_rucss_pending_jobs_cron_interval'
);

$schedules['rocket_saas_pending_jobs'] = [
'interval' => $interval,
Expand All @@ -186,7 +191,12 @@ public function add_interval( $schedules ) {
*
* @param int $interval Interval in seconds.
*/
$interval = apply_filters( 'rocket_remove_saas_failed_jobs_cron_interval', $default_interval );
$interval = rocket_apply_filter_and_deprecated(
'rocket_remove_saas_failed_jobs_cron_interval',
[ $default_interval ],
'3.16',
'rocket_remove_rucss_failed_jobs_cron_interval'
);
$interval = (bool) $interval ? $interval : $default_interval;

$schedules['rocket_remove_saas_failed_jobs'] = [
Expand All @@ -199,7 +209,12 @@ public function add_interval( $schedules ) {
*
* @param int $interval Interval in seconds.
*/
$interval = (int) apply_filters( 'rocket_remove_saas_on_submit_jobs_cron_interval', 1 * rocket_get_constant( 'MINUTE_IN_SECONDS', 60 ) );
$interval = (int) rocket_apply_filter_and_deprecated(
'rocket_remove_saas_on_submit_jobs_cron_interval',
[ 1 * rocket_get_constant( 'MINUTE_IN_SECONDS', 60 ) ],
'3.16',
'rocket_remove_rucss_on_submit_jobs_cron_interval'
);

$schedules['rocket_saas_on_submit_jobs'] = [
'interval' => $interval,
Expand Down Expand Up @@ -312,7 +327,12 @@ protected function is_deletion_enabled(): bool {
*
* @param bool $delete_saas_jobs True to enable deletion, false otherwise.
*/
return (bool) apply_filters( 'rocket_saas_deletion_enabled', true );
return (bool) rocket_apply_filter_and_deprecated(
'rocket_saas_deletion_enabled',
[ true ],
'3.16',
'rocket_rucss_deletion_enabled'
);
}

/**
Expand Down
78 changes: 68 additions & 10 deletions inc/Engine/Common/JobManager/JobProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ public function process_pending_jobs() {
*
* @param string $current_time Current time.
*/
do_action( 'rocket_rucss_process_pending_jobs_start', $this->wpr_clock->current_time( 'mysql', true ) );
rocket_do_action_and_deprecated(
'rocket_saas_process_pending_jobs_start',
[ $this->wpr_clock->current_time( 'mysql', true ) ],
'3.16',
'rocket_rucss_process_pending_jobs_start'
);
$this->logger::debug( 'RUCSS: Start processing pending jobs inside cron.' );

if ( ! $this->is_allowed() ) {
Expand All @@ -121,7 +126,12 @@ public function process_pending_jobs() {
*
* @param int $rows Number of rows to grab with each CRON iteration.
*/
$rows = apply_filters( 'rocket_saas_pending_jobs_cron_rows_count', 100 );
$rows = rocket_apply_filter_and_deprecated(
'rocket_saas_pending_jobs_cron_rows_count',
[ 100 ],
'3.16',
'rocket_rucss_pending_jobs_cron_rows_count'
);

$pending_jobs = $this->get_jobs( $rows, 'pending' );

Expand All @@ -144,7 +154,12 @@ public function process_pending_jobs() {
*
* @param string $current_time Current time.
*/
do_action( 'rocket_rucss_process_pending_jobs_end', $this->wpr_clock->current_time( 'mysql', true ) );
rocket_do_action_and_deprecated(
'rocket_saas_process_pending_jobs_end',
[ $this->wpr_clock->current_time( 'mysql', true ) ],
'3.16',
'rocket_rucss_process_pending_jobs_end'
);
}

/**
Expand Down Expand Up @@ -191,13 +206,30 @@ public function check_job_status( string $url, bool $is_mobile, string $optimiza
$factory->manager()->process( $job_details, $row_details, $optimization_type );
}

/**
* Fires after successfully Processing the SaaS jobs.
*
* @param string $current_time Current time.
*/
rocket_do_action_and_deprecated(
'rocket_saas_check_job_status_end',
[ $this->wpr_clock->current_time( 'mysql', true ) ],
'3.16',
'rocket_rucss_check_job_status_end'
);

/**
* Fires after successfully processing the SaaS jobs.
*
* @param string $url Optimized Url.
* @param array $job_details Result of the request to get the job status from SaaS.
*/
do_action( 'rocket_saas_complete_job_status', $row_details->url, $job_details );
rocket_do_action_and_deprecated(
'rocket_saas_complete_job_status',
[ $row_details->url, $job_details ],
'3.16',
'rocket_rucss_complete_job_status'
);
}

/**
Expand All @@ -213,7 +245,12 @@ public function process_on_submit_jobs() {
*
* @param string $current_time Current time.
*/
do_action( 'rocket_rucss_process_on_submit_jobs_start', $this->wpr_clock->current_time( 'mysql', true ) );
rocket_do_action_and_deprecated(
'rocket_saas_process_on_submit_jobs_start',
[ $this->wpr_clock->current_time( 'mysql', true ) ],
'3.16',
'rocket_rucss_process_on_submit_jobs_start'
);

if ( ! $this->is_allowed() ) {
$this->logger::debug( 'Stop processing cron iteration for to-submit jobs.' );
Expand All @@ -226,15 +263,26 @@ public function process_on_submit_jobs() {
*
* @param int $count Number of rows.
*/
$pending_job = (int) apply_filters( 'rocket_saas_pending_jobs_cron_rows_count', 100 );
$pending_job = rocket_apply_filter_and_deprecated(
'rocket_saas_pending_jobs_cron_rows_count',
[ 100 ],
'3.16',
'rocket_rucss_pending_jobs_cron_rows_count'
);

/**
* Maximum processing rows.
*
* @param int $max Max processing rows.
*/
$max_pending_rows = (int) apply_filters( 'rocket_saas_max_pending_jobs', 3 * $pending_job, $pending_job );
$rows = $this->get_jobs( $max_pending_rows, 'submit' );
$max_pending_rows = (int) rocket_apply_filter_and_deprecated(
'rocket_saas_max_pending_jobs',
[ 3 * $pending_job, $pending_job ],
'3.16',
'rocket_rucss_max_pending_jobs'
);

$rows = $this->get_jobs( $max_pending_rows, 'submit' );

if ( ! $rows ) {
return;
Expand Down Expand Up @@ -272,7 +320,12 @@ public function process_on_submit_jobs() {
*
* @param string $current_time Current time.
*/
do_action( 'rocket_rucss_process_pending_jobs_end', $this->wpr_clock->current_time( 'mysql', true ) );
rocket_do_action_and_deprecated(
'rocket_saas_process_on_submit_jobs_end',
[ $this->wpr_clock->current_time( 'mysql', true ) ],
'3.16',
'rocket_rucss_process_on_submit_jobs_end'
);
}

/**
Expand Down Expand Up @@ -351,7 +404,12 @@ public function clear_failed_urls(): void {
*
* @param string $delay delay before failed saas jobs are deleted.
*/
$delay = (string) apply_filters( 'rocket_delay_remove_saas_failed_jobs', '3 days' );
$delay = (string) rocket_apply_filter_and_deprecated(
'rocket_delay_remove_saas_failed_jobs',
[ '3 days' ],
'3.16',
'rocket_delay_remove_rucss_failed_jobs'
);

if ( '' === $delay || '0' === $delay ) {
$delay = '3 days';
Expand Down
Loading

0 comments on commit b86840b

Please sign in to comment.