Repository navigation
Date/Time: Remove mysql2date() usage from core - #14467
faisalahammad wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
2f42755 to
9ec0bd0
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Replace `mysql2date()` in the comment template tags, feeds, export, `WP::send_headers()`, XML-RPC, Customizer scheduling, autosave checks and signup expiry with `get_post_time()`, `wp_date()`, `get_gmt_from_date()` and `strtotime()`. This also fixes `get_comment_time()` with `$gmt` set to true. It parsed the date in the site timezone, so formats with timezone characters showed the site offset instead of UTC. See #48936.
9ec0bd0 to
13f05b5
Compare
https://core.trac.wordpress.org/ticket/48936
What and why
mysql2date()always parses its input in the site timezone. When it is given a UTC value and a format that prints a timezone, the output shows the site offset instead of UTC. Core already has better tools for each case:get_post_time(),wp_date(),get_gmt_from_date(), and plainstrtotime()for comparisons. This PR replaces the first batch ofmysql2date()calls with those, and fixesget_comment_time()so$gmt = truereads the stored date as UTC.Scope
In scope (first pass):
get_comment_date()andget_comment_time()parse dates directly, the same wayget_post_time()does. With$gmt = true, a format with timezone characters now outputs+00:00instead of the site offset.get_post_time()/get_comment_time().WP::send_headers()buildsLast-Modifiedfrom the raw GMT values withgmdate()._convert_date(),_convert_date_gmt()and theif_not_modified_sincecheck inwp_getPosts.ms-functions.phpusestrtotime().Output from all touched callers is unchanged, except for the
get_comment_time()GMT fix above.Out of scope, for follow-up patches:
upgrade.phpcalls. They treat UTC as local today, and fixing that changes output.deprecated.phpand the bundled themes.mysql2date()itself.Notes for reviewers:
get_post_time/get_comment_timefilters instead of'Y-m-d H:i:s'.feed-rdf.phpnow runs theget_post_timefilter.Testing
New tests, all tagged
@ticket 48936:tests/phpunit/tests/date/getCommentDate.phptests/phpunit/tests/date/xmlrpc.phptests/phpunit/tests/wp/sendHeaders.phpOn trunk, only the GMT time zone test fails. The other new tests pass before and after, which confirms the output did not change.
Manual check:
/feed/,/feed/rdf/and/comments/feed/. ThepubDate/dc:date/updatedvalues should match the GMT columns in the database, and theLast-Modifiedresponse header should be in GMT.pubDatevalues in the file.get_comment_time( 'c', true )should end in+00:00.