Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateSyncBackfill::was_never_edited
Decide whether a row represents a post that has never been edited since creation, using the timestamp pair available.
Returns true when either the GMT pair or the local pair compare equal. The OR makes the classifier resilient to legacy insert paths that left one pair blank or sentinel-valued, which is the common case we've observed in the wild.
Known limitation: when both pairs independently compare equal for reasons unrelated to edit state (e.g. both _gmt columns are the '0000-00-00 00:00:00' sentinel and the local pair happens to match), the function can report "never edited" for a post that has in fact been edited, which would cause Case B to rewrite the merchant's content. We accept that trade-off because the population of rows where every timestamp pair is simultaneously corrupt is effectively empty in practice; the simpler predicate is worth the theoretical exposure.
Method of the class: WCEmailTemplateSyncBackfill{}
No Hooks.
Returns
true|false. True if at least one timestamp pair matches.
Usage
$result = WCEmailTemplateSyncBackfill::was_never_edited( $row ): bool;
- $row(stdClass) (required)
- Row with post_date, post_modified, post_date_gmt, post_modified_gmt.
WCEmailTemplateSyncBackfill::was_never_edited() WCEmailTemplateSyncBackfill::was never edited code WC 10.8.1
private static function was_never_edited( \stdClass $row ): bool {
$post_date_gmt = (string) ( $row->post_date_gmt ?? '' );
$post_modified_gmt = (string) ( $row->post_modified_gmt ?? '' );
$post_date = (string) ( $row->post_date ?? '' );
$post_modified = (string) ( $row->post_modified ?? '' );
return $post_date_gmt === $post_modified_gmt || $post_date === $post_modified;
}