Page 1 of 1

Important note: FlatPress themes and PHP 8

Posted: Fri Jan 01, 2021 1:17 pm
by Arvid
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

Re: Important note: FlatPress themes and PHP 8

Posted: Wed Jan 06, 2021 5:56 pm
by laborix
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.

Re: Important note: FlatPress themes and PHP 8

Posted: Sat Jan 16, 2021 11:18 am
by Arvid
Thanks for your research on this topic!
Let's get the templates PHP 8 ready one after the other.