aaemnnosttv / wp-sqlite-db

A single file drop-in for using a SQLite database with WordPress. Based on the original SQLite Integration plugin.
551 stars 93 forks source link

Posts in missed schedule state when host time is not UTC #28

Open DoobleD opened 2 years ago

DoobleD commented 2 years ago

Thank you for this sqlite port!

When the host time is not UTC (for instance Europe/Paris), new posts can't be published. Instead, they're instantly in a missed schedule state.

Changing the WP timezone from Settings > General > Timezone doesn't solve the issue.

DanielRuf commented 2 years ago

How is that related to this sqlite wrapper in general? Sounds more like a general WordPress issue with the system / PHP timezone.

DoobleD commented 2 years ago

Well the issue didn't arise when I tested with MySQL, and with a PostgreSQL plugin, on the same host.

I thought perhaps it could come from the NOW and/or CURDATE emumations. By default SQLite's date function returns time in UTC, whereas it looks like MySQL and PostgreSQL NOW functions return time in the local timezone (respective docs here, here and here).

Just a guess though, I haven't tested further. I instead changed the host timezone to UTC.

johnbillion commented 2 years ago

I know it doesn't address your bug report directly, but you shouldn't change the timezone from UTC on a server running WordPress as it can cause time calculations to be doubled up or cancelled out. Info here: https://github.com/johnbillion/wp-crontrol/wiki/PHP-default-timezone-is-not-set-to-UTC

aaemnnosttv commented 1 year ago

Looks like NOW and CURDATE are implemented to use PHP's date function so they would indeed be subject to whatever the configured timezone is for PHP. If these should always be UTC, that should be straightforward to correct.