Important note: FlatPress themes and PHP 8

Ask questions about FlatPress themes, present your themes, request new themes.
Post Reply
User avatar
Arvid
FlatPress Coder
Posts: 211
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Important note: FlatPress themes and PHP 8

Post by Arvid » Fri Jan 01, 2021 1:17 pm

Hi all you theme authors out there,

as you might or might not know, PHP 8 is much less forgiving than prior versions when in comes to uninitialized variables or array indices. This results in ugly warning messages when you run e.g. FlatPress 1.1 under PHP 8.

A very common mistake I fixed a thousand times in the template files of our default theme Leggero is this:
{if $somevariable}
If $somevariable is not initialized yet, this will result in an error like this:
Warning: Undefined array key "somevariable " in ( ... path to the cached file ...)
The solution is simple:
{if isset($somevariable)}


Please check your themes with PHP 8. Don't forget to test not just the frontend, but also the admin area.
Most web hosters have PHP 8 available already. Alternatively, it is super-easy to set up a local web server on your own computer with XAMPP.

See my commits on GitHub around Dec 31 / Jan 01 to learn how I dealt with the described bugs in detail. Ask your open questions here in this topic.

If your theme works fine with PHP 8, please feel free to add a note on the themes page on our wiki, something like: "Tested with PHP 8". And if you find warning messages, please fix your theme and upload a new version of it.

Thank you very much!
All the best,
Arvid

laborix
Posts: 47
Joined: Sat Feb 16, 2019 3:51 pm

Re: Important note: FlatPress themes and PHP 8

Post by laborix » Wed Jan 06, 2021 5:56 pm

Arvid wrote: ↑Fri Jan 01, 2021 1:17 pm... Please check your themes with PHP 8. Don't forget to test not just the frontend, but also the admin area.
Most web hosters have PHP 8 available already. ...
It seems that you only must change two files in your prefered template for using it with Faltpress on PHP 8.
  • /fp-interface/themes/...template.../default.tpl
  • /fp-interface/themes/...template.../cpheader.tpl
I tested on PHP 8 different templates with the current Flatpress Github 549 version. It seems that you really only have to change these two files.

User avatar
Arvid
FlatPress Coder
Posts: 211
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Important note: FlatPress themes and PHP 8

Post by Arvid » Sat Jan 16, 2021 11:18 am

Thanks for your research on this topic!
Let's get the templates PHP 8 ready one after the other.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest