WPSEO_Upgrade::clean_unindexed_indexable_rows_with_no_object_id()protectedYoast 1.0

Cleans up "unindexed" indexable rows when appropriate, aka when there's no object ID even though it should.

Метод класса: WPSEO_Upgrade{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->clean_unindexed_indexable_rows_with_no_object_id();

Код WPSEO_Upgrade::clean_unindexed_indexable_rows_with_no_object_id() Yoast 22.4

protected function clean_unindexed_indexable_rows_with_no_object_id() {
	global $wpdb;

	// If migrations haven't been completed successfully the following may give false errors. So suppress them.
	$show_errors       = $wpdb->show_errors;
	$wpdb->show_errors = false;

	// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
	// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
	$wpdb->query(
		$wpdb->prepare(
			"DELETE FROM %i
			WHERE %i = 'unindexed'
			AND %i NOT IN ( 'home-page', 'date-archive', 'post-type-archive', 'system-page' )
			AND %i IS NULL",
			[ Model::get_table_name( 'Indexable' ),'post_status','object_type','object_id' ]
		)
	);

	$wpdb->show_errors = $show_errors;
}