• 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

73.91
/src/indexables/user-interface/verification-no-timestamp-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_Non_Timestamp_Indexables_Command;
8
use Yoast\WP\SEO\Indexables\Application\Commands\Verify_Non_Timestamp_Indexables_Command_Handler;
9
use Yoast\WP\SEO\Indexables\Application\Cron_Verification_Gate;
10
use Yoast\WP\SEO\Indexables\Application\Next_Verification_Action_Handler;
11
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Batch_Handler;
12
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Schedule_Handler;
13
use Yoast\WP\SEO\Integrations\Integration_Interface;
14

15
/**
16
 * The Verification_Cron_Callback_Integration class.
17
 *
18
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
19
 */
20
class Verification_No_Timestamp_Cron_Callback_Integration implements Integration_Interface {
21

22
        use Admin_Conditional_Trait;
23

24
        /**
25
         * The cron scheduler handler instance.
26
         *
27
         * @var Verification_Cron_Schedule_Handler
28
         */
29
        protected $cron_schedule_handler;
30

31
        /**
32
         * The options helper instance.
33
         *
34
         * @var Options_Helper
35
         */
36
        protected $options_helper;
37

38
        /**
39
         * The verification cron batch handler.
40
         *
41
         * @var Verification_Cron_Batch_Handler
42
         */
43
        protected $cron_batch_handler;
44

45
        /**
46
         * The non timestamp command handler.
47
         *
48
         * @var Verify_Non_Timestamp_Indexables_Command_Handler
49
         */
50
        protected $non_timestamp_indexables_command_handler;
51

52
        /**
53
         * The next verification action handler instance.
54
         *
55
         * @var Next_Verification_Action_Handler
56
         */
57
        protected $verification_action_handler;
58

59
        /**
60
         * The cron verification gate instance.
61
         *
62
         * @var Cron_Verification_Gate
63
         */
64
        private $cron_verification_gate;
65

66
        /**
67
         * The constructor.
68
         *
69
         * @param Cron_Verification_Gate                          $cron_verification_gate                   The cron
70
         *                                                                                                  verification
71
         *                                                                                                  gate.
72
         * @param Verification_Cron_Schedule_Handler              $cron_schedule_handler                    The cron
73
         *                                                                                                  schedule
74
         *                                                                                                  handler.
75
         * @param Options_Helper                                  $options_helper                           The options
76
         *                                                                                                  helper.
77
         * @param Verification_Cron_Batch_Handler                 $cron_batch_handler                       The cron batch
78
         *                                                                                                  handler.
79
         * @param Verify_Non_Timestamp_Indexables_Command_Handler $non_timestamp_indexables_command_handler The non
80
         *                                                                                                  timestamp
81
         *                                                                                                  indexables
82
         *                                                                                                  command
83
         *                                                                                                  handler.
84
         * @param Next_Verification_Action_Handler                $verification_action_handler              The
85
         *                                                                                                  verification
86
         *                                                                                                  action handler.
87
         */
88
        public function __construct(
89
                Cron_Verification_Gate $cron_verification_gate,
90
                Verification_Cron_Schedule_Handler $cron_schedule_handler,
91
                Options_Helper $options_helper,
92
                Verification_Cron_Batch_Handler $cron_batch_handler,
93
                Verify_Non_Timestamp_Indexables_Command_Handler $non_timestamp_indexables_command_handler,
94
                Next_Verification_Action_Handler $verification_action_handler
95
        ) {
NEW
96
                $this->cron_verification_gate                   = $cron_verification_gate;
×
NEW
97
                $this->cron_schedule_handler                    = $cron_schedule_handler;
×
NEW
98
                $this->options_helper                           = $options_helper;
×
NEW
99
                $this->cron_batch_handler                       = $cron_batch_handler;
×
NEW
100
                $this->non_timestamp_indexables_command_handler = $non_timestamp_indexables_command_handler;
×
NEW
101
                $this->verification_action_handler              = $verification_action_handler;
×
102
        }
103

104
        /**
105
         * Registers the hooks with WordPress.
106
         */
107
        public function register_hooks() {
108
                \add_action(
2✔
109
                        Verification_Cron_Schedule_Handler::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME,
2✔
110
                        [
1✔
111
                                $this,
2✔
112
                                'start_verify_non_timestamped_indexables',
2✔
113
                        ]
1✔
114
                );
1✔
115
        }
1✔
116

117
        /**
118
         * Start the non timestamp cron handler callback.
119
         *
120
         * @return void
121
         */
122
        public function start_verify_non_timestamped_indexables() {
123
                if ( \wp_doing_cron() && ! $this->cron_verification_gate->should_verify_on_cron() ) {
4✔
124
                        $this->cron_schedule_handler->unschedule_verify_non_timestamped_indexables_cron();
2✔
125

126
                        return;
2✔
127
                }
128

129
                /**
130
                 * Filter: 'Yoast\WP\SEO\no_timestamped_indexable_verify_limit_size' - Adds the possibility to limit the number of items that are indexed when in cron action.
131
                 *
132
                 * @api int $limit Maximum number of indexables to be indexed per indexing action.
133
                 */
134
                $batch_size    = \apply_filters( 'Yoast\WP\SEO\no_timestamped_indexable_verify_limit_size', 15 ); //@phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- The name needs to be descriptive since it is a very niche use case
2✔
135
                $current_batch = $this->cron_batch_handler->get_current_non_timestamped_indexables_batch();
2✔
136
                $action        = $this->verification_action_handler->get_current_verification_action();
2✔
137
                $command       = new Verify_Non_Timestamp_Indexables_Command( $current_batch, $batch_size, $action );
2✔
138

139
                $this->non_timestamp_indexables_command_handler->handle( $command );
2✔
140
        }
1✔
141
}
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