• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 6851338203

13 Nov 2023 02:27PM UTC coverage: 49.181% (-0.1%) from 49.287%
6851338203

Pull #20470

github

thijsoo
CS.
Pull Request #20470: Introduces indexables verification cron

125 of 287 new or added lines in 26 files covered. (43.55%)

684 existing lines in 2 files now uncovered.

13364 of 27173 relevant lines covered (49.18%)

3.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/indexables/user-interface/verification-posts-cron-callback-integration.php
1
<?php
2

3
namespace Yoast\WP\SEO\Indexables\User_Interface;
4

5
use Yoast\WP\SEO\Conditionals\Traits\Admin_Conditional_Trait;
6
use Yoast\WP\SEO\Helpers\Options_Helper;
7
use Yoast\WP\SEO\Indexables\Application\Commands\Verify_Post_Indexables_Command;
8
use Yoast\WP\SEO\Indexables\Application\Commands\Verify_Post_Indexables_Command_Handler;
9
use Yoast\WP\SEO\Indexables\Application\Cron_Verification_Gate;
10
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Batch_Handler;
11
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Schedule_Handler;
12
use Yoast\WP\SEO\Integrations\Integration_Interface;
13

14

15
/**
16
 * The Verification_Posts_Cron_Callback_Integration class.
17
 */
18
class Verification_Posts_Cron_Callback_Integration implements Integration_Interface {
19

20
        use Admin_Conditional_Trait;
21

22
        /**
23
         * The verification cron schedule handler instance.
24
         *
25
         * @var Verification_Cron_Schedule_Handler $cron_schedule_handler
26
         */
27
        private $cron_schedule_handler;
28

29
        /**
30
         * The options helper instance.
31
         *
32
         * @var Options_Helper $options_helper
33
         */
34
        private $options_helper;
35

36
        /**
37
         * The cron batch handler instance.
38
         *
39
         * @var Verification_Cron_Batch_Handler $cron_batch_handler
40
         */
41
        private $cron_batch_handler;
42

43
        /**
44
         * The verify post indexables command handler.
45
         *
46
         * @var Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler
47
         */
48
        private $verify_post_indexables_command_handler;
49

50
        /**
51
         * The cron verification gate instance.
52
         *
53
         * @var Cron_Verification_Gate
54
         */
55
        private $cron_verification_gate;
56

57
        /**
58
         * The constructor.
59
         *
60
         * @param Cron_Verification_Gate                 $cron_verification_gate                 The cron verification
61
         *                                                                                       gate.
62
         * @param Verification_Cron_Schedule_Handler     $cron_schedule_handler                  The cron schedule handler.
63
         * @param Options_Helper                         $options_helper                         The options helper.
64
         * @param Verification_Cron_Batch_Handler        $cron_batch_handler                     The cron batch handler.
65
         * @param Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler The verify post indexables command handler.
66
         */
67
        public function __construct(
68
                Cron_Verification_Gate $cron_verification_gate,
69
                Verification_Cron_Schedule_Handler $cron_schedule_handler,
70
                Options_Helper $options_helper,
71
                Verification_Cron_Batch_Handler $cron_batch_handler,
72
                Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler
73
        ) {
NEW
74
                $this->cron_verification_gate                 = $cron_verification_gate;
×
NEW
75
                $this->cron_schedule_handler                  = $cron_schedule_handler;
×
NEW
76
                $this->options_helper                         = $options_helper;
×
NEW
77
                $this->cron_batch_handler                     = $cron_batch_handler;
×
NEW
78
                $this->verify_post_indexables_command_handler = $verify_post_indexables_command_handler;
×
79
        }
80

81
        /**
82
         * Registers the hooks with WordPress.
83
         */
84
        public function register_hooks() {
85
                \add_action(
2✔
86
                        Verification_Cron_Schedule_Handler::INDEXABLE_VERIFY_POST_INDEXABLES_NAME,
2✔
87
                        [
1✔
88
                                $this,
2✔
89
                                'start_verify_posts',
2✔
90
                        ]
1✔
91
                );
1✔
92
        }
1✔
93

94
        /**
95
         * Starts the post verification post cron handlers.
96
         *
97
         * @return void
98
         */
99
        public function start_verify_posts(): void {
100
                if ( \wp_doing_cron() && ! $this->cron_verification_gate->should_verify_on_cron() ) {
4✔
101
                        $this->cron_schedule_handler->unschedule_verify_post_indexables_cron();
2✔
102

103
                        return;
2✔
104
                }
105
                /**
106
                 * Filter: 'Yoast\WP\SEO\post_verify_indexing_limit_size' - Adds the possibility to limit the number of items that are indexed when in cron action.
107
                 *
108
                 * @api int $limit Maximum number of indexables to be indexed per indexing action.
109
                 */
110
                $batch_size = \apply_filters( 'Yoast\WP\SEO\post_verify_indexing_limit_size', 15 ); //@phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- The name needs to be descriptive since it is a very niche use case
2✔
111
                $last_batch = $this->cron_batch_handler->get_current_post_indexables_batch();
2✔
112

113
                $this->verify_post_indexables_command_handler->handle( new Verify_Post_Indexables_Command( $batch_size, $last_batch ) );
2✔
114
        }
1✔
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc