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

Yoast / wordpress-seo / 6892519348

16 Nov 2023 03:00PM UTC coverage: 49.203% (-0.08%) from 49.287%
6892519348

Pull #20470

github

thijsoo
Small fix in using the name of the post type instead of the object.
Pull Request #20470: Introduces indexables verification cron

129 of 283 new or added lines in 25 files covered. (45.58%)

652 existing lines in 2 files now uncovered.

13368 of 27169 relevant lines covered (49.2%)

3.92 hits per line

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

78.95
/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 cron batch handler instance.
31
         *
32
         * @var Verification_Cron_Batch_Handler $cron_batch_handler
33
         */
34
        private $cron_batch_handler;
35

36
        /**
37
         * The verify post indexables command handler.
38
         *
39
         * @var Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler
40
         */
41
        private $verify_post_indexables_command_handler;
42

43
        /**
44
         * The cron verification gate instance.
45
         *
46
         * @var Cron_Verification_Gate
47
         */
48
        private $cron_verification_gate;
49

50
        /**
51
         * The constructor.
52
         *
53
         * @param Cron_Verification_Gate                 $cron_verification_gate                 The cron verification
54
         *                                                                                       gate.
55
         * @param Verification_Cron_Schedule_Handler     $cron_schedule_handler                  The cron schedule handler.
56
         * @param Verification_Cron_Batch_Handler        $cron_batch_handler                     The cron batch handler.
57
         * @param Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler The verify post indexables command handler.
58
         */
59
        public function __construct(
60
                Cron_Verification_Gate $cron_verification_gate,
61
                Verification_Cron_Schedule_Handler $cron_schedule_handler,
62
                Verification_Cron_Batch_Handler $cron_batch_handler,
63
                Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler
64
        ) {
NEW
65
                $this->cron_verification_gate                 = $cron_verification_gate;
×
NEW
66
                $this->cron_schedule_handler                  = $cron_schedule_handler;
×
NEW
67
                $this->cron_batch_handler                     = $cron_batch_handler;
×
NEW
68
                $this->verify_post_indexables_command_handler = $verify_post_indexables_command_handler;
×
69
        }
70

71
        /**
72
         * Registers the hooks with WordPress.
73
         */
74
        public function register_hooks() {
75
                \add_action(
2✔
76
                        Verification_Cron_Schedule_Handler::INDEXABLE_VERIFY_POST_INDEXABLES_NAME,
2✔
77
                        [
1✔
78
                                $this,
2✔
79
                                'start_verify_posts',
2✔
80
                        ]
1✔
81
                );
1✔
82
        }
1✔
83

84
        /**
85
         * Starts the post verification post cron handlers.
86
         *
87
         * @return void
88
         */
89
        public function start_verify_posts(): void {
90
                if ( \wp_doing_cron() && ! $this->cron_verification_gate->should_verify_on_cron() ) {
4✔
91
                        $this->cron_schedule_handler->unschedule_verify_post_indexables_cron();
2✔
92

93
                        return;
2✔
94
                }
95

96
                /**
97
                 * 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.
98
                 *
99
                 * @api int $limit Maximum number of indexables to be indexed per indexing action.
100
                 */
101
                $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✔
102
                $last_batch = $this->cron_batch_handler->get_current_post_indexables_batch();
2✔
103

104
                $this->verify_post_indexables_command_handler->handle( new Verify_Post_Indexables_Command( $batch_size, $last_batch ) );
2✔
105
        }
1✔
106
}
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