rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -9,13 +9,15 @@ use Yoast\WP\SEO\Analytics\Domain\Missing_Indexable_Count;
/**
* Manages the collection of the missing indexable data.
*
* @makePublic
*/
class Missing_Indexables_Collector implements WPSEO_Collection {
/**
* All the indexation actions.
*
* @var array<Indexation_Action_Interface> $indexation_actions
* @var array<Indexation_Action_Interface>
*/
private $indexation_actions;
@@ -34,10 +36,10 @@ class Missing_Indexables_Collector implements WPSEO_Collection {
*
* @return array The list of missing indexables.
*/
public function get(): array {
public function get() {
$missing_indexable_bucket = new Missing_Indexable_Bucket();
foreach ( $this->indexation_actions as $indexation_action ) {
$missing_indexable_count = new Missing_Indexable_Count( get_class( $indexation_action ), $indexation_action->get_total_unindexed() );
$missing_indexable_count = new Missing_Indexable_Count( \get_class( $indexation_action ), $indexation_action->get_total_unindexed() );
$missing_indexable_bucket->add_missing_indexable_count( $missing_indexable_count );
}
@@ -49,7 +51,7 @@ class Missing_Indexables_Collector implements WPSEO_Collection {
*
* @return void
*/
private function add_additional_indexing_actions(): void {
private function add_additional_indexing_actions() {
/**
* Filter: Adds the possibility to add additional indexation actions to be included in the count routine.
*

View File

@@ -9,6 +9,8 @@ use Yoast\WP\SEO\Repositories\Indexable_Cleanup_Repository;
/**
* Collects data about to-be-cleaned indexables.
*
* @makePublic
*/
class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
@@ -31,7 +33,7 @@ class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
/**
* Gets the data for the collector.
*/
public function get(): array {
public function get() {
$to_be_cleaned_indexable_bucket = new To_Be_Cleaned_Indexable_Bucket();
$cleanup_tasks = [
'indexables_with_post_object_type_and_shop_order_object_sub_type' => $this->indexable_cleanup_repository->count_indexables_with_object_type_and_object_sub_type( 'post', 'shop_order' ),
@@ -41,7 +43,7 @@ class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
'indexables_for_non_publicly_viewable_post_type_archive_pages' => $this->indexable_cleanup_repository->count_indexables_for_non_publicly_post_type_archive_pages(),
'indexables_for_authors_archive_disabled' => $this->indexable_cleanup_repository->count_indexables_for_authors_archive_disabled(),
'indexables_for_authors_without_archive' => $this->indexable_cleanup_repository->count_indexables_for_authors_without_archive(),
'indexables_for_object_type_and_source_table_users' => $this->indexable_cleanup_repository->count_indexables_for_object_type_and_source_table( 'users', 'ID', 'user' ),
'indexables_for_object_type_and_source_table_users' => $this->indexable_cleanup_repository->count_indexables_for_orphaned_users(),
'indexables_for_object_type_and_source_table_posts' => $this->indexable_cleanup_repository->count_indexables_for_object_type_and_source_table( 'posts', 'ID', 'post' ),
'indexables_for_object_type_and_source_table_terms' => $this->indexable_cleanup_repository->count_indexables_for_object_type_and_source_table( 'terms', 'term_id', 'term' ),
'orphaned_from_table_indexable_hierarchy' => $this->indexable_cleanup_repository->count_orphaned_from_table( 'Indexable_Hierarchy', 'indexable_id' ),
@@ -50,8 +52,10 @@ class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
];
foreach ( $cleanup_tasks as $name => $count ) {
$count_object = new To_Be_Cleaned_Indexable_Count( $name, $count );
$to_be_cleaned_indexable_bucket->add_to_be_cleaned_indexable_count( $count_object );
if ( $count !== null ) {
$count_object = new To_Be_Cleaned_Indexable_Count( $name, $count );
$to_be_cleaned_indexable_bucket->add_to_be_cleaned_indexable_count( $count_object );
}
}
$this->add_additional_counts( $to_be_cleaned_indexable_bucket );
@@ -66,7 +70,7 @@ class To_Be_Cleaned_Indexables_Collector implements WPSEO_Collection {
*
* @return void
*/
private function add_additional_counts( To_Be_Cleaned_Indexable_Bucket $to_be_cleaned_indexable_bucket ): void {
private function add_additional_counts( $to_be_cleaned_indexable_bucket ) {
/**
* Action: Adds the possibility to add additional to be cleaned objects.
*

View File

@@ -10,7 +10,7 @@ class Missing_Indexable_Bucket {
/**
* All the missing indexable count objects.
*
* @var array<Missing_Indexable_Count> $missing_indexable_counts
* @var array<Missing_Indexable_Count>
*/
private $missing_indexable_counts;
@@ -37,14 +37,12 @@ class Missing_Indexable_Bucket {
*
* @return array
*/
public function to_array(): array {
public function to_array() {
return \array_map(
function ( $item ) {
static function ( $item ) {
return $item->to_array();
},
$this->missing_indexable_counts
);
}
}

View File

@@ -10,14 +10,14 @@ class Missing_Indexable_Count {
/**
* The indexable type that is represented by this.
*
* @var string $indexable_type
* @var string
*/
private $indexable_type;
/**
* The amount of missing indexables.
*
* @var int $count
* @var int
*/
private $count;
@@ -27,7 +27,7 @@ class Missing_Indexable_Count {
* @param string $indexable_type The indexable type that is represented by this.
* @param int $count The amount of missing indexables.
*/
public function __construct( string $indexable_type, int $count ) {
public function __construct( $indexable_type, $count ) {
$this->indexable_type = $indexable_type;
$this->count = $count;
}
@@ -37,7 +37,7 @@ class Missing_Indexable_Count {
*
* @return array Returns both values in an array format.
*/
public function to_array(): array {
public function to_array() {
return [
'indexable_type' => $this->get_indexable_type(),
'count' => $this->get_count(),
@@ -49,7 +49,7 @@ class Missing_Indexable_Count {
*
* @return string Returns the indexable type.
*/
public function get_indexable_type(): string {
public function get_indexable_type() {
return $this->indexable_type;
}
@@ -58,7 +58,7 @@ class Missing_Indexable_Count {
*
* @return int Returns the amount of missing indexables.
*/
public function get_count(): int {
public function get_count() {
return $this->count;
}
}

View File

@@ -10,7 +10,7 @@ class To_Be_Cleaned_Indexable_Bucket {
/**
* All the to be cleaned indexable count objects.
*
* @var array<To_Be_Cleaned_Indexable_Count> $to_be_cleaned_indexable_counts
* @var array<To_Be_Cleaned_Indexable_Count>
*/
private $to_be_cleaned_indexable_counts;
@@ -28,7 +28,7 @@ class To_Be_Cleaned_Indexable_Bucket {
*
* @return void
*/
public function add_to_be_cleaned_indexable_count( To_Be_Cleaned_Indexable_Count $to_be_cleaned_indexable_counts ): void {
public function add_to_be_cleaned_indexable_count( To_Be_Cleaned_Indexable_Count $to_be_cleaned_indexable_counts ) {
$this->to_be_cleaned_indexable_counts[] = $to_be_cleaned_indexable_counts;
}
@@ -37,14 +37,12 @@ class To_Be_Cleaned_Indexable_Bucket {
*
* @return array
*/
public function to_array(): array {
public function to_array() {
return \array_map(
function ( $item ) {
static function ( $item ) {
return $item->to_array();
},
$this->to_be_cleaned_indexable_counts
);
}
}

View File

@@ -10,14 +10,14 @@ class To_Be_Cleaned_Indexable_Count {
/**
* The cleanup task that is represented by this.
*
* @var string $cleanup_name
* @var string
*/
private $cleanup_name;
/**
* The amount of missing indexables.
*
* @var int $count
* @var int
*/
private $count;
@@ -25,9 +25,9 @@ class To_Be_Cleaned_Indexable_Count {
* The constructor.
*
* @param string $cleanup_name The indexable type that is represented by this.
* @param int $count The amount of missing indexables.
* @param int $count The amount of missing indexables.
*/
public function __construct( string $cleanup_name, int $count ) {
public function __construct( $cleanup_name, $count ) {
$this->cleanup_name = $cleanup_name;
$this->count = $count;
}
@@ -37,7 +37,7 @@ class To_Be_Cleaned_Indexable_Count {
*
* @return array Returns both values in an array format.
*/
public function to_array(): array {
public function to_array() {
return [
'cleanup_name' => $this->get_cleanup_name(),
'count' => $this->get_count(),
@@ -49,7 +49,7 @@ class To_Be_Cleaned_Indexable_Count {
*
* @return string
*/
public function get_cleanup_name(): string {
public function get_cleanup_name() {
return $this->cleanup_name;
}
@@ -58,7 +58,7 @@ class To_Be_Cleaned_Indexable_Count {
*
* @return int Returns the amount of missing indexables.
*/
public function get_count(): int {
public function get_count() {
return $this->count;
}
}

View File

@@ -2,9 +2,9 @@
namespace Yoast\WP\SEO\Analytics\User_Interface;
use Yoast\WP\SEO\Integrations\Integration_Interface;
use Yoast\WP\SEO\Conditionals\No_Conditionals;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Integrations\Integration_Interface;
/**
* Handles setting a timestamp when the indexation of a specific indexation action is completed.
@@ -16,7 +16,7 @@ class Last_Completed_Indexation_Integration implements Integration_Interface {
/**
* The options helper.
*
* @var Options_Helper $options_helper The options helper.
* @var Options_Helper The options helper.
*/
private $options_helper;
@@ -50,7 +50,7 @@ class Last_Completed_Indexation_Integration implements Integration_Interface {
* Saves a timestamp option when there are no unindexed indexables.
*
* @param string $indexable_name The name of the indexable that is being checked.
* @param int $count The amount of missing indexables.
* @param int $count The amount of missing indexables.
*
* @return void
*/