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

Yoast / wordpress-seo / 121d6055c956360fb867d8ed620c843ef16874b1

09 Dec 2025 02:53PM UTC coverage: 51.87%. Remained the same
121d6055c956360fb867d8ed620c843ef16874b1

push

github

web-flow
Merge pull request #22786 from Yoast/schema_aggregator/fix-cache

Add post type to cache layer.

8327 of 15641 branches covered (53.24%)

Branch coverage included in aggregate %.

0 of 15 new or added lines in 5 files covered. (0.0%)

1 existing line in 1 file now uncovered.

31846 of 61809 relevant lines covered (51.52%)

46650.28 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
         */
48
        public function __construct( Config $config, Manager $cache_manager, Xml_Manager $xml_manager ) {
×
49
                $this->config        = $config;
×
50
                $this->cache_manager = $cache_manager;
×
51
                $this->xml_manager   = $xml_manager;
×
52
        }
53

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

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

UNCOV
93
                        return;
×
94
                }
95
                $this->cache_manager->invalidate_all();
×
96
                $this->xml_manager->invalidate();
×
97

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