Skip to content

Commit

Permalink
Update yoast SEO meta migration to include edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephsekla committed Nov 16, 2021
1 parent fc6e580 commit b2b3a36
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,30 @@ function migrate_wpseo_to_yoast() : void {

// Handle post meta.
$posts_query_args = [
'post_type' => 'any',
// Get all post types, even those with exclude_from_search (so "any" is not appropriate https://core.trac.wordpress.org/ticket/17592).
'post_type' => get_post_types(),
'post_status' => 'any',
'posts_per_page' => 0,
'meta_key' => '_meta_title',
'meta_compare' => 'EXISTS',
'fields' => 'ids',
// Ignore filters that may exclude certain post types from queries.
'suppress_filters' => true,
// phpcs:disable HM.Performance.SlowMetaQuery.dynamic_query -- check required for all of this meta. Performance here isn't a major issue, as this is only run manually on upgrade.
'meta_query' => [
'relation' => 'OR',
[
'meta_key' => '_meta_title',
'meta_compare' => 'EXISTS',
],
[
'meta_key' => '_meta_description',
'meta_compare' => 'EXISTS',
],
[
'meta_key' => '_meta_keywords',
'meta_compare' => 'EXISTS',
],
],
// phpcs:enable HM.Performance.SlowMetaQuery.dynamic_query
];
$posts = new WP_Query( $posts_query_args );

Expand Down

0 comments on commit b2b3a36

Please sign in to comment.