Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
diedexx committed Nov 16, 2021
1 parent 38b552d commit 2fdce2f
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 90 deletions.
10 changes: 7 additions & 3 deletions lib/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public function set_orm( $orm ) {
*/
public function __get( $property ) {
$property = $this->handleDeprecation( $property );
$value = $this->orm->get( $property );
$value = $this->orm->get( $property );

if ( $value !== null && \in_array( $property, $this->boolean_columns, true ) ) {
return (bool) $value;
Expand Down Expand Up @@ -748,7 +748,11 @@ protected function handleDeprecation( $property ) {

if ( ! empty( $deprecation['replacement'] ) ) {
// There is no _deprecated_property. This matches our usecase best.
_deprecated_argument( __FUNCTION__, '17.7', 'Use the \"' . $deprecation['replacement'] . '\" property instead of \"' . $property . '\" ' );
_deprecated_argument(
__FUNCTION__,
'17.7',
'Use the \"' . esc_html( $deprecation['replacement'] ) . '\" property instead of \"' . esc_html( $property ) . '\" '
);

if ( $deprecation['automatically_use_replacement'] === true ) {
return $deprecation['replacement'];
Expand All @@ -757,7 +761,7 @@ protected function handleDeprecation( $property ) {
return $property;
}
// There is no _deprecated_property. This matches our usecase best.
_deprecated_argument( __FUNCTION__, '17.7', 'The \"' . $property . '\" property will be removed in a future version' );
_deprecated_argument( __FUNCTION__, '17.7', 'The \"' . esc_html( $property ) . '\" property will be removed in a future version' );

return $property;
}
Expand Down
17 changes: 11 additions & 6 deletions src/builders/indexable-author-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ public function build( $user_id, Indexable $indexable ) {
return $indexable;
}

/**
* Sets the aggregate values for an author indexable.
*
* @param Indexable $indexable The indexable to set the aggregates for.
*
* @return Indexable The indexable with set aggregates.
*/
public function set_aggregate_values( Indexable $indexable ) {
$aggregates = $this->get_public_post_archive_aggregates( $indexable->object_id );
$indexable->object_published_at = $aggregates->first_published_at;
Expand Down Expand Up @@ -183,20 +190,18 @@ protected function find_alternative_image( Indexable $indexable ) {
protected function get_public_post_archive_aggregates( $author_id ) {
$post_statuses = $this->post_helper->get_public_post_statuses();
$post_types = $this->author_archive->get_author_archive_post_types();
// TODO DIEDE: Protected pages krijgen _geen_ noindex. en staan gewoon in het author archive. moeten die meegeteld worden?
// Private werkt wel zoals verwacht.

$sql = "
SELECT
COUNT(p.ID) as number_of_public_posts,
MAX(p.post_modified_gmt) AS most_recent_last_modified,
MIN(p.post_date_gmt) AS first_published_at
FROM {$this->wpdb->posts} AS p
WHERE p.post_status IN (" . implode( ', ', array_fill( 0, count( $post_statuses ), '%s' ) ) . ")
AND p.post_password = ''
WHERE p.post_status IN (" . implode( ', ', array_fill( 0, count( $post_statuses ), '%s' ) ) . ')
AND p.post_password = \'\'
AND p.post_author = %d
AND p.post_type IN (" . implode( ', ', array_fill( 0, count( $post_types ), '%s' ) ) . ")
";
AND p.post_type IN (' . implode( ', ', array_fill( 0, count( $post_types ), '%s' ) ) . ')
';

$replacements = \array_merge( $post_statuses, [ $author_id ], $post_types );

Expand Down
7 changes: 7 additions & 0 deletions src/builders/indexable-home-page-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public function build( $indexable ) {
return $indexable;
}

/**
* Sets the aggregate values for a home page indexable.
*
* @param Indexable $indexable The indexable to set the aggregates for.
*
* @return Indexable The indexable with set aggregates.
*/
public function set_aggregate_values( Indexable $indexable ) {
$aggregates = $this->get_public_post_archive_aggregates();
$indexable->object_published_at = $aggregates->first_published_at;
Expand Down
2 changes: 2 additions & 0 deletions src/builders/indexable-post-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ protected function get_permalink( $post_type, $post_id ) {
*
* @return bool|null Whether the post type is public. Null if no override is set.
*
* @codeCoverageIgnore
* @deprecated 17.7
*/
protected function is_public( $indexable ) {
Expand Down Expand Up @@ -219,6 +220,7 @@ protected function is_public( $indexable ) {
*
* @return bool|null False when it has no parent. Null when it has a parent.
*
* @codeCoverageIgnore
* @deprecated 17.7
*/
protected function is_public_attachment( $indexable ) {
Expand Down
7 changes: 7 additions & 0 deletions src/builders/indexable-post-type-archive-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public function build( $post_type, Indexable $indexable ) {
return $indexable;
}

/**
* Sets the aggregate values for a post type archive indexable.
*
* @param Indexable $indexable The indexable to set the aggregates for.
*
* @return Indexable The indexable with set aggregates.
*/
public function set_aggregate_values( Indexable $indexable ) {
$aggregates = $this->get_public_post_archive_aggregates( $indexable->object_sub_type );
$indexable->object_published_at = $aggregates->first_published_at;
Expand Down
7 changes: 7 additions & 0 deletions src/builders/indexable-term-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ public function build( $term_id, $indexable ) {
return $indexable;
}

/**
* Sets the aggregate values for a term indexable.
*
* @param Indexable $indexable The indexable to set the aggregates for.
*
* @return Indexable The indexable with set aggregates.
*/
public function set_aggregate_values( Indexable $indexable ) {
$aggregates = $this->get_public_post_archive_aggregates( $indexable->object_id, $indexable->object_sub_type );
$indexable->object_published_at = $aggregates->first_published_at;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\WP\SEO\Config\Migrations
*/

namespace Yoast\WP\SEO\Config\Migrations;

Expand Down Expand Up @@ -40,7 +35,6 @@ public function up() {
'number_of_publicly_viewable_posts',
'integer'
);

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\WP\SEO\Config\Migrations
*/

namespace Yoast\WP\SEO\Config\Migrations;

Expand Down Expand Up @@ -37,7 +32,8 @@ public function up() {
[
'null' => true,
'default' => null,
] );
]
);
}

/**
Expand All @@ -51,11 +47,10 @@ public function down() {

$this->remove_column(
$table_name,
'is_publicly_viewable',
'is_publicly_viewable'
);
}


/**
* Retrieves the table name to use.
*
Expand Down
23 changes: 3 additions & 20 deletions src/helpers/author-archive-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@
*/
class Author_Archive_Helper {

/**
* @var Indexable_Repository
*/
private $indexable_repository;

/**
* Sets the indexable repository. Done to avoid circular dependencies.
*
* @required
*
* @param Indexable_Repository $indexable_repository
*
* @return void
*/
public function setIndexableRepository( Indexable_Repository $indexable_repository ) {
$this->indexable_repository = $indexable_repository;
}

/**
* Gets the array of post types that are shown on an author's archive.
*
Expand All @@ -49,10 +31,11 @@ public function get_author_archive_post_types() {
*
* @return bool|null Whether the author has at least one public post.
*
* @codeCoverageIgnore
* @deprecated 17.7
*/
public function author_has_public_posts( $author_id ) {
_deprecated_function( __METHOD__, '17.7',Indexable_Repository::class.'::noindex_query');
_deprecated_function( __METHOD__, '17.7', esc_html( Indexable_Repository::class ) . '::noindex_query' );
// First check if the author has at least one public post.
$has_public_post = $this->author_has_a_public_post( $author_id );
if ( $has_public_post ) {
Expand Down Expand Up @@ -110,7 +93,7 @@ protected function author_has_a_public_post( $author_id ) {
*
* @return bool Whether the author has at least one post with the is public null.
*
* @deprecated 17.7
* @deprecated 17.7
*/
protected function author_has_a_post_with_is_public_null( $author_id ) {
$cache_key = 'author_has_a_post_with_is_public_null_' . $author_id;
Expand Down
6 changes: 5 additions & 1 deletion src/helpers/post-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct( String_Helper $string ) {
*
* @return void
*/
public function setIndexableBuilder( Indexable_Builder $indexable_builder ) {
public function set_indexable_builder( Indexable_Builder $indexable_builder ) {
$this->indexable_builder = $indexable_builder;
}

Expand Down Expand Up @@ -135,6 +135,8 @@ public function get_post( $post_id ) {
return \get_post( $post_id );
}

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Signature kept the same after deprecation.

/**
* Updates the number_of_publicly_viewable_posts field on attachments for a post_parent.
*
Expand All @@ -159,6 +161,8 @@ public function update_has_public_posts_on_attachments( $post_parent, $has_publi
return true;
}

// phpcs:enable

/**
* Determines if the post can be indexed.
*
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/robots-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
class Robots_Helper {

/**
* A helper to get and set plugin options.
*
* @var Options_Helper
*/
private $options_helper;

/**
* @param Options_Helper $options_helper The indexable version manager.
* Robots_Helper constructor.
*
* @param Options_Helper $options_helper A helper to get and set plugin options.
*/
public function __construct( Options_Helper $options_helper ) {
$this->options_helper = $options_helper;
Expand Down Expand Up @@ -45,7 +49,7 @@ public function set_robots_no_index( $robots ) {
*
* @return bool Whether the site default is set to noindex for the requested object type.
*/
public function get_default_noindex_for_object( $object_type, $object_sub_type = "" ) {
public function get_default_noindex_for_object( $object_type, $object_sub_type = '' ) {
switch ( $object_type ) {
case 'post':
return (bool) $this->options_helper->get( 'noindex-' . $object_sub_type );
Expand Down
1 change: 0 additions & 1 deletion src/integrations/watchers/indexable-post-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ protected function get_related_term_indexables( $post_id ) {
return $this->repository->find_by_multiple_ids_and_type( $term_ids, 'term', false );
}


/**
* Tests if the site is multisite and switched.
*
Expand Down
5 changes: 5 additions & 0 deletions src/models/indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ class Indexable extends Model {
'number_of_publicly_viewable_posts',
];

/**
* Which columns are deprecated.
*
* @var array
*/
protected $deprecated_columns = [
'has_public_posts' => [
'since' => '17.7',
Expand Down
Loading

0 comments on commit 2fdce2f

Please sign in to comment.