PHP 8.1.0 with some issues

This is the right place to report general bugs, make suggestions or ask for help.
User avatar
stippi
Posts: 9
Joined: Wed Dec 15, 2021 1:18 pm
Location: 48.06271, 8.53402
Contact:

PHP 8.1.0 with some issues

Post by stippi » Wed Dec 15, 2021 3:37 pm

Hi everyone,

As I was forced to upgrade my PHP version by my hosting service provider, because of end of support, I upgraded to the most recent available version 8.1.0. After that all seemed to be gone and only an error message was shown on the website. So I also updated to the most recent release of FP 1.2.1. I fixed it so far, that I could see and login to my page. Some of the error messages I could solve on my own, by editing some of the affected .php files mainly in fp-includes/core/core.date.php. I 'googled' the messages and could find some hints on fixing the 'bugs'. Now some if the error messages are very odd to me, as I do no programming at all. I also deleted all the theme and template cache in the admin section and also renewed the index as it was recommended if something goes wrong. At least some error messages keep showing on my blog https://sophtwearteam.de/.

Now, what can I do to fix the last 'bugs' in my installation?
Any help appreciated a lot. Thank you in advance.
stippi

User avatar
stippi
Posts: 9
Joined: Wed Dec 15, 2021 1:18 pm
Location: 48.06271, 8.53402
Contact:

Re: PHP 8.1.0 with some issues

Post by stippi » Sat Dec 18, 2021 5:47 am

Here are some additional details about what I did so far. I changed the core.date.php as follows:
- 5 function date_strformat($format, $timestamp=0) {
+ 5 $date = DateTimeImmutable::createFromFormat('U', time()); {

- 10 if ( strpos($format, '%a') !== false ) {
- 11 $i = strftime('%w', $timestamp);
- 12 $format = str_replace('%a', $lang['date']['weekday_abbr'][$i], $format);
+ 10 if ( strpos('%U', '%a') !== false ) {
+ 11 $i = $date('%w', time());
+ 12 $date = str_replace('%a', $lang['date']['weekday_abbr'][$i], $date);

- 15 if ( strpos($format, '%A') !== false ) {
- 16 $i = strftime('%w', $timestamp);
- 17 $format = str_replace('%A', $lang['date']['weekday'][$i], $format);
+ 15 if ( strpos('%U', '%A') !== false ) {
+ 16 $i = $date('%w', time());
+ 17 $date = str_replace('%A', $lang['date']['weekday'][$i], $date);

- 23 if ( strpos($format, '%b') !== false ) {
- 24 $i = intval(strftime('%m', $timestamp))-1;
- 25 $format = str_replace('%b', $lang['date']['month_abbr'][$i], $format);
+ 23 if ( strpos('%U', '%b') !== false ) {
+ 24 $i = intval($date('%m', time()))-1;
+ 25 $date = str_replace('%b', $lang['date']['month_abbr'][$i], $date);

- 29 if ( strpos($format, '%B') !== false ) {
- 30 $i = intval(strftime('%m', $timestamp))-1;
- 31 $format = str_replace('%B', $lang['date']['month'][$i], $format);
+ 29 if ( strpos('%U', '%B') !== false ) {
+ 30 $i = intval(date('%m', time()))-1;
+ 31 $date = str_replace('%B', $lang['date']['month'][$i], $date);

- 37 if (strpos($format, '%e') !== false) {
+ 37 if (strpos($date, '%e') !== false) {

- 39 $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
+ 39 $_win_to[] = sprintf('%\' 2d', date('j', time()));

- 41 if (strpos($format, '%l') !== false) {
+ 41 if (strpos($date, '%l') !== false) {

- 43 $_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
+ 43 $_win_to[] = sprintf('%\' 2d', date('h', time()));

- 45 $format = str_replace($_win_from, $_win_to, $format);
+ 45 $date = str_replace($_win_from, $_win_to, $date);

- 48 return strftime($format, $timestamp);
+ 48 return date('%F', time());

- 58 $timestamp = time();
- 59 return $timestamp + $offset * 3600;
+ 58 $date = time();
+ 59 return time() + $offset * 3600;

- 65 $timestamp = gmtime();
- 66 $time_stamp = intval($timestamp) + intval($offset) * 60 * 60;
- 67 return date($format, $time_stamp);
+ 65 time() = gmtime();
+ 66 $time_stamp = intval(time()) + intval($offset) * 60 * 60;
+ 67 return date($date, $time_stamp);
============
Unless these changes haven't been made, the page couldn't be displayed and a single-line error message appeared.
Now I have these error messages showing on my blog:
Startpage / Header:
===================
Warning: Undefined array key "entry" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%F7^F7F^F7F34188%%header.tpl.php on line 15

Startpage / Title:
==================
Warning: Undefined array key "entry" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%F7^F7F^F7F34188%%header.tpl.php on line 65

Warning: Undefined array key "cat" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%F7^F7F^F7F34188%%header.tpl.php on line 70

Warning: Undefined array key "y" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%F7^F7F^F7F34188%%header.tpl.php on line 74

Below every entry:
==================
Warning: Undefined array key "entry" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%3A^3A5^3A581D6D%%entry-default.tpl.php on line 74

Top of control centre | start:
==============================
../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%CE^CE4^CE42039A%%cpheader.tpl.php on line 33
admin-main-">

Top of control centre | themes:
===============================
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in ../htdocs/admin/panels/themes/admin.themes.php on line 44

Line 44: $theme_uri = trim( @$theme_uri[2] );

Logoff / logon Screen (Control Centre)
======================================
Warning: Undefined array key "rawcontent" in ../htdocs/fp-content/cache/4203aee83c498e73b28dcdbf80894c04^%%3A^3A6^3A66F9CF%%default.tpl.php on line 23

====== E N D ============

As I mentioned before: I have emptied the cache from the control centre's menu as most of the messages imply something wrong in the cache. The pages are displayed as they was in the past plus the error messages above. So the source of the error messages could be another .php file e. g. admin.themes.php, but I didn't find any solution to the entry in line 44 on the net, or I can not (not able to) follow the abstracts. Plus I assume other deprecated functions and variables left in some of the PHP-code.

If someone can lead me to the point it will be a very welcome help.

Regards
stippi

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

Re: PHP 8.1.0 with some issues

Post by Arvid » Sat Dec 18, 2021 11:22 am

stippi, welcome to the FlatPress support forum! :)

Thanks for reporting this problem. The strftime() function FlatPress makes use of many times has been declared deprecated with PHP 8.1. This is a bigger issue since e.g. all date format configs in FlatPress rely on the old strftime format (with the % escape character); the recommended replacement date() works differently (no % in the format strings).

I've opened an issue for this one.

The obvious workaround for you is to switch to PHP 8.0 where strftime() isn't deprecated yet. But we'll have to fix FlatPress in order to make it run under 8.1, of course.
Can you please send me your changed files via email?

As for the cache errors, have you tried to rebuild the caches (Admin area -> Maintain -> Purge theme and templates cache)?

All the best und viele Grüße aus dem Ruhrpott..
..Arvid

User avatar
stippi
Posts: 9
Joined: Wed Dec 15, 2021 1:18 pm
Location: 48.06271, 8.53402
Contact:

Re: PHP 8.1.0 with some issues

Post by stippi » Sat Dec 18, 2021 2:10 pm

Hi Arvid,

Yes, I tried to rebuild the caches. Maybe I wasn't clear enough in my explanations before. Sorry for that.
As I had no other mail address I replied to the notification e-mail (hello@flatpress.org), sorry as well for that.

regards from the black forest :lol:
stippi

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

Re: PHP 8.1.0 with some issues

Post by laborix » Sun Dec 19, 2021 7:09 am

The current recommended PHP version at most providers is PHP 8.0 and is supported until 26 November 2023. Flatpress 1.2.1 runs stable under PHP 8.0 :)

Es sollte möglich sein, dein Webspace/Hosting Paket zurück auf PHP 8.0 zu stellen, damit stehen dir zwei weitere Jahre mit Flatpress ohne PHP Fehler zur Verfügung.

best regards, Grüße,
Laborix

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

Re: PHP 8.1.0 with some issues

Post by laborix » Sun Dec 19, 2021 9:44 am

Hi,

I just added the Smart Engine 2.6.32 to Flatpress 1.2.1 and tested in real life PHP 8.1.1 environment. There is a error at the most used strftime() function (Edit in Admin INterface) in Flatpress.

Code: Select all

Deprecated: Function strftime() is deprecated in ...\fp121\fp-includes\smarty\Smarty_Compiler.class.php on line 394
After a look in source code of the Smarty_Compiler.class.php and some sources in the Smarty \plugin directory, it seems that it was only fixed superficially.

User avatar
stippi
Posts: 9
Joined: Wed Dec 15, 2021 1:18 pm
Location: 48.06271, 8.53402
Contact:

Re: PHP 8.1.0 with some issues

Post by stippi » Sun Dec 19, 2021 4:49 pm

laborix wrote: Sun Dec 19, 2021 7:09 am The current recommended PHP version at most providers is PHP 8.0 and is supported until 26 November 2023. Flatpress 1.2.1 runs stable under PHP 8.0 :)

Es sollte möglich sein, dein Webspace/Hosting Paket zurück auf PHP 8.0 zu stellen, damit stehen dir zwei weitere Jahre mit Flatpress ohne PHP Fehler zur Verfügung.

best regards, Grüße,
Laborix
Hallo Laborix,

leider kein Glück mit PHP 8.0.13. Nach wie vor Fehler, selbst nach

* Den Flatpress-Index neu erstellen
* Den Theme- und Template-Cache leeren
:(

Grüße
stippi

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

Re: PHP 8.1.0 with some issues

Post by laborix » Sun Dec 19, 2021 5:36 pm

stippi wrote: Sun Dec 19, 2021 4:49 pm ... leider kein Glück mit PHP 8.0.13. Nach wie vor Fehler. ...
Hi stippi,

bitte melde dich in Flatpress an und stelle das verwendete Template/Layout auf "Leggero" um. Dann den Cache in Flatpress und im eingesetzten Webbrowser löschen und nochmals testen. Es liegt der Verdacht nahe, dass dein Problem mit dem verwendeten Template/Layout zusammen hängt.

Test 2:
Deaktiviere alle Plugins die nicht zum Kern von Flatpress gehören. Auch hier, danach Cache löschen und testen.

Gruß
Laborix

User avatar
stippi
Posts: 9
Joined: Wed Dec 15, 2021 1:18 pm
Location: 48.06271, 8.53402
Contact:

Re: PHP 8.1.0 with some issues

Post by stippi » Mon Dec 20, 2021 6:48 pm

laborix wrote: Sun Dec 19, 2021 5:36 pm
stippi wrote: Sun Dec 19, 2021 4:49 pm ... leider kein Glück mit PHP 8.0.13. Nach wie vor Fehler. ...
Hi stippi,

bitte melde dich in Flatpress an und stelle das verwendete Template/Layout auf "Leggero" um. Dann den Cache in Flatpress und im eingesetzten Webbrowser löschen und nochmals testen. Es liegt der Verdacht nahe, dass dein Problem mit dem verwendeten Template/Layout zusammen hängt.

Test 2:
Deaktiviere alle Plugins die nicht zum Kern von Flatpress gehören. Auch hier, danach Cache löschen und testen.

Gruß
Laborix
Hallo Laborix,

ja, tatsächlich. Keine Fehler mit "Leggero". Einzig das Abmelden muss ich immer zweimal machen und die Startseite wird danach nicht automatisch geladen, so wie ich es vor der Umstellung auf PHP 8 gewohnt war, aber damit kann ich leben. Plugins habe ich keine installiert, benutze nur die mitgelieferten Standard-Plugins.
Vielen dank für die Hilfe.

Grüße an @lle und Euch eine frohe Weihnachtszeit.
stippi

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

Re: PHP 8.1.0 with some issues

Post by laborix » Tue Dec 21, 2021 4:53 pm

Ich habe mal kurz das Template Atog getestet, ja, es ist nicht Flatpress 1.2.1 kompatibel und erzeugt unter PHP 8.0.14 einige Fehler. Es werden Flatpress Parameter verwendet, die laut alten Forum (2009/2010) genutzt wurden, auch scheint es nicht mobile-fähig zu sein.

Danke für die Info und dir auch eine schöne Weihnachtszeit :)

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests