Skip to content

Commit

Permalink
Merge pull request #17500 from Yoast/P2-1369-revert-prominent-from-free
Browse files Browse the repository at this point in the history
P2 1369 revert prominent from free
  • Loading branch information
increddibelly authored Oct 8, 2021
2 parents 149526e + 5ed7184 commit 16ab7e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 56 deletions.
10 changes: 5 additions & 5 deletions inc/class-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public function __construct() {
'16.2-RC0' => 'upgrade_162',
'16.5-RC0' => 'upgrade_165',
'17.1-RC0' => 'upgrade_171',
'17.2-RC0' => 'retrigger_cleanup',
'17.4-RC0' => 'retrigger_cleanup',
'17.2-RC0' => 'upgrade_172',
];

array_walk( $routines, [ $this, 'run_upgrade_routine' ], $version );
Expand Down Expand Up @@ -833,10 +832,11 @@ private function upgrade_165() {
}

/**
* Schedules a cleanup of the database, cleaning out unused data.
* Performs the 17.2 upgrade. Cleans out any unnecessary indexables. See $cleanup_integration->get_cleanup_tasks() to see what will be cleaned out.
*
* @return void
*/
private function retrigger_cleanup() {
// The hooks that are unscheduled here have since been renamed.
private function upgrade_172() {
\wp_unschedule_hook( 'wpseo_cleanup_orphaned_indexables' );
\wp_unschedule_hook( 'wpseo_cleanup_indexables' );

Expand Down
24 changes: 0 additions & 24 deletions src/integrations/cleanup-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ protected function get_cleanup_tasks() {
'clean_indexables_by_post_status_auto-draft' => function( $limit ) {
return $this->clean_indexables_with_post_status( 'auto-draft', $limit );
},
'clean_old_prominent_word_version_numbers' => function( $limit ) {
return $this->cleanup_old_prominent_word_version_numbers( $limit );
},
],
$this->get_additional_tasks(),
[
Expand Down Expand Up @@ -317,25 +314,4 @@ protected function cleanup_orphaned_from_table( $table, $column, $limit ) {
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: Already prepared.
return $wpdb->query( "DELETE FROM $table WHERE {$column} IN( " . \implode( ',', $orphans ) . ' )' );
}

/**
* Cleans up the old prominent word versions from the postmeta table in the database.
*
* @param int $limit The maximum number of prominent word version numbers to clean in one go.
*
* @return bool|int The number of cleaned up prominent word version numbers, or `false` if the query failed.
*/
protected function cleanup_old_prominent_word_version_numbers( $limit ) {
global $wpdb;

// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
$query = $wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s LIMIT %d",
[ '_yst_prominent_words_version', $limit ]
);
// phpcs:enable

// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: Already prepared.
return $wpdb->query( $query );
}
}
27 changes: 0 additions & 27 deletions tests/unit/integrations/cleanup-integration-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function test_get_conditionals() {
* @covers ::clean_indexables_with_object_type_and_object_sub_type
* @covers ::clean_indexables_with_post_status
* @covers ::cleanup_orphaned_from_table
* @covers ::cleanup_old_prominent_word_version_numbers
* @covers ::get_limit
* @covers ::reset_cleanup
*/
Expand Down Expand Up @@ -111,8 +110,6 @@ public function test_run_cleanup() {
/* Clean up of seo links target ids for deleted indexables */
$this->setup_cleanup_orphaned_from_table_mocks( 50, 'SEO_Links', 'target_indexable_id', $query_limit );

$this->setup_cleanup_old_prominent_words_versions( $query_limit );

$this->instance->run_cleanup();
}

Expand Down Expand Up @@ -358,30 +355,6 @@ public function test_run_cleanup_invalid_query_limit_from_filter() {
$this->instance->run_cleanup_cron();
}

/**
* Sets up the expectations for the cleanup old prominent words versions task.
*
* @param int $limit The query limit.
*
* @return void
*/
private function setup_cleanup_old_prominent_words_versions( $limit ) {
$this->wpdb->postmeta = $this->wpdb->prefix . 'postmeta';

$this->wpdb->expects( 'prepare' )
->with(
'DELETE FROM wp_postmeta WHERE meta_key = %s LIMIT %d',
[ '_yst_prominent_words_version', $limit ]
)
->andReturn(
'DELETE FROM wp_postmeta WHERE meta_key = \'_yst_prominent_words_version\' LIMIT ' . $limit
);

$this->wpdb->expects( 'query' )
->with( 'DELETE FROM wp_postmeta WHERE meta_key = \'_yst_prominent_words_version\' LIMIT ' . $limit )
->andReturn( 3 );
}

/**
* Sets up expectations for the clean_indexables_with_object_type_and_object_sub_type cleanup task.
*
Expand Down

0 comments on commit 16ab7e7

Please sign in to comment.