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

Yoast / wordpress-seo / 3cd34bb9c7b9cedb819c214ddaae5cb49310ce7e

25 Nov 2025 02:37PM UTC coverage: 48.338%. First build
3cd34bb9c7b9cedb819c214ddaae5cb49310ce7e

Pull #22675

github

web-flow
Merge e1e0782a6 into 130f1448f
Pull Request #22675: 804 add caching

0 of 187 new or added lines in 7 files covered. (0.0%)

17512 of 36228 relevant lines covered (48.34%)

3.81 hits per line

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

0.0
/src/schema-aggregator/user-interface/site-schema-aggregator-cache-cli-command.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Schema_Aggregator\User_Interface;
4

5
use WP_CLI;
6
use WP_CLI\ExitException;
7
use Yoast\WP\SEO\Commands\Command_Interface;
8
use Yoast\WP\SEO\Main;
9
use Yoast\WP\SEO\Schema_Aggregator\Application\Cache\Manager;
10
use Yoast\WP\SEO\Schema_Aggregator\Application\Cache\Xml_Manager;
11
use Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Config;
12

13
/**
14
 * Handles the CLI command to represent a site's schema as JSON.
15
 *
16
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
17
 */
18
class Site_Schema_Aggregator_Cache_Cli_Command implements Command_Interface {
19

20
        /**
21
         * The configuration instance.
22
         *
23
         * @var Config
24
         */
25
        private $config;
26

27
        /**
28
         * The The cache manager instance.
29
         *
30
         * @var Manager
31
         */
32
        private $cache_manager;
33

34
        /**
35
         * The XML cache manager instance.
36
         *
37
         * @var Xml_Manager
38
         */
39
        private $xml_manager;
40

41
        /**
42
         * Site_Schema_Aggregator_Cache_Cli_Command constructor.
43
         *
44
         * @param Config      $config        The config object.
45
         * @param Manager     $cache_manager The cache manager.
46
         * @param Xml_Manager $xml_manager   The XML cache manager.
47
         */
NEW
48
        public function __construct( Config $config, Manager $cache_manager, Xml_Manager $xml_manager ) {
×
NEW
49
                $this->config        = $config;
×
NEW
50
                $this->cache_manager = $cache_manager;
×
NEW
51
                $this->xml_manager   = $xml_manager;
×
52
        }
53

54
        /**
55
         * Returns the namespace of this command.
56
         *
57
         * @return string
58
         */
NEW
59
        public static function get_namespace() {
×
NEW
60
                return Main::WP_CLI_NAMESPACE;
×
61
        }
62

63
        /**
64
         * Aggregates the schema for a certain site.
65
         *
66
         * ## OPTIONS
67
         *
68
         * [--page=<page>]
69
         * : The current page to process.
70
         * ---
71
         * ## EXAMPLES
72
         *
73
         *     wp yoast aggregate_site_schema_clear_cache
74
         *
75
         * @when after_wp_load
76
         *
77
         * @param array<string>|null $args       The arguments.
78
         * @param array<string>|null $assoc_args The associative arguments.
79
         *
80
         * @throws ExitException When the input args are invalid.
81
         * @return void
82
         */
NEW
83
        public function aggregate_site_schema_clear_cache( $args = null, $assoc_args = null ) {
×
NEW
84
                if ( isset( $assoc_args['page'] ) && (int) $assoc_args['page'] >= 1 ) {
×
NEW
85
                        $this->cache_manager->invalidate( $assoc_args['page'] );
×
NEW
86
                        $this->xml_manager->invalidate();
×
NEW
87
                        WP_CLI::log(
×
NEW
88
                                \__( 'The site schema cache has been cleared successfully.', 'wordpress-seo' )
×
NEW
89
                        );
×
NEW
90
                        return;
×
91
                }
NEW
92
                $this->cache_manager->invalidate_all();
×
NEW
93
                $this->xml_manager->invalidate();
×
94

NEW
95
                WP_CLI::log(
×
NEW
96
                        \__( 'All site schema cache has been cleared successfully.', 'wordpress-seo' )
×
NEW
97
                );
×
98
        }
99
}
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

© 2026 Coveralls, Inc