Background
PR #829 fixes a fatal error in the /entries REST endpoint caused by deleted liveblog entries having an empty comment_date_gmt. The fix there is defensive: DateTimeImmutable::createFromFormat() now returns false for empty/malformed dates, and we fall through to mysql2date().
That addresses the symptom, but leaves two open questions worth a follow-up.
Root cause to investigate
- Why is
comment_date_gmt empty on delete entries? A standard WP comment delete workflow shouldn't blank the GMT date. Is this the result of a custom delete path in liveblog, historical data, or something else?
- Should deleted entries be filtered out of the
/entries endpoint earlier? If the endpoint is returning deleted-type comments but downstream code can't meaningfully render them, filtering at the query level might be the right fix.
Related concern
WPCOM_Liveblog_Entry::get_timestamp() (classes/class-wpcom-liveblog-entry.php:170) uses mysql2date( 'G', $this->comment->comment_date_gmt ) directly. It won't fatal error like the /entries path did, but it will silently return false for deleted entries with empty dates. Worth covering this path during the root-cause work.
Also worth deciding
- When
get_comment_date_gmt() can't produce a timestamp, should it return false (current behaviour), 0, or something else? The JSON output at for_json() currently includes 'entry_time' => $this->get_comment_date_gmt( 'U', $entry_id ) which will emit false in this edge case.
Related
Background
PR #829 fixes a fatal error in the
/entriesREST endpoint caused by deleted liveblog entries having an emptycomment_date_gmt. The fix there is defensive:DateTimeImmutable::createFromFormat()now returnsfalsefor empty/malformed dates, and we fall through tomysql2date().That addresses the symptom, but leaves two open questions worth a follow-up.
Root cause to investigate
comment_date_gmtempty on delete entries? A standard WP comment delete workflow shouldn't blank the GMT date. Is this the result of a custom delete path in liveblog, historical data, or something else?/entriesendpoint earlier? If the endpoint is returning deleted-type comments but downstream code can't meaningfully render them, filtering at the query level might be the right fix.Related concern
WPCOM_Liveblog_Entry::get_timestamp()(classes/class-wpcom-liveblog-entry.php:170) usesmysql2date( 'G', $this->comment->comment_date_gmt )directly. It won't fatal error like the/entriespath did, but it will silently returnfalsefor deleted entries with empty dates. Worth covering this path during the root-cause work.Also worth deciding
get_comment_date_gmt()can't produce a timestamp, should it returnfalse(current behaviour),0, or something else? The JSON output atfor_json()currently includes'entry_time' => $this->get_comment_date_gmt( 'U', $entry_id )which will emitfalsein this edge case.Related