Weird error when removing page templates

Hi,

I removed a page template from the resource folder and ever since I see an error when editing a page. It says that the page template I deleted is missing.

It all happened after I noticed my new templates were not being added to the page template list when editing a page. While trying to figure out why they weren’t showing up I saw there was a file test.php in the resources folder. I made this file to store some code temporarily. As I didn’t need it anymore I decided to delete it. That was the moment when the error appeared for the first time when editing a page, saying test.php in resources was missing.

So after a while the error seemed to disappear, I’m not sure what made it go away. Afik I didn’t change any settings. I then noticed there was another test template file in my views folder and decided to remove that one as well. Then the error (I linked earlier) appeared and again there are no new templates being added tot the template list when editing a page.

There are no page’s using the removed templates whatsoever, I double checked them by explicitly saving them to existing page templates. I’m amazed by seeing this error because in my understanding it just scans the views folder for templates and if you remove templates they are simply not picked up by the system. However it seems they are being stored in some sort of cache.

Has anyone experienced this before or has any idea how I could solve this error? Also good to mention perhaps, I also updated to Wordpress 4.9

Thanks,

Nick

There’s a Blade cache in uploads/cache that stores the compiled Blade templates - you could try emptying that folder to see if it fixes it.

You could also try a full text search through your code and see if there are any references to that file anywhere. If that still doesn’t solve it, maybe there’s a reference in the database…

There are no files containing the name of the template file. In the database I found a reference to the file. I found it in the export of the database I just made as I thought that would be the fastest way to search for it.

However the weird part is that the error just disappeared, so I exported the database again and now I couldn’t find any reference anymore. So there is some sort of process checking the file templates periodically I guess. That might also explain why new file templates are not showing up (because that is still the case). It seems it needs to get scanned/cached first or something. I’ll keep trying to figure out what’s going on here.

So the reference I found in the database was from the wp_options table stored as a transient record. Transients appear to function as some sort of result cache so that Wordpress won’t have to run specific queries over and over again. After a quick search and backing up the database I removed the record that had the name of the removed page template in it, and now the error is gone.

It seems transients have an expiry date which might indicate why the error “solved” it self as described in my previous posts. However I’m still left with uncertainty on how to gain more control over these transients. Because my new page templates won’t appear immediately as it seems I have to wait for a new transient to be set/created.

1 Like