Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateSyncBackfill::fetch_eligible_posts
Fetch every woo_email post that has not yet been stamped with a source hash.
The NOT EXISTS clause is what makes the callback retry-safe: posts stamped by RSM-137 (new installs) or by a previous invocation of this migration are filtered out, so an Action Scheduler retry converges on exactly the posts that still need work.
Method of the class: WCEmailTemplateSyncBackfill{}
No Hooks.
Returns
\stdClass[]. Rows with ID, post_content, post_date_gmt, post_modified_gmt.
Usage
$result = WCEmailTemplateSyncBackfill::fetch_eligible_posts(): array;
WCEmailTemplateSyncBackfill::fetch_eligible_posts() WCEmailTemplateSyncBackfill::fetch eligible posts code WC 10.8.1
private static function fetch_eligible_posts(): array {
global $wpdb;
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT ID, post_content, post_date, post_modified, post_date_gmt, post_modified_gmt
FROM {$wpdb->posts}
WHERE post_type = %s
AND post_status <> 'trash'
AND NOT EXISTS (
SELECT 1 FROM {$wpdb->postmeta} pm
WHERE pm.post_id = {$wpdb->posts}.ID
AND pm.meta_key = %s
)
ORDER BY ID ASC",
Integration::EMAIL_POST_TYPE,
WCEmailTemplateDivergenceDetector::SOURCE_HASH_META_KEY
)
);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
return is_array( $rows ) ? $rows : array();
}