[wp-trac] [WordPress Trac] #36738: No validation for $post_date_gmt parameter
WordPress Trac
noreply at wordpress.org
Fri Sep 12 12:00:00 UTC 2025
#36738: No validation for $post_date_gmt parameter
-------------------------------------------------+-------------------------
Reporter: Latz | Owner:
| paulbonneau
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future
| Release
Component: Posts, Post Types | Version: 3.5
Severity: normal | Resolution:
Keywords: has-test-info good-first-bug has- | Focuses:
patch has-unit-tests |
-------------------------------------------------+-------------------------
Comment (by pmbaldha):
== Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/9705/
❌ This report indicates that the patch is not working as expected.
=== Steps to Reproduce or Test
1. Add wp-content/mu-plugins/test.php file with the following code:
{{{#!php
<?php
add_action('init', function() {
if ( isset( $_GET['test'] ) && 1 == $_GET['test'] ) {
$post = wp_insert_post( array(
'post_title' => 'Test post',
'post_type' => 'post',
'post_status' => 'publish',
'post_date_gmt' => 'invalid_date',
) );
var_dump( $post );
die;
}
});
}}}
2. 🐞 Go to [YOUR_SITE_URL]/wp-admin/edit.php and you will see the Tes
post with the 1970/01/01 at 12:00 am date as shown in the screenshot.
=== Expected Results
When testing a patch to validate it works as expected:
- ✅ The post should not be inserted and should return WP_Error object.
When reproducing a bug:
- 🐞 The post with the invalid post_date_gmt argument is inserted and show
the wrong date 1970/01/01 at 12:00 am.
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 140.0.0.0
- OS: Windows 10/11
- Theme: Twenty Seventeen 3.9
- MU Plugins:
* test.php
- Plugins:
* Email Log 2.61
* Test Reports 1.2.0
==== Actual Results
When reproducing a bug/defect:
- 🐞 The post with the invalid post_date_gmt argument is inserted and
show the wrong date 1970/01/01 at 12:00 am.
When testing the bugfix patch:
- ❌ Issue has not resolved with patch. The post with the invalid
post_date_gmt argument is returning 0, instead of WP_Error object.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36738#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list