WC_Product_CSV_Importer_Controller::release_stranded_cleanup_claims
Release temporary products a cleanup request claimed but did not live to delete.
A fatal inside the delete lifecycle leaves the claimed status behind, and the importer only recognises a placeholder by the status it was created with, so the CSV row owning that SKU would be skipped as an existing product. Healing at the start of a run keeps that contained.
Method of the class: WC_Product_CSV_Importer_Controller{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Product_CSV_Importer_Controller::release_stranded_cleanup_claims(): void;
WC_Product_CSV_Importer_Controller::release_stranded_cleanup_claims() WC Product CSV Importer Controller::release stranded cleanup claims code WC 11.2.1
private static function release_stranded_cleanup_claims(): void {
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$post_ids = $wpdb->get_col(
$wpdb->prepare(
"SELECT ID FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = %s",
self::CLEANUP_CLAIMED_STATUS
)
);
if ( ! $post_ids ) {
return;
}
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->posts} SET post_status = %s WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = %s",
self::CLEANUP_PLACEHOLDER_STATUS,
self::CLEANUP_CLAIMED_STATUS
)
);
wp_cache_delete_multiple( array_map( 'absint', $post_ids ), 'posts' );
}