XF 2.1 Site broken after clearning code_cache/templates manually

sajal

Active member
I have removed this code_cache/templates directory manually... and now I get blank page on front-end and admin...??
 
Try going to <your site>/install which should redirect to the upgrade page, continue and once done templates should be recompiled. I have tried this on local development board for fun and it seems to have worked or at least looks like it.

You should generally avoid touching any XF file or directory manually, unless you know what you're doing.
 
I made my custom theme on the top of third party UIX.2 theme, would that preserve changes to my custom theme?
The directory code_cache is compiled version of phrases, styles and so on. The changes you made are saved in database so, yes they should be preserved. But like always, take a backup.
 
This!!
You should generally avoid touching any XF file or directory manually, unless you know what you're doing.

Also, even if you think you know what you are doing, take a full backup before touching anything. That way you can always get back to where you were before screwing up.
 
Yeah @ozzy47, you are right, but the name of the directory is bit of misleading here I would say, "code_cache", if you can not generate it from somewhere, why I would name it like "*cache"?

So I believe there must be something we could use to "regenerate" this stuff for sure.
 
There is a CLI command to rebuild that as well php /<path to xf>/html/cmd.php xf:rebuild-master-data but this requires development mode to be enabled.

Edit 2: Corrected the command.
 
@sajal
php cmd.php xf-dev:recompile-phrases && php cmd.php xf-dev:recompile-templates

Unless you know exactly what you are doing (which is not that case, otherwise you would not ask such questions; and even if you do there is usually no need to go into code_cache unless you are digging really, really deep while debugging smth.) keep your fingers off code_cache.

This is not a "cache" like your browser cache wich can be safely emptied and rebuilts itself, it is a vital part of the application code!
 
Last edited:
Agree with you @ozzy47!

Many thanks @TickTackk and @Kirby for pointing out those commands. Luckily I just deleted only "code_cache/templates" directory only. And I was able to restore my templates back with that command.

Sure, I will never touch this "code_cache" now :)!

In fact, let me know why I deleted that whole directory:

I have created a new "Page" from the back-end, and trying to edit it was not reflecting on frontend. While, trying to editing the stored version of it "admin.php?templates/_page_node-10053.2263/edit&style_id=10" was working. So I was just trying to clear these caches....
 
Back
Top Bottom