From adcd1201ca2696faec9c7d321521912d16077e6b Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Tue, 11 Jun 2024 14:34:38 +0200 Subject: [PATCH 1/7] Add indexable enabled check to the activation of the plugin hook. --- .../admin/activation-cleanup-integration.php | 17 +++++- .../Activation_Cleanup_Integration_Test.php | 53 ++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/integrations/admin/activation-cleanup-integration.php b/src/integrations/admin/activation-cleanup-integration.php index 87270662491..676243026f1 100644 --- a/src/integrations/admin/activation-cleanup-integration.php +++ b/src/integrations/admin/activation-cleanup-integration.php @@ -3,6 +3,7 @@ namespace Yoast\WP\SEO\Integrations\Admin; use Yoast\WP\SEO\Conditionals\No_Conditionals; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Integrations\Cleanup_Integration; use Yoast\WP\SEO\Integrations\Integration_Interface; @@ -14,6 +15,13 @@ class Activation_Cleanup_Integration implements Integration_Interface { use No_Conditionals; + /** + * The indexable helper. + * + * @var \Yoast\WP\SEO\Helpers\Indexable_Helper + */ + protected $indexable_helper; + /** * The options helper. * @@ -27,9 +35,11 @@ class Activation_Cleanup_Integration implements Integration_Interface { * @param Options_Helper $options_helper The options helper. */ public function __construct( - Options_Helper $options_helper + Options_Helper $options_helper, + Indexable_Helper $indexable_helper ) { - $this->options_helper = $options_helper; + $this->options_helper = $options_helper; + $this->indexable_helper = $indexable_helper; } /** @@ -49,6 +59,9 @@ public function register_hooks() { public function register_cleanup_routine() { $first_activated_on = $this->options_helper->get( 'first_activated_on', false ); + if (! $this->indexable_helper->should_index_indexables() ) { + return; + } if ( ! $first_activated_on || \time() > ( $first_activated_on + ( \MINUTE_IN_SECONDS * 5 ) ) ) { if ( ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ) ) { \wp_schedule_single_event( ( \time() + \DAY_IN_SECONDS ), Cleanup_Integration::START_HOOK ); diff --git a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php index 7127b4e5a47..7dee49aa6c9 100644 --- a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php +++ b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php @@ -4,6 +4,7 @@ use Brain\Monkey; use Mockery; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Integrations\Admin\Activation_Cleanup_Integration; use Yoast\WP\SEO\Integrations\Cleanup_Integration; @@ -20,7 +21,14 @@ final class Activation_Cleanup_Integration_Test extends TestCase { /** - * Represents the indexable repository. + * Represents the indexable helper. + * + * @var Mockery\MockInterface|\Yoast\WP\SEO\Helpers\Indexable_Helper + */ + protected $indexable_helper; + + /** + * Represents the options helper. * * @var Mockery\MockInterface|Options_Helper */ @@ -42,7 +50,8 @@ protected function set_up() { parent::set_up(); $this->options_helper = Mockery::mock( Options_Helper::class ); - $this->instance = new Activation_Cleanup_Integration( $this->options_helper ); + $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); + $this->instance = new Activation_Cleanup_Integration( $this->options_helper, $this->indexable_helper ); } /** @@ -88,6 +97,10 @@ public function test_register_cleanup_routine_no_running() { ->once() ->with( ( \time() + \DAY_IN_SECONDS ), Cleanup_Integration::START_HOOK ); + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + $this->options_helper->expects( 'get' ) ->once() ->with( 'first_activated_on', false ) @@ -104,6 +117,10 @@ public function test_register_cleanup_routine_no_running() { * @return void */ public function test_register_cleanup_routine_already_running() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + Monkey\Functions\expect( 'wp_next_scheduled' ) ->once() ->with( Cleanup_Integration::START_HOOK ) @@ -129,6 +146,38 @@ public function test_register_cleanup_routine_already_running() { * @return void */ public function test_register_cleanup_routine_first_time_install() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + + $this->options_helper->expects( 'get' ) + ->once() + ->with( 'first_activated_on', false ) + ->andReturn( \time() ); + + Monkey\Functions\expect( 'wp_next_scheduled' ) + ->never() + ->with( Cleanup_Integration::START_HOOK ) + ->andReturnTrue(); + + Monkey\Functions\expect( 'wp_schedule_single_event' ) + ->never(); + + $this->instance->register_cleanup_routine(); + } + + /** + * Tests that the cleanup routine is not scheduled when indexables are disabled. + * + * @covers ::register_cleanup_routine + * + * @return void + */ + public function test_register_cleanup_routine_indexables_disabled() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnFalse(); + $this->options_helper->expects( 'get' ) ->once() ->with( 'first_activated_on', false ) From b7641fda44d96d29e78551e9d28ea3f0e05e212f Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Tue, 11 Jun 2024 14:58:55 +0200 Subject: [PATCH 2/7] Add indexable check when the cleanups are about to run to make sure they should otherwise disable the cron. --- .../admin/activation-cleanup-integration.php | 4 +- src/integrations/cleanup-integration.php | 24 +++++- .../Activation_Cleanup_Integration_Test.php | 6 +- .../Integrations/Cleanup_Integration_Test.php | 76 ++++++++++++++++++- 4 files changed, 103 insertions(+), 7 deletions(-) diff --git a/src/integrations/admin/activation-cleanup-integration.php b/src/integrations/admin/activation-cleanup-integration.php index 676243026f1..8ecb9c6db6b 100644 --- a/src/integrations/admin/activation-cleanup-integration.php +++ b/src/integrations/admin/activation-cleanup-integration.php @@ -18,7 +18,7 @@ class Activation_Cleanup_Integration implements Integration_Interface { /** * The indexable helper. * - * @var \Yoast\WP\SEO\Helpers\Indexable_Helper + * @var Indexable_Helper */ protected $indexable_helper; @@ -59,7 +59,7 @@ public function register_hooks() { public function register_cleanup_routine() { $first_activated_on = $this->options_helper->get( 'first_activated_on', false ); - if (! $this->indexable_helper->should_index_indexables() ) { + if ( ! $this->indexable_helper->should_index_indexables() ) { return; } if ( ! $first_activated_on || \time() > ( $first_activated_on + ( \MINUTE_IN_SECONDS * 5 ) ) ) { diff --git a/src/integrations/cleanup-integration.php b/src/integrations/cleanup-integration.php index 10e66ef1fbb..3e689e94eca 100644 --- a/src/integrations/cleanup-integration.php +++ b/src/integrations/cleanup-integration.php @@ -3,6 +3,7 @@ namespace Yoast\WP\SEO\Integrations; use Closure; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Repositories\Indexable_Cleanup_Repository; /** @@ -25,6 +26,13 @@ class Cleanup_Integration implements Integration_Interface { */ public const START_HOOK = 'wpseo_start_cleanup_indexables'; + /** + * The indexable helper. + * + * @var Indexable_Helper + */ + private $indexable_helper; + /** * The cleanup repository. * @@ -37,8 +45,12 @@ class Cleanup_Integration implements Integration_Interface { * * @param Indexable_Cleanup_Repository $cleanup_repository The cleanup repository. */ - public function __construct( Indexable_Cleanup_Repository $cleanup_repository ) { + public function __construct( + Indexable_Cleanup_Repository $cleanup_repository, + Indexable_Helper $indexable_helper + ) { $this->cleanup_repository = $cleanup_repository; + $this->indexable_helper = $indexable_helper; } /** @@ -71,6 +83,10 @@ public static function get_conditionals() { public function run_cleanup() { $this->reset_cleanup(); + if ( ! $this->indexable_helper->should_index_indexables() ) { + return; + } + $cleanups = $this->get_cleanup_tasks(); $limit = $this->get_limit(); @@ -263,6 +279,12 @@ public function start_cron_job( $task_name, $schedule_time = 3600 ) { * @return void */ public function run_cleanup_cron() { + if ( ! $this->indexable_helper->should_index_indexables() ) { + $this->reset_cleanup(); + + return; + } + $current_task_name = \get_option( self::CURRENT_TASK_OPTION ); if ( $current_task_name === false ) { diff --git a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php index 7dee49aa6c9..ca2d565e4c7 100644 --- a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php +++ b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php @@ -23,7 +23,7 @@ final class Activation_Cleanup_Integration_Test extends TestCase { /** * Represents the indexable helper. * - * @var Mockery\MockInterface|\Yoast\WP\SEO\Helpers\Indexable_Helper + * @var Mockery\MockInterface|Indexable_Helper */ protected $indexable_helper; @@ -49,9 +49,9 @@ final class Activation_Cleanup_Integration_Test extends TestCase { protected function set_up() { parent::set_up(); - $this->options_helper = Mockery::mock( Options_Helper::class ); + $this->options_helper = Mockery::mock( Options_Helper::class ); $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); - $this->instance = new Activation_Cleanup_Integration( $this->options_helper, $this->indexable_helper ); + $this->instance = new Activation_Cleanup_Integration( $this->options_helper, $this->indexable_helper ); } /** diff --git a/tests/Unit/Integrations/Cleanup_Integration_Test.php b/tests/Unit/Integrations/Cleanup_Integration_Test.php index 63522be8bd6..274c73a5518 100644 --- a/tests/Unit/Integrations/Cleanup_Integration_Test.php +++ b/tests/Unit/Integrations/Cleanup_Integration_Test.php @@ -5,6 +5,7 @@ use Brain\Monkey; use Mockery; use wpdb; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Integrations\Cleanup_Integration; use Yoast\WP\SEO\Repositories\Indexable_Cleanup_Repository; use Yoast\WP\SEO\Repositories\Indexable_Repository; @@ -19,6 +20,13 @@ */ final class Cleanup_Integration_Test extends TestCase { + /** + * The indexables helper. + * + * @var Mockery\MockInterface|Indexable_Helper + */ + private $indexable_helper; + /** * Represents the instance we are testing. * @@ -49,9 +57,11 @@ protected function set_up() { parent::set_up(); $this->indexable_repository = Mockery::mock( Indexable_Cleanup_Repository::class ); + $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); $this->instance = new Cleanup_Integration( - $this->indexable_repository + $this->indexable_repository, + $this->indexable_helper ); global $wpdb; @@ -99,6 +109,10 @@ public function test_get_conditionals() { * @return void */ public function test_run_cleanup() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + Monkey\Functions\expect( 'delete_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ); @@ -138,6 +152,9 @@ public function test_run_cleanup() { * @return void */ public function test_run_cleanup_db_query_failed() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'delete_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ); @@ -168,6 +185,9 @@ public function test_run_cleanup_db_query_failed() { * @return void */ public function test_run_cleanup_starts_cron_job() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'delete_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ); @@ -207,6 +227,9 @@ public function test_run_cleanup_starts_cron_job() { * @return void */ public function test_run_cleanup_cron_next_task() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -240,6 +263,9 @@ public function test_run_cleanup_cron_next_task() { * @return void */ public function test_run_cleanup_cron_last_task() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -274,6 +300,9 @@ public function test_run_cleanup_cron_last_task() { * @return void */ public function test_run_cleanup_cron_no_tasks_left() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -302,6 +331,9 @@ public function test_run_cleanup_cron_no_tasks_left() { * @return void */ public function test_run_cleanup_cron_db_query_failed() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -337,6 +369,10 @@ public function test_run_cleanup_cron_db_query_failed() { * @return void */ public function test_run_cleanup_cron_items_left() { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -364,6 +400,11 @@ public function test_run_cleanup_cron_items_left() { * @return void */ public function test_run_cleanup_invalid_query_limit_from_filter() { + + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnTrue(); + Monkey\Functions\expect( 'get_option' ) ->once() ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) @@ -377,4 +418,37 @@ public function test_run_cleanup_invalid_query_limit_from_filter() { $this->instance->run_cleanup_cron(); } + + /** + * Tests the run_cleanup_cron function. + * + * Specifically tests whether the query limit is + * + * @covers ::run_cleanup_cron + * @covers ::get_limit + * @covers ::get_cleanup_tasks + * + * @return void + */ + public function test_run_cleanup_indexables_disabled() { + + $this->indexable_helper->expects( 'should_index_indexables' ) + ->once() + ->andReturnFalse(); + + Monkey\Functions\expect( 'delete_option' ) + ->once() + ->with( Cleanup_Integration::CURRENT_TASK_OPTION ); + + Monkey\Functions\expect( 'wp_unschedule_hook' ) + ->once() + ->with( Cleanup_Integration::CRON_HOOK ); + + Monkey\Functions\expect( 'get_option' ) + ->never() + ->with( Cleanup_Integration::CURRENT_TASK_OPTION ) + ->andReturn( 'clean_indexables_by_post_status_auto-draft' ); + + $this->instance->run_cleanup_cron(); + } } From ee833e853b2d1d7ba3449057fed45c326583ea6c Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Wed, 12 Jun 2024 15:05:37 +0200 Subject: [PATCH 3/7] Add check to make sure we only want to schedule when indexables are enabled. --- composer.json | 2 +- .../admin/activation-cleanup-integration.php | 3 +- src/integrations/cleanup-integration.php | 3 +- .../watchers/indexable-attachment-watcher.php | 21 ++++++-- .../indexable-author-archive-watcher.php | 23 +++++++-- .../indexable-post-type-change-watcher.php | 17 +++++-- .../watchers/indexable-post-watcher.php | 6 ++- .../indexable-taxonomy-change-watcher.php | 17 +++++-- .../Indexable_Attachment_Watcher_Test.php | 24 +++++++++- ...ndexable_Post_Type_Change_Watcher_Test.php | 30 ++++++++---- .../Watchers/Indexable_Post_Watcher_Test.php | 12 +++++ ...Indexable_Taxonomy_Change_Watcher_Test.php | 48 ++++++++++++------- 12 files changed, 159 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index fe4dce3ee37..3775d93d9e9 100644 --- a/composer.json +++ b/composer.json @@ -92,7 +92,7 @@ "Yoast\\WP\\SEO\\Composer\\Actions::check_coding_standards" ], "check-cs-thresholds": [ - "@putenv YOASTCS_THRESHOLD_ERRORS=2523", + "@putenv YOASTCS_THRESHOLD_ERRORS=2507", "@putenv YOASTCS_THRESHOLD_WARNINGS=253", "Yoast\\WP\\SEO\\Composer\\Actions::check_cs_thresholds" ], diff --git a/src/integrations/admin/activation-cleanup-integration.php b/src/integrations/admin/activation-cleanup-integration.php index 8ecb9c6db6b..8ca21c54704 100644 --- a/src/integrations/admin/activation-cleanup-integration.php +++ b/src/integrations/admin/activation-cleanup-integration.php @@ -32,7 +32,8 @@ class Activation_Cleanup_Integration implements Integration_Interface { /** * Activation_Cleanup_Integration constructor. * - * @param Options_Helper $options_helper The options helper. + * @param Options_Helper $options_helper The options helper. + * @param Indexable_Helper $indexable_helper The indexable helper. */ public function __construct( Options_Helper $options_helper, diff --git a/src/integrations/cleanup-integration.php b/src/integrations/cleanup-integration.php index 3e689e94eca..653b0039303 100644 --- a/src/integrations/cleanup-integration.php +++ b/src/integrations/cleanup-integration.php @@ -44,6 +44,7 @@ class Cleanup_Integration implements Integration_Interface { * The constructor. * * @param Indexable_Cleanup_Repository $cleanup_repository The cleanup repository. + * @param Indexable_Helper $indexable_helper The indexable helper. */ public function __construct( Indexable_Cleanup_Repository $cleanup_repository, @@ -69,7 +70,7 @@ public function register_hooks() { /** * Returns the conditionals based on which this loadable should be active. * - * @return array The array of conditionals. + * @return array The array of conditionals. */ public static function get_conditionals() { return []; diff --git a/src/integrations/watchers/indexable-attachment-watcher.php b/src/integrations/watchers/indexable-attachment-watcher.php index 6f34a43b95f..4ad9587ee9e 100644 --- a/src/integrations/watchers/indexable-attachment-watcher.php +++ b/src/integrations/watchers/indexable-attachment-watcher.php @@ -6,6 +6,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; use Yoast\WP\SEO\Helpers\Attachment_Cleanup_Helper; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Integrations\Cleanup_Integration; use Yoast\WP\SEO\Integrations\Integration_Interface; @@ -30,6 +31,13 @@ class Indexable_Attachment_Watcher implements Integration_Interface { */ protected $attachment_cleanup; + /** + * The indexable helper. + * + * @var Indexable_Helper + */ + protected $indexable_helper; + /** * The notifications center. * @@ -40,7 +48,7 @@ class Indexable_Attachment_Watcher implements Integration_Interface { /** * Returns the conditionals based on which this loadable should be active. * - * @return array + * @return array The conditionals. */ public static function get_conditionals() { return [ Migrations_Conditional::class ]; @@ -52,15 +60,18 @@ public static function get_conditionals() { * @param Indexing_Helper $indexing_helper The indexing helper. * @param Attachment_Cleanup_Helper $attachment_cleanup The attachment cleanup helper. * @param Yoast_Notification_Center $notification_center The notification center. + * @param Indexable_Helper $indexable_helper The indexable helper. */ public function __construct( Indexing_Helper $indexing_helper, Attachment_Cleanup_Helper $attachment_cleanup, - Yoast_Notification_Center $notification_center + Yoast_Notification_Center $notification_center, + Indexable_Helper $indexable_helper ) { $this->indexing_helper = $indexing_helper; $this->attachment_cleanup = $attachment_cleanup; $this->notification_center = $notification_center; + $this->indexable_helper = $indexable_helper; } /** @@ -79,8 +90,8 @@ public function register_hooks() { * either it cleans up attachment indexables when it has been toggled to true, * or it starts displaying a notification for the user to start a new SEO optimization. * - * @param array $old_value The old value of the wpseo_titles option. - * @param array $new_value The new value of the wpseo_titles option. + * @param array $old_value The old value of the wpseo_titles option. + * @param array $new_value The new value of the wpseo_titles option. * * @return void */ @@ -119,7 +130,7 @@ public function check_option( $old_value, $new_value ) { $this->attachment_cleanup->remove_attachment_indexables( false ); $this->attachment_cleanup->clean_attachment_links_from_target_indexable_ids( false ); - if ( ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ) ) { + if ( $this->indexable_helper->should_index_indexables() && ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ) ) { // This just schedules the cleanup routine cron again. \wp_schedule_single_event( ( \time() + ( \MINUTE_IN_SECONDS * 5 ) ), Cleanup_Integration::START_HOOK ); } diff --git a/src/integrations/watchers/indexable-author-archive-watcher.php b/src/integrations/watchers/indexable-author-archive-watcher.php index b607fb6d2f3..83af7c31ecd 100644 --- a/src/integrations/watchers/indexable-author-archive-watcher.php +++ b/src/integrations/watchers/indexable-author-archive-watcher.php @@ -3,6 +3,7 @@ namespace Yoast\WP\SEO\Integrations\Watchers; use Yoast\WP\SEO\Conditionals\Migrations_Conditional; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Integrations\Cleanup_Integration; use Yoast\WP\SEO\Integrations\Integration_Interface; @@ -11,6 +12,22 @@ */ class Indexable_Author_Archive_Watcher implements Integration_Interface { + /** + * The indexable helper. + * + * @var Indexable_Helper + */ + protected $indexable_helper; + + /** + * Indexable_Author_Archive_Watcher constructor. + * + * @param Indexable_Helper $indexable_helper The indexable helper. + */ + public function __construct( Indexable_Helper $indexable_helper ) { + $this->indexable_helper = $indexable_helper; + } + /** * Check if the author archives are disabled whenever the `wpseo_titles` option * changes. @@ -42,13 +59,13 @@ public static function get_conditionals() { * * When author archives are disabled, they can never be indexed. * - * @param array $old_value The old `wpseo_titles` option value. - * @param array $new_value The new `wpseo_titles` option value. + * @param array $old_value The old `wpseo_titles` option value. + * @param array $new_value The new `wpseo_titles` option value. * * @return void */ public function reschedule_indexable_cleanup_when_author_archives_are_disabled( $old_value, $new_value ) { - if ( $old_value['disable-author'] !== true && $new_value['disable-author'] === true ) { + if ( $old_value['disable-author'] !== true && $new_value['disable-author'] === true && $this->indexable_helper->should_index_indexables() ) { $cleanup_not_yet_scheduled = ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ); if ( $cleanup_not_yet_scheduled ) { \wp_schedule_single_event( ( \time() + ( \MINUTE_IN_SECONDS * 5 ) ), Cleanup_Integration::START_HOOK ); diff --git a/src/integrations/watchers/indexable-post-type-change-watcher.php b/src/integrations/watchers/indexable-post-type-change-watcher.php index df80a0cf1dc..69b54cce561 100644 --- a/src/integrations/watchers/indexable-post-type-change-watcher.php +++ b/src/integrations/watchers/indexable-post-type-change-watcher.php @@ -7,6 +7,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Conditionals\Not_Admin_Ajax_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Post_Type_Helper; @@ -26,6 +27,13 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface { */ protected $indexing_helper; + /** + * The indexable helper. + * + * @var Indexable_Helper + */ + private $indexable_helper; + /** * Holds the Options_Helper instance. * @@ -50,7 +58,7 @@ class Indexable_Post_Type_Change_Watcher implements Integration_Interface { /** * Returns the conditionals based on which this loadable should be active. * - * @return array + * @return array The conditionals. */ public static function get_conditionals() { return [ Not_Admin_Ajax_Conditional::class, Admin_Conditional::class, Migrations_Conditional::class ]; @@ -63,17 +71,20 @@ public static function get_conditionals() { * @param Indexing_Helper $indexing_helper The indexing helper. * @param Post_Type_Helper $post_type_helper The post_typehelper. * @param Yoast_Notification_Center $notification_center The notification center. + * @param Indexable_Helper $indexable_helper The indexable helper. */ public function __construct( Options_Helper $options, Indexing_Helper $indexing_helper, Post_Type_Helper $post_type_helper, - Yoast_Notification_Center $notification_center + Yoast_Notification_Center $notification_center, + Indexable_Helper $indexable_helper ) { $this->options = $options; $this->indexing_helper = $indexing_helper; $this->post_type_helper = $post_type_helper; $this->notification_center = $notification_center; + $this->indexable_helper = $indexable_helper; } /** @@ -135,7 +146,7 @@ public function check_post_types_public_availability() { } // There are post types that have been made private. - if ( $newly_made_non_public_post_types ) { + if ( $newly_made_non_public_post_types && $this->indexable_helper->should_index_indexables() ) { // Schedule a cron job to remove all the posts whose post type has been made private. $cleanup_not_yet_scheduled = ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ); if ( $cleanup_not_yet_scheduled ) { diff --git a/src/integrations/watchers/indexable-post-watcher.php b/src/integrations/watchers/indexable-post-watcher.php index 21564d94c28..0c1e68c7549 100644 --- a/src/integrations/watchers/indexable-post-watcher.php +++ b/src/integrations/watchers/indexable-post-watcher.php @@ -84,7 +84,7 @@ class Indexable_Post_Watcher implements Integration_Interface { /** * Returns the conditionals based on which this loadable should be active. * - * @return array + * @return array The conditionals. */ public static function get_conditionals() { return [ Migrations_Conditional::class ]; @@ -240,7 +240,9 @@ protected function update_has_public_posts( $indexable ) { $author_indexable->has_public_posts = $this->author_archive->author_has_public_posts( $author_indexable->object_id ); $this->indexable_helper->save_indexable( $author_indexable ); - $this->reschedule_cleanup_if_author_has_no_posts( $author_indexable ); + if ( $this->indexable_helper->should_index_indexable( $author_indexable ) ) { + $this->reschedule_cleanup_if_author_has_no_posts( $author_indexable ); + } } } catch ( Exception $exception ) { $this->logger->log( LogLevel::ERROR, $exception->getMessage() ); diff --git a/src/integrations/watchers/indexable-taxonomy-change-watcher.php b/src/integrations/watchers/indexable-taxonomy-change-watcher.php index 79099392f16..68b9f8f7e33 100644 --- a/src/integrations/watchers/indexable-taxonomy-change-watcher.php +++ b/src/integrations/watchers/indexable-taxonomy-change-watcher.php @@ -7,6 +7,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Conditionals\Not_Admin_Ajax_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Taxonomy_Helper; @@ -28,6 +29,13 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface { */ protected $indexing_helper; + /** + * The indexable helper. + * + * @var Indexable_Helper + */ + protected $indexable_helper; + /** * Holds the Options_Helper instance. * @@ -52,7 +60,7 @@ class Indexable_Taxonomy_Change_Watcher implements Integration_Interface { /** * Returns the conditionals based on which this loadable should be active. * - * @return array + * @return array The conditionals. */ public static function get_conditionals() { return [ Not_Admin_Ajax_Conditional::class, Admin_Conditional::class, Migrations_Conditional::class ]; @@ -65,17 +73,20 @@ public static function get_conditionals() { * @param Options_Helper $options The options helper. * @param Taxonomy_Helper $taxonomy_helper The taxonomy helper. * @param Yoast_Notification_Center $notification_center The notification center. + * @param Indexable_Helper $indexable_helper The indexable helper. */ public function __construct( Indexing_Helper $indexing_helper, Options_Helper $options, Taxonomy_Helper $taxonomy_helper, - Yoast_Notification_Center $notification_center + Yoast_Notification_Center $notification_center, + Indexable_Helper $indexable_helper ) { $this->indexing_helper = $indexing_helper; $this->options = $options; $this->taxonomy_helper = $taxonomy_helper; $this->notification_center = $notification_center; + $this->indexable_helper = $indexable_helper; } /** @@ -137,7 +148,7 @@ public function check_taxonomy_public_availability() { } // There are taxonomies that have been made private. - if ( ! empty( $newly_made_non_public_taxonomies ) ) { + if ( ! empty( $newly_made_non_public_taxonomies ) && $this->indexable_helper->should_index_indexables() ) { // Schedule a cron job to remove all the terms whose taxonomy has been made private. $cleanup_not_yet_scheduled = ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ); if ( $cleanup_not_yet_scheduled ) { diff --git a/tests/Unit/Integrations/Watchers/Indexable_Attachment_Watcher_Test.php b/tests/Unit/Integrations/Watchers/Indexable_Attachment_Watcher_Test.php index 0260e064f53..00f5982e23b 100644 --- a/tests/Unit/Integrations/Watchers/Indexable_Attachment_Watcher_Test.php +++ b/tests/Unit/Integrations/Watchers/Indexable_Attachment_Watcher_Test.php @@ -8,6 +8,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; use Yoast\WP\SEO\Helpers\Attachment_Cleanup_Helper; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Integrations\Cleanup_Integration; use Yoast\WP\SEO\Integrations\Watchers\Indexable_Attachment_Watcher; @@ -46,6 +47,13 @@ final class Indexable_Attachment_Watcher_Test extends TestCase { */ protected $notification_center; + /** + * The indexable helper mock. + * + * @var Mockery\MockInterface|Indexable_Helper + */ + private $indexable_helper; + /** * The Indexable_Attachment_Watcher instance. * @@ -64,11 +72,13 @@ protected function set_up() { $this->indexing_helper = Mockery::mock( Indexing_Helper::class ); $this->attachment_cleanup = Mockery::mock( Attachment_Cleanup_Helper::class ); $this->notification_center = Mockery::mock( Yoast_Notification_Center::class ); + $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); $this->instance = new Indexable_Attachment_Watcher( $this->indexing_helper, $this->attachment_cleanup, - $this->notification_center + $this->notification_center, + $this->indexable_helper ); } @@ -100,7 +110,7 @@ public function test_register_hooks() { /** * Data provider for test_check_option. * - * @return array + * @return array|null> */ public static function check_option_provider() { return [ @@ -240,6 +250,16 @@ public function test_check_option( $old_value, $new_value, $delete_transient_tim ->times( $attachment_cleanup_times ) ->andReturn( $wp_next_scheduled ); + if ( $wp_next_scheduled ) { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->times( 1 ) + ->andReturnTrue(); + } + else { + $this->indexable_helper->expects( 'should_index_indexables' ) + ->times( $schedule_event_times ) + ->andReturnTrue(); + } Monkey\Functions\expect( 'wp_schedule_single_event' ) ->with( ( \time() + ( \MINUTE_IN_SECONDS * 5 ) ), Cleanup_Integration::START_HOOK ) ->times( $schedule_event_times ); diff --git a/tests/Unit/Integrations/Watchers/Indexable_Post_Type_Change_Watcher_Test.php b/tests/Unit/Integrations/Watchers/Indexable_Post_Type_Change_Watcher_Test.php index 07a2f91fdd8..007e94371fe 100644 --- a/tests/Unit/Integrations/Watchers/Indexable_Post_Type_Change_Watcher_Test.php +++ b/tests/Unit/Integrations/Watchers/Indexable_Post_Type_Change_Watcher_Test.php @@ -9,6 +9,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Conditionals\Not_Admin_Ajax_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Post_Type_Helper; @@ -59,6 +60,13 @@ final class Indexable_Post_Type_Change_Watcher_Test extends TestCase { */ private $notification_center; + /** + * The indexable helper mock. + * + * @var Mockery\MockInterface|Indexable_Helper + */ + private $indexable_helper; + /** * Represents the instance to test. * @@ -78,12 +86,14 @@ protected function set_up() { $this->indexing_helper = Mockery::mock( Indexing_Helper::class ); $this->post_type_helper = Mockery::mock( Post_Type_Helper::class ); $this->notification_center = Mockery::mock( Yoast_Notification_Center::class ); + $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); $this->instance = new Indexable_Post_Type_Change_Watcher( $this->options, $this->indexing_helper, $this->post_type_helper, - $this->notification_center + $this->notification_center, + $this->indexable_helper ); } @@ -125,13 +135,13 @@ public function test_register_hooks() { * * @covers ::check_post_types_public_availability * - * @param bool $is_json_request Whether it's a JSON request. - * @param array $public_post_types The public post types. - * @param int $get_public_post_types_times The times we get the public post types. - * @param array $last_known_public_post_types The last known public post types. - * @param int $set_public_post_types_times The times we get the last known public post types. - * @param int $delete_transient_times The times we delete the transients. - * @param int $schedule_cleanup_times The times we schedule the cleanup. + * @param bool $is_json_request Whether it's a JSON request. + * @param array $public_post_types The public post types. + * @param int $get_public_post_types_times The times we get the public post types. + * @param array $last_known_public_post_types The last known public post types. + * @param int $set_public_post_types_times The times we get the last known public post types. + * @param int $delete_transient_times The times we delete the transients. + * @param int $schedule_cleanup_times The times we schedule the cleanup. * * @return void */ @@ -191,13 +201,15 @@ public function test_check_post_types_public_availability( Functions\expect( 'do_action' ) ->times( $delete_transient_times ); + $this->indexable_helper->expects( 'should_index_indexables' )->times( $schedule_cleanup_times )->andReturnTrue(); + $this->instance->check_post_types_public_availability(); } /** * Data provider for test_check_post_types_public_availability(). * - * @return array + * @return array> The data. */ public static function provider_check_post_types_public_availability() { diff --git a/tests/Unit/Integrations/Watchers/Indexable_Post_Watcher_Test.php b/tests/Unit/Integrations/Watchers/Indexable_Post_Watcher_Test.php index 29e3c11fe76..fd0f8942b5d 100644 --- a/tests/Unit/Integrations/Watchers/Indexable_Post_Watcher_Test.php +++ b/tests/Unit/Integrations/Watchers/Indexable_Post_Watcher_Test.php @@ -425,6 +425,12 @@ public function test_update_has_public_posts_with_post() { ->with( $author_indexable ) ->once(); + $this->indexable_helper + ->expects( 'should_index_indexable' ) + ->with( $author_indexable ) + ->andReturnTrue() + ->once(); + $this->post->expects( 'update_has_public_posts_on_attachments' )->once()->with( 33, null )->andReturnTrue(); $this->instance->update_has_public_posts( $post_indexable ); @@ -522,6 +528,12 @@ public function test_reschedule_cleanup_when_author_does_not_have_posts() { ->with( $author_indexable ) ->once(); + $this->indexable_helper + ->expects( 'should_index_indexable' ) + ->with( $author_indexable ) + ->once() + ->andReturnTrue(); + $this->post->expects( 'update_has_public_posts_on_attachments' ) ->once() ->with( 33, null ) diff --git a/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php b/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php index 453957a6e71..fc7d55780d0 100644 --- a/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php +++ b/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php @@ -9,6 +9,7 @@ use Yoast\WP\SEO\Conditionals\Migrations_Conditional; use Yoast\WP\SEO\Conditionals\Not_Admin_Ajax_Conditional; use Yoast\WP\SEO\Config\Indexing_Reasons; +use Yoast\WP\SEO\Helpers\Indexable_Helper; use Yoast\WP\SEO\Helpers\Indexing_Helper; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Taxonomy_Helper; @@ -20,17 +21,24 @@ /** * Class Indexable_Taxonomy_Change_Watcher_Test. * - * @group indexables - * @group integrations - * @group watchers + * @group indexables + * @group integrations + * @group watchers * * @coversDefaultClass \Yoast\WP\SEO\Integrations\Watchers\Indexable_Taxonomy_Change_Watcher * @covers \Yoast\WP\SEO\Integrations\Watchers\Indexable_Taxonomy_Change_Watcher * - * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded + * @phpcs :disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded */ final class Indexable_Taxonomy_Change_Watcher_Test extends TestCase { + /** + * Holds the Indexable_Helper instance. + * + * @var Mockery\MockInterface|Indexable_Helper + */ + private $indexable_helper; + /** * Holds the Options_Helper instance. * @@ -78,12 +86,14 @@ protected function set_up() { $this->options = Mockery::mock( Options_Helper::class ); $this->taxonomy_helper = Mockery::mock( Taxonomy_Helper::class ); $this->notification_center = Mockery::mock( Yoast_Notification_Center::class ); + $this->indexable_helper = Mockery::mock( Indexable_Helper::class ); $this->instance = new Indexable_Taxonomy_Change_Watcher( $this->indexing_helper, $this->options, $this->taxonomy_helper, - $this->notification_center + $this->notification_center, + $this->indexable_helper ); } @@ -125,13 +135,13 @@ public function test_register_hooks() { * * @covers ::check_taxonomy_public_availability * - * @param bool $is_json_request Whether it's a JSON request. - * @param array $public_taxonomies The public taxonomies. - * @param int $get_public_taxonomies_times The times we get the public taxonomies. - * @param array $last_known_public_taxonomies The last known public taxonomies. - * @param int $set_public_taxonomies_times The times we get the last known public taxonomies. - * @param int $delete_transient_times The times we delete the transients. - * @param int $schedule_cleanup_times The times we schedule cleanup. + * @param bool $is_json_request Whether it's a JSON request. + * @param array $public_taxonomies The public taxonomies. + * @param int $get_public_taxonomies_times The times we get the public taxonomies. + * @param array $last_known_public_taxonomies The last known public taxonomies. + * @param int $set_public_taxonomies_times The times we get the last known public taxonomies. + * @param int $delete_transient_times The times we delete the transients. + * @param int $schedule_cleanup_times The times we schedule cleanup. * * @return void */ @@ -191,18 +201,22 @@ public function test_check_taxonomy_public_availability( Functions\expect( 'do_action' ) ->times( $delete_transient_times ); + $this->indexable_helper->expects( 'should_index_indexables' ) + ->times( $schedule_cleanup_times ) + ->andReturnTrue(); + $this->instance->check_taxonomy_public_availability(); } /** * Data provider for test_check_taxonomy_public_availability(). * - * @return array + * @return array> The data. */ public static function provider_check_taxonomy_public_availability() { return [ - 'When it is ajax request' => [ + 'When it is ajax request' => [ 'is_json_request' => true, 'public_taxonomies' => [ 'irrelevant' ], 'get_public_taxonomies_times' => 0, @@ -211,7 +225,7 @@ public static function provider_check_taxonomy_public_availability() { 'delete_transient_times' => 0, 'schedule_cleanup_times' => 0, ], - 'When there are no new public taxonomies' => [ + 'When there are no new public taxonomies' => [ 'is_json_request' => false, 'public_taxonomies' => [], 'get_public_taxonomies_times' => 1, @@ -232,7 +246,7 @@ public static function provider_check_taxonomy_public_availability() { 'delete_transient_times' => 0, 'schedule_cleanup_times' => 0, ], - 'When new taxonomy is added' => [ + 'When new taxonomy is added' => [ 'is_json_request' => false, 'public_taxonomies' => [ 'category', @@ -246,7 +260,7 @@ public static function provider_check_taxonomy_public_availability() { 'delete_transient_times' => 1, 'schedule_cleanup_times' => 0, ], - 'when taxonomy is removed' => [ + 'when taxonomy is removed' => [ 'is_json_request' => false, 'public_taxonomies' => [ 'category' ], 'get_public_taxonomies_times' => 1, From d6c325af3aa9b253f71476a4acf8e20ff459e187 Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Thu, 13 Jun 2024 16:00:57 +0200 Subject: [PATCH 4/7] Make cron unschedule itself. --- src/integrations/cleanup-integration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/integrations/cleanup-integration.php b/src/integrations/cleanup-integration.php index 653b0039303..e2e7dc29134 100644 --- a/src/integrations/cleanup-integration.php +++ b/src/integrations/cleanup-integration.php @@ -85,6 +85,7 @@ public function run_cleanup() { $this->reset_cleanup(); if ( ! $this->indexable_helper->should_index_indexables() ) { + \wp_unschedule_hook( self::START_HOOK ); return; } From acb699e17441164deb41c6db5cc588a0a8c37d8c Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Wed, 26 Jun 2024 09:35:32 +0200 Subject: [PATCH 5/7] Feedback Igor --- src/integrations/admin/activation-cleanup-integration.php | 4 ++-- src/integrations/watchers/indexable-attachment-watcher.php | 7 +++++-- .../watchers/indexable-author-archive-watcher.php | 7 +++++-- .../Watchers/Indexable_Taxonomy_Change_Watcher_Test.php | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/integrations/admin/activation-cleanup-integration.php b/src/integrations/admin/activation-cleanup-integration.php index 8ca21c54704..b2c19fd41ba 100644 --- a/src/integrations/admin/activation-cleanup-integration.php +++ b/src/integrations/admin/activation-cleanup-integration.php @@ -58,11 +58,11 @@ public function register_hooks() { * @return void */ public function register_cleanup_routine() { - $first_activated_on = $this->options_helper->get( 'first_activated_on', false ); - if ( ! $this->indexable_helper->should_index_indexables() ) { return; } + $first_activated_on = $this->options_helper->get( 'first_activated_on', false ); + if ( ! $first_activated_on || \time() > ( $first_activated_on + ( \MINUTE_IN_SECONDS * 5 ) ) ) { if ( ! \wp_next_scheduled( Cleanup_Integration::START_HOOK ) ) { \wp_schedule_single_event( ( \time() + \DAY_IN_SECONDS ), Cleanup_Integration::START_HOOK ); diff --git a/src/integrations/watchers/indexable-attachment-watcher.php b/src/integrations/watchers/indexable-attachment-watcher.php index 4ad9587ee9e..36cb580b6fe 100644 --- a/src/integrations/watchers/indexable-attachment-watcher.php +++ b/src/integrations/watchers/indexable-attachment-watcher.php @@ -90,9 +90,12 @@ public function register_hooks() { * either it cleans up attachment indexables when it has been toggled to true, * or it starts displaying a notification for the user to start a new SEO optimization. * - * @param array $old_value The old value of the wpseo_titles option. - * @param array $new_value The new value of the wpseo_titles option. + * @phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification * + * @param array $old_value The old value of the wpseo_titles option. + * @param array $new_value The new value of the wpseo_titles option. + * + * @phpcs:enable * @return void */ public function check_option( $old_value, $new_value ) { diff --git a/src/integrations/watchers/indexable-author-archive-watcher.php b/src/integrations/watchers/indexable-author-archive-watcher.php index 83af7c31ecd..7452cc42161 100644 --- a/src/integrations/watchers/indexable-author-archive-watcher.php +++ b/src/integrations/watchers/indexable-author-archive-watcher.php @@ -59,9 +59,12 @@ public static function get_conditionals() { * * When author archives are disabled, they can never be indexed. * - * @param array $old_value The old `wpseo_titles` option value. - * @param array $new_value The new `wpseo_titles` option value. + * @phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification * + * @param array $old_value The old `wpseo_titles` option value. + * @param array $new_value The new `wpseo_titles` option value. + * + * @phpcs:enable * @return void */ public function reschedule_indexable_cleanup_when_author_archives_are_disabled( $old_value, $new_value ) { diff --git a/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php b/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php index fc7d55780d0..e988ef27bbb 100644 --- a/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php +++ b/tests/Unit/Integrations/Watchers/Indexable_Taxonomy_Change_Watcher_Test.php @@ -28,7 +28,7 @@ * @coversDefaultClass \Yoast\WP\SEO\Integrations\Watchers\Indexable_Taxonomy_Change_Watcher * @covers \Yoast\WP\SEO\Integrations\Watchers\Indexable_Taxonomy_Change_Watcher * - * @phpcs :disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded + * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded */ final class Indexable_Taxonomy_Change_Watcher_Test extends TestCase { From 9a709f3eeab2a5c1f10a1fe4ea963abcf29bbc4c Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:44:46 +0200 Subject: [PATCH 6/7] Adapt test to change No longer retrieving the option --- .../Admin/Activation_Cleanup_Integration_Test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php index ca2d565e4c7..d20154f567a 100644 --- a/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php +++ b/tests/Unit/Integrations/Admin/Activation_Cleanup_Integration_Test.php @@ -179,9 +179,7 @@ public function test_register_cleanup_routine_indexables_disabled() { ->andReturnFalse(); $this->options_helper->expects( 'get' ) - ->once() - ->with( 'first_activated_on', false ) - ->andReturn( \time() ); + ->never(); Monkey\Functions\expect( 'wp_next_scheduled' ) ->never() From 12ea35d742f823232da4199086238fbcd26d864f Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:46:51 +0200 Subject: [PATCH 7/7] Update PHPCS threshold --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0611f33b9c1..fa001e48947 100644 --- a/composer.json +++ b/composer.json @@ -91,7 +91,7 @@ "Yoast\\WP\\SEO\\Composer\\Actions::check_coding_standards" ], "check-cs-thresholds": [ - "@putenv YOASTCS_THRESHOLD_ERRORS=2498", + "@putenv YOASTCS_THRESHOLD_ERRORS=2495", "@putenv YOASTCS_THRESHOLD_WARNINGS=253", "Yoast\\WP\\SEO\\Composer\\Actions::check_cs_thresholds" ],