-
Notifications
You must be signed in to change notification settings - Fork 11
Ensure that revisions get created when changesets are updated via explicit saves #111
Conversation
js/customize-snapshots.js
Outdated
@@ -1113,6 +1113,7 @@ | |||
isSameStatus = api.state( 'changesetStatus' ).get() === originalOptions.data.customize_changeset_status; | |||
if ( 'customize_save' === originalOptions.data.action && isSameStatus && options.data ) { | |||
options.data = removeParam( options.data, 'customize_changeset_status' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the customize_changeset_status
param getting removed, again? Is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are checking customize_snapshots_create_revision
customize_changeset_status
does not need to be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sayedtaqui but core will (somewhat unintuitively) create a new revision every time the customize_changeset_status
is supplied. Wasn't there a reason for the param to be removed? Did it have something to do with passing the date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter Yes we wanted to auto save the date and title in editbox, but we could not do wp.customize.previewer.save()
without status because the default status is publish
, and we did not want to create revision each time it auto saves the date/title.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so then we need to still include the logic for removing the status parameter, but then an additional change is needed right? We need to omit the request for a revision when the date and title are modified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, thats correct.
I think the code was adding status(revision) to request only when we change status from drop down. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, Unless @sayedtaqui want to change this via using JS only.
@@ -104,6 +104,8 @@ function hooks() { | |||
add_action( 'admin_bar_menu', array( $this, 'remove_all_non_snapshot_admin_bar_links' ), 100000 ); | |||
add_action( 'wp_before_admin_bar_render', array( $this, 'print_admin_bar_styles' ) ); | |||
add_filter( 'removable_query_args', array( $this, 'filter_removable_query_args' ) ); | |||
add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 20, 3 ); | |||
add_filter( 'save_post_customize_changeset', array( $this, 'create_initial_changeset_revision' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter I think save_post_customize_changeset
would be an action and not filter?
https://github.com/WordPress/WordPress/blob/b0bcea2a18f095e2d5b64554782591eacf492c21/wp-includes/post.php#L3494
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! It should be add_action
here.
I think this is a better approach than doing it via just JS. |
I think checking the param
would return true in case of existing changeset which has Looks good 👍 |
@sayedtaqui I'm noticing something else here that is unexpected. If I open the customizer, change a setting, and then save the changeset as a draft; then if I click the edit icon, and then try supplying a title the changed title won't get saved until I try making another change to settings. In other words, it doesn't seem that the title changes are getting sent on Are you able to tie up the lose ends on this ticket, including sending the flag to indicate a revision should be made, as well as ensuring changes to the title cause a title update to be sent? Also, related is #112 where the date fields are being unexpectedly shown. |
Sure working on them. |
…-snapshots into bugfix/create-revisions
@westonruter The title would not get saved if the date is not of future, once user updates the date to be of future, it will start auto-saving, but yes it should be happening only in case of future, which I have updated. Now working on the main issue.. |
@westonruter I wasn't able to finish it today, and I am going on a leave till next Tuesday, so may be @PatelUtkarsh can continue on this PR or I can do it when I come back. 👋 |
1 similar comment
…s in prefilter for editbox auto save.
@westonruter Ready for review. |
@sayedtaqui On 4.6 I'm getting an error if I Save a snapshot, then make a change, and then hit Update. A modal pops open with “The snapshot could not be saved”, with the Ajax request returning with a |
Found a bug with 0.6.0-rc1 whereby revisions were no longer being made as expected when explicitly clicking the Save Draft button in the UI. The opt-in for creating a revision in core is currently indicated by whether or not a
customize_changeset_status
param is present. This is not ideal, but since the param is getting stripped by Customize Snapshots if the status is the same as the current status, I added a workaround for this to explicitly indicate the need to create a revision via another channel. There is probably a better solution for this, not at least to allow asave_revision
to be passed when callingwp.customize.previewer.save()
.See: https://github.com/WordPress/wordpress-develop/blob/8900e2466e3a01c9c228ac31784aa70e8dcf3137/src/wp-includes/class-wp-customize-manager.php#L2279