Skip to content

Fix Serde UTC deserialisation and remove column fields from Message::$meta_keys #614

Closed

Description

@jonathanbossenger

Part of #302. Blocks #303 and #307. Related: #372.

What problem does this address?

  • Model\Message::$meta_keys includes expires_at and severity, which are dedicated columns. encode_meta() therefore writes {"date":"…","timezone_type":3,"timezone":"UTC"} into meta and duplicates severity. jsonSerialize() happens to override both afterwards, which is why this hasn't been caught.
  • Serde deserialisation of dates doesn't reliably round-trip as UTC. Every date assertion elsewhere depends on this.
  • channel_title should also leave $meta_keys; otherwise it sneaks back into the meta blob once the column is dropped (Removing the channel title in the messages table #372).

What is your proposed solution?

  • Remove expires_at, severity and channel_title from Message::$meta_keys.
  • Fix Serde so dates deserialise as UTC; add tests/phpunit/tests/test-serde.php covering the round trip.
  • Drop validate_message() if no longer needed.
  • Update test-model-message.php, which pins the exact JSON output.

Activity

  1. added this to the 0.3.0 milestone on Oct 16, 2026
  2. added
    bugSomething isn't working
    [Scope] ModelDefinition of the data used in the WP Notify project
    phpPull requests that update Php code
    on Oct 16, 2026
  3. huzaifaalmesbah commented on Oct 16, 2026

    @huzaifaalmesbah
    Member

    Hi @jonathanbossenger, I'd like to work on this one.

    I've reproduced both parts:

    • Serde::maybe_deserialize_mysql_date() calls DateTime::createFromFormat() without a timezone, so dates are read in the PHP default timezone. WordPress sets that to UTC, but anything that changes it shifts every date. It also accepts dates like 2024-02-30, which PHP silently rolls over to March.
    • Message::$meta_keys includes expires_at, severity and channel_title, so encode_meta() writes them into the meta JSON.

    Plan: read and write dates in UTC explicitly, remove the three keys from $meta_keys while keeping them in jsonSerialize(), drop the unused validate_message(), add tests/phpunit/tests/test-serde.php and update test-model-message.php. I'll open a PR shortly.

  4. added a commit that references this issue on Nov 3, 2026
    ec95a15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Scope] ModelDefinition of the data used in the WP Notify projectbugSomething isn't workinghas-prThe issue has a linked PRphpPull requests that update Php code

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions