Skip to content

Commit

Permalink
Fixed the sitemap query to disregard trashed posts. (#8238)
Browse files Browse the repository at this point in the history
  • Loading branch information
zinigor authored and jeherve committed Nov 24, 2017
1 parent 828774e commit e546b19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion class.jetpack-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,13 +1059,14 @@ public function partner_provision( $args, $named_args ) {
* ## OPTIONS
*
* rebuild : Rebuild all sitemaps
* --purge : if set, will remove all existing sitemap data before rebuilding
*
* ## EXAMPLES
*
* wp jetpack sitemap rebuild
*
* @subcommand sitemap
* @synopsis <rebuild>
* @synopsis <rebuild> [--purge]
*/
public function sitemap( $args, $assoc_args ) {
if ( ! Jetpack::is_active() ) {
Expand All @@ -1078,6 +1079,11 @@ public function sitemap( $args, $assoc_args ) {
WP_CLI::error( __( 'Jetpack Sitemaps module is active, but unavailable. This can happen if your site is set to discourage search engine indexing. Please enable search engine indexing to allow sitemap generation.', 'jetpack' ) );
}

if ( isset( $assoc_args['purge'] ) && $assoc_args['purge'] ) {
$librarian = new Jetpack_Sitemap_Librarian();
$librarian->delete_all_stored_sitemap_data();
}

$sitemap_builder = new Jetpack_Sitemap_Builder();
$sitemap_builder->update_sitemap();
}
Expand Down
2 changes: 2 additions & 0 deletions modules/sitemaps/sitemap-librarian.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ public function query_sitemaps_after_id( $type, $from_id, $num_posts ) {
"SELECT *
FROM $wpdb->posts
WHERE post_type=%s
AND post_status=%s
AND ID>%d
ORDER BY ID ASC
LIMIT %d;",
$type,
'draft',
$from_id,
$num_posts
),
Expand Down

0 comments on commit e546b19

Please sign in to comment.