Important note: FlatPress themes and PHP 8
Posted: 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:
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
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 is not initialized yet, this will result in an error like this:{if $somevariable}
The solution is simple:Warning: Undefined array key "somevariable " in ( ... path to the cached file ...)
{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