WPSEO_Upgrade::reset_permalinks_of_attachments_for_141()privateYoast 1.0

Resets the permalinks of attachments to null in the indexable table for the upgrade routine to 14.1.

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

Хуков нет.

Возвращает

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

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

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

Код WPSEO_Upgrade::reset_permalinks_of_attachments_for_141() Yoast 22.4

private function reset_permalinks_of_attachments_for_141() {
	global $wpdb;

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

	// Reset the permalinks of the attachments in the indexable table.
	// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
	// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
	$wpdb->query(
		$wpdb->prepare(
			"UPDATE %i SET %i = NULL WHERE %i = 'post' AND %i = 'attachment'",
			[ Model::get_table_name( 'Indexable' ),'permalink','object_type','object_sub_type' ]
		)
	);

	$wpdb->show_errors = $show_errors;
}