Skip to content

Investigate why deleted liveblog entries have empty comment_date_gmt #859

@GaryJones

Description

@GaryJones

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

  1. 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?
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions