<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[39410] branches/4.7: Customize: Reject a changeset update when a non-future date is provided and also ensure that a published changeset always gets set to the current date/time.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/39410">39410</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/39410","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-12-02 00:06:59 +0000 (Fri, 02 Dec 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Customize: Reject a changeset update when a non-future date is provided and also ensure that a published changeset always gets set to the current date/time.
* Also moves checks from `customize_save` Ajax handler to the underlying `WP_Customize_Manager::save_changeset_post()` call which plugins may invoke directly.
* Ensures that `customize_save_response` filter is always passed an array, with error code available as `code`.
Props utkarshpatel, westonruter, sayedwp.
Merges <a href="https://core.trac.wordpress.org/changeset/39409">[39409]</a> into 4.7 branch.
See <a href="https://core.trac.wordpress.org/ticket/30937">#30937</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/38943">#38943</a> for 4.7.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches47srcwpincludesclasswpcustomizemanagerphp">branches/4.7/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#branches47testsphpunittestsajaxCustomizeManagerphp">branches/4.7/tests/phpunit/tests/ajax/CustomizeManager.php</a></li>
<li><a href="#branches47testsphpunittestscustomizemanagerphp">branches/4.7/tests/phpunit/tests/customize/manager.php</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches47">branches/4.7/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/4.7
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/4.7 2016-12-02 00:01:51 UTC (rev 39409)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/4.7 2016-12-02 00:06:59 UTC (rev 39410)
</ins><a id="branches47"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/4.7</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.1:18031
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.3:20543
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:18512,39365,39369,39371,39373,39375-39376,39378,39380,39382,39384,39386,39388,39390,39392-39393,39396-39397,39400,39402,39404,39406
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:18512,39365,39369,39371,39373,39375-39376,39378,39380,39382,39384,39386,39388,39390,39392-39393,39396-39397,39400,39402,39404,39406,39409
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches47srcwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/src/wp-includes/class-wp-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/src/wp-includes/class-wp-customize-manager.php 2016-12-02 00:01:51 UTC (rev 39409)
+++ branches/4.7/src/wp-includes/class-wp-customize-manager.php 2016-12-02 00:06:59 UTC (rev 39410)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1961,10 +1961,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $changeset_post_id = $this->changeset_post_id();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $changeset_post_id && in_array( get_post_status( $changeset_post_id ), array( 'publish', 'trash' ) ) ) {
- wp_send_json_error( 'changeset_already_published' );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $changeset_post_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->create_posts ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'cannot_create_changeset_post' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1999,13 +1995,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'bad_customize_changeset_status', 400 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $is_publish = ( 'publish' === $changeset_status || 'future' === $changeset_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $is_publish ) {
- if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) {
- wp_send_json_error( 'changeset_publish_unauthorized', 403 );
- }
- if ( false === has_action( 'transition_post_status', '_wp_customize_publish_changeset' ) ) {
- wp_send_json_error( 'missing_publish_callback', 500 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $is_publish && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) {
+ wp_send_json_error( 'changeset_publish_unauthorized', 403 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2034,20 +2025,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $changeset_date_gmt = gmdate( 'Y-m-d H:i:s', $timestamp );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $now = gmdate( 'Y-m-d H:i:59' );
-
- $is_future_dated = ( mysql2date( 'U', $changeset_date_gmt, false ) > mysql2date( 'U', $now, false ) );
- if ( ! $is_future_dated ) {
- wp_send_json_error( 'not_future_date', 400 ); // Only future dates are allowed.
- }
-
- if ( ! $this->is_theme_active() && ( 'future' === $changeset_status || $is_future_dated ) ) {
- wp_send_json_error( 'cannot_schedule_theme_switches', 400 ); // This should be allowed in the future, when theme is a regular setting.
- }
- $will_remain_auto_draft = ( ! $changeset_status && ( ! $changeset_post_id || 'auto-draft' === get_post_status( $changeset_post_id ) ) );
- if ( $changeset_date && $will_remain_auto_draft ) {
- wp_send_json_error( 'cannot_supply_date_for_auto_draft_changeset', 400 );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $r = $this->save_changeset_post( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2057,7 +2034,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'data' => $input_changeset_data,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $r ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = $r->get_error_data();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = array(
+ 'message' => $r->get_error_message(),
+ 'code' => $r->get_error_code(),
+ );
+ if ( is_array( $r->get_error_data() ) ) {
+ $response = array_merge( $response, $r->get_error_data() );
+ } else {
+ $response['data'] = $r->get_error_data();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $r;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2132,9 +2117,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $changeset_post_id = $this->changeset_post_id();
</span><span class="cx" style="display: block; padding: 0 10px"> $existing_changeset_data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $changeset_post_id ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $existing_status = get_post_status( $changeset_post_id );
+ if ( 'publish' === $existing_status || 'trash' === $existing_status ) {
+ return new WP_Error( 'changeset_already_published' );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $existing_changeset_data = $this->get_changeset_post_data( $changeset_post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Fail if attempting to publish but publish hook is missing.
+ if ( 'publish' === $args['status'] && false === has_action( 'transition_post_status', '_wp_customize_publish_changeset' ) ) {
+ return new WP_Error( 'missing_publish_callback' );
+ }
+
+ // Validate date.
+ $now = gmdate( 'Y-m-d H:i:59' );
+ if ( $args['date_gmt'] ) {
+ $is_future_dated = ( mysql2date( 'U', $args['date_gmt'], false ) > mysql2date( 'U', $now, false ) );
+ if ( ! $is_future_dated ) {
+ return new WP_Error( 'not_future_date' ); // Only future dates are allowed.
+ }
+
+ if ( ! $this->is_theme_active() && ( 'future' === $args['status'] || $is_future_dated ) ) {
+ return new WP_Error( 'cannot_schedule_theme_switches' ); // This should be allowed in the future, when theme is a regular setting.
+ }
+ $will_remain_auto_draft = ( ! $args['status'] && ( ! $changeset_post_id || 'auto-draft' === get_post_status( $changeset_post_id ) ) );
+ if ( $will_remain_auto_draft ) {
+ return new WP_Error( 'cannot_supply_date_for_auto_draft_changeset' );
+ }
+ } elseif ( $changeset_post_id && 'future' === $args['status'] ) {
+
+ // Fail if the new status is future but the existing post's date is not in the future.
+ $changeset_post = get_post( $changeset_post_id );
+ if ( mysql2date( 'U', $changeset_post->post_date_gmt, false ) <= mysql2date( 'U', $now, false ) ) {
+ return new WP_Error( 'not_future_date' );
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // The request was made via wp.customize.previewer.save().
</span><span class="cx" style="display: block; padding: 0 10px"> $update_transactionally = (bool) $args['status'];
</span><span class="cx" style="display: block; padding: 0 10px"> $allow_revision = (bool) $args['status'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2347,7 +2366,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $args['status'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_array['post_status'] = $args['status'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $args['date_gmt'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Reset post date to now if we are publishing, otherwise pass post_date_gmt and translate for post_date.
+ if ( 'publish' === $args['status'] ) {
+ $post_array['post_date_gmt'] = '0000-00-00 00:00:00';
+ $post_array['post_date'] = '0000-00-00 00:00:00';
+ } elseif ( $args['date_gmt'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_array['post_date_gmt'] = $args['date_gmt'];
</span><span class="cx" style="display: block; padding: 0 10px"> $post_array['post_date'] = get_date_from_gmt( $args['date_gmt'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="branches47testsphpunittestsajaxCustomizeManagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/tests/phpunit/tests/ajax/CustomizeManager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/phpunit/tests/ajax/CustomizeManager.php 2016-12-02 00:01:51 UTC (rev 39409)
+++ branches/4.7/tests/phpunit/tests/ajax/CustomizeManager.php 2016-12-02 00:06:59 UTC (rev 39410)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -164,7 +164,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_customize->save_changeset_post( array( 'status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_ajax_call( 'customize_save' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 'changeset_already_published', $this->_last_response_parsed['data'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 'changeset_already_published', $this->_last_response_parsed['data']['code'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_update_post( array( 'ID' => $wp_customize->changeset_post_id(), 'post_status' => 'auto-draft' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // User cannot edit.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,7 +213,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['customize_changeset_date'] = '2010-01-01 00:00:00';
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_ajax_call( 'customize_save' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 'not_future_date', $this->_last_response_parsed['data'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 'not_future_date', $this->_last_response_parsed['data']['code'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['customize_changeset_date'] = ( gmdate( 'Y' ) + 1 ) . '-01-01 00:00:00';
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_ajax_call( 'customize_save' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $this->_last_response_parsed['success'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,4 +307,80 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'New Site Title', get_option( 'blogname' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Published', get_post( $post_id )->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Test WP_Customize_Manager::save().
+ *
+ * @ticket 38943
+ * @covers WP_Customize_Manager::save()
+ */
+ function test_success_save_post_date() {
+ $uuid = wp_generate_uuid4();
+ $post_id = $this->factory()->post->create( array(
+ 'post_name' => $uuid,
+ 'post_title' => 'Original',
+ 'post_type' => 'customize_changeset',
+ 'post_status' => 'auto-draft',
+ 'post_content' => wp_json_encode( array(
+ 'blogname' => array(
+ 'value' => 'New Site Title',
+ ),
+ ) ),
+ ) );
+ $wp_customize = $this->set_up_valid_state( $uuid );
+
+ // Success future schedule date.
+ $future_date = ( gmdate( 'Y' ) + 1 ) . '-01-01 00:00:00';
+ $_POST['customize_changeset_status'] = 'future';
+ $_POST['customize_changeset_title'] = 'Future date';
+ $_POST['customize_changeset_date'] = $future_date;
+ $this->make_ajax_call( 'customize_save' );
+ $this->assertTrue( $this->_last_response_parsed['success'] );
+ $changeset_post_schedule = get_post( $post_id );
+ $this->assertEquals( $future_date, $changeset_post_schedule->post_date );
+
+ // Success future changeset change to draft keeping existing date.
+ unset( $_POST['customize_changeset_date'] );
+ $_POST['customize_changeset_status'] = 'draft';
+ $this->make_ajax_call( 'customize_save' );
+ $this->assertTrue( $this->_last_response_parsed['success'] );
+ $changeset_post_draft = get_post( $post_id );
+ $this->assertEquals( $future_date, $changeset_post_draft->post_date );
+
+ // Success if date is not passed with schedule changeset and stored changeset have future date.
+ $_POST['customize_changeset_status'] = 'future';
+ $this->make_ajax_call( 'customize_save' );
+ $this->assertTrue( $this->_last_response_parsed['success'] );
+ $changeset_post_schedule = get_post( $post_id );
+ $this->assertEquals( $future_date, $changeset_post_schedule->post_date );
+ // Success if draft with past date.
+ $now = current_time( 'mysql' );
+ wp_update_post( array(
+ 'ID' => $post_id,
+ 'post_status' => 'draft',
+ 'post_date' => $now,
+ 'post_date_gmt' => get_gmt_from_date( $now ),
+ ) );
+
+ // Fail if future request and existing date is past.
+ $_POST['customize_changeset_status'] = 'future';
+ unset( $_POST['customize_changeset_date'] );
+ $this->make_ajax_call( 'customize_save' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'not_future_date', $this->_last_response_parsed['data']['code'] );
+
+ // Success publish changeset reset date to current.
+ wp_update_post( array(
+ 'ID' => $post_id,
+ 'post_status' => 'future',
+ 'post_date' => $future_date,
+ 'post_date_gmt' => get_gmt_from_date( $future_date ),
+ ) );
+ unset( $_POST['customize_changeset_date'] );
+ $_POST['customize_changeset_status'] = 'publish';
+ $this->make_ajax_call( 'customize_save' );
+ $this->assertTrue( $this->_last_response_parsed['success'] );
+ $changeset_post_publish = get_post( $post_id );
+ $this->assertNotEquals( $future_date, $changeset_post_publish->post_date );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="branches47testsphpunittestscustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/tests/phpunit/tests/customize/manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/phpunit/tests/customize/manager.php 2016-12-02 00:01:51 UTC (rev 39409)
+++ branches/4.7/tests/phpunit/tests/customize/manager.php 2016-12-02 00:06:59 UTC (rev 39410)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -627,10 +627,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'custom' => 'something',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $date = ( gmdate( 'Y' ) + 1 ) . '-12-01 00:00:00';
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = $manager->save_changeset_post( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'status' => 'auto-draft',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'Auto Draft',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'date_gmt' => '2010-01-01 00:00:00',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'date_gmt' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'data' => $pre_saved_data,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'array', $r );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -651,7 +652,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Auto Draft', get_post( $post_id )->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'auto-draft', get_post( $post_id )->post_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( '2010-01-01 00:00:00', get_post( $post_id )->post_date_gmt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $date, get_post( $post_id )->post_date_gmt );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEquals( 'Changeset Title', get_option( 'blogname' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'setting_validities', $r );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>