-
-
Notifications
You must be signed in to change notification settings - Fork 513
Page Preview should not return a revision post #1752
Description
Expected behavior
Within the WP editor, when clicking the Preview Changes button (or the Previewbutton if post is in draft status), the preview should render the modified published or draft post.
(Wordpress previews work by modifying the edited posts' content with the autosaved revision posts' content. The post object's post_type remains as post instead of revision. See the _set_preview() function in WP core.)
Actual behavior
Timber, as of 1.7.1 with these commits (c119c16 and e34a702) now returns a post object whose post_type is revision instead of the expected post. Noticeable implications of this arise in particular with post.class in a twig file. Wordpress's get_post_class() function adds CSS classes based on several conditionals that fail for posts with post_type revision. So styling based on these classes will not appear when previewing a post. This is related to #1728 and possibly has other impacts on previewing posts.
Steps to reproduce behavior
Trace the post_type in preview. In a vanilla Wordpress install with the 2017 theme, the post_type is post. Add Timber, the same preview returns a post with post_type of revision.
What version of WordPress, PHP and Timber are you using?
Wordpress 4.9.7, PHP 5.6 and Timber 1.7.1. I've also replicated the issue running Timber 2.x-dev.
Reverting to 1.7.0 fixes the issue. Or in 2.x-dev, commenting out line 304 also resolves it.
I'm not sure I understand why the change was made to return a revision post object so I can't say if reverting this change would re-introduce other issues.
How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)
Composer.