Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#41144 closed defect (bug) (invalid)

Previewing static front page drops custom page template

Reported by: jbchristy's profile JBChristy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Editor Keywords:
Focuses: Cc:

Description

We have a static front page, and that page uses a custom page template. When we're editing the page that is the static front page, and we click the Preview Changes button, the custom page template disappears, and the front page's page template is reset to Default Template. This completely screws up the rendering of our homepage.

For some reason, this change is immediately stored to the database. So the instant we preview the front page, visitors to our site start seeing a malformed homepage.

  • Previewing the homepage should not change it's page template.
  • Previewing any page should not change the page in the database.

Change History (5)

#1 @JBChristy
6 years ago

Our earlier tests today led us to believe that previewing the page dropping the page template only happened on the static front page. However, a user just came to me with an issue, and we discovered that the same thing had happened on an interior page.

Also, on my local dev environment, the issue happens ~80% of the time, i.e. it's not 100% reproducible.

#2 @johnbillion
6 years ago

  • Keywords reporter-feedback added

Welcome to WordPress Trac, @JBChristy. Sorry to hear you're having problems.

Are you able to reproduce this problem with all of your plugins deactivated and one of the default themes (such as Twenty Seventeen) enabled? It could be that something else on your site is interfering.

#3 @JBChristy
6 years ago

  • Keywords reporter-feedback removed

Hi @johnbillion.

Twenty Seventeen doesn't have any custom page templates. The issue involves deleting a custom page template, so it can't be reproduced with a theme doesn't have any.

Our site is www.stanford.edu. I really can't switch themes on that site anyway, and our custom theme requires that certain plugins be enabled. I wrote the custom theme, and I know it does not interact with Preview in any way. It's mostly just defining custom post types and providing a few custom endpoints. However, one of our required plugins, licensed from a third party, does have it's own "Live Preview" functionality built in React. I will reach out to the vendor and see if they can find any interaction between their preview functionality and WP core's. It's hard to imagine, tho, that their functionality would trigger a write to the DB. But it's certainly possible, and I'll work with them to try to narrow down the interaction, if any.

I know what a colossal job to test a zillion bug reports from a zillion random users running in customized environments, and of course you need us in the community to do due diligence to narrow down the issue to WP core. And I will try to do so. But if you're aware of any other issues re custom page templates and / or live preview, maybe you could add this issue to the testbed for those issues?

Thanks for your thoughtful attention.

-JB

#4 @JBChristy
6 years ago

  • Keywords close added
  • Resolution set to invalid
  • Status changed from new to closed

You are correct. The issue appears to be with our 3rd party plugin. I created a vanilla WordPress 4.8 site using TwentySeventeen. I created a trivial custom page template, and assigned it to the homepage (which is the default Sample Page). I was unable to reproduce the problem, no matter how many times I tried to edit and preview the page.

I then installed and activated our 3rd party plugin. Once an autosave was created for my user for the homepage, I was able to reproduce the problem 100% of the time. I deactivated that plugin, and was again unable to reproduce the problem.

I see that that plugin has a wp_creating_autosave hook that copies the parent page's page template to the autosave. Although I've spent hours in the debugger, I cannot seem to find where or when the parent page's page template gets reset, but it seems to always happen after that hook fires, and never happen when the plugin is disabled.

Anyway, I see that this is not an issue with WP core, so I'm marking this ticket resolve as: invalid.

#5 @netweb
6 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.