FS#73451 - [tt-rss] php 8.1 breaks stuff

Attached to Project: Community Packages
Opened by Oleksandr Natalenko (post-factum) - Friday, 21 January 2022, 20:24 GMT
Last edited by Anatol Pomozov (anatolik) - Tuesday, 01 February 2022, 17:11 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Pierre Schmitz (Pierre)
Anatol Pomozov (anatolik)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 5
Private No

Details

The following issue occurs after upgrading to php 8.1:

```
nginx[122339]: 2022/01/21 21:04:15 [error] 122339#122339: *572280 FastCGI sent in stderr: "PHP message: PHP Fatal error: During inheritance of ArrayAccess: Uncaught Error: Class "ORM" not found in /usr/share/webapps/tt-rss/classes/logger/sql.php:7
Stack trace:
#0 /usr/share/webapps/tt-rss/classes/logger.php(62): Logger_SQL->__construct()
#1 /usr/share/webapps/tt-rss/classes/logger.php(80): Logger->__construct()
#2 /usr/share/webapps/tt-rss/classes/logger.php(32): Logger::get_instance()
#3 /usr/share/webapps/tt-rss/include/errorhandler.php(60): Logger::log_error()
#4 /usr/share/webapps/tt-rss/vendor/j4mie/idiorm/idiorm.php(115): ttrss_error_handler()
#5 /usr/share/webapps/tt-rss/vendor/composer/ClassLoader.php(444): include('...')
#6 /usr/share/webapps/tt-rss/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile()
#7 /usr/share/webapps/tt-rss/classes/db.php(11): Composer\Autoload\ClassLoader->loadClass()
#8 /usr/share/webapps/tt-rss/classes/db.php(82): Db->__construct()
#9 /usr/share/webapps/tt-rss/classes/db/migrations.php(33): Db::pdo()
#10 /usr/share/webapps/tt-rss/clas...PHP message: PHP Fatal error: Uncaught Error: Class "ORM" not found in /usr/share/webapps/tt-rss/classes/logger/sql.php:7
Stack trace:
#0 /usr/share/webapps/tt-rss/classes/logger.php(62): Logger_SQL->__construct()
#1 /usr/share/webapps/tt-rss/classes/logger.php(80): Logger->__construct()
#2 /usr/share/webapps/tt-rss/classes/logger.php(32): Logger::get_instance()
#3 /usr/share/webapps/tt-rss/include/errorhandler.php(81): Logger::log_error()
#4 [internal function]: ttrss_fatal_handler()
#5 {main}
thrown in /usr/share/webapps/tt-rss/classes/logger/sql.php on line 7" while reading response header from upstream, client: 1.2.3.4, server: rss.example.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/…/sock:", host: "rss.example.com"
```

Looks like `j4mie/idiorm` vendor component is not compatible with 8.1 [1].

There's a workaround, as per [2], which is to annotate `ArrayAccess` class methods with `#[\ReturnTypeWillChange]`.

I've tried this workaround, and it seems it works, but I have no idea if it is a correct approach. Probably, Arch should carry a small patch since it seems that stuff is not actively maintained in upstream.

[1] https://github.com/j4mie/idiorm/issues/371
[2] https://github.com/j4mie/idiorm/pull/370
This task depends upon

Closed by  Anatol Pomozov (anatolik)
Tuesday, 01 February 2022, 17:11 GMT
Reason for closing:  Fixed
Additional comments about closing:  tt-rss-2:r11220.b59bde7b4-1
Comment by Oleksandr Natalenko (post-factum) - Friday, 21 January 2022, 20:34 GMT Comment by Oleksandr Natalenko (post-factum) - Friday, 21 January 2022, 20:36 GMT
php 8.1 related change explanation: [1]

[1] https://php.watch/versions/8.1/internal-method-return-types
Comment by Anatol Pomozov (anatolik) - Saturday, 22 January 2022, 02:48 GMT
how to reproduce the issue?
Comment by Oleksandr Natalenko (post-factum) - Saturday, 22 January 2022, 07:15 GMT
Just install tt-rss and run it with php 8.1.
Comment by Anatol Pomozov (anatolik) - Saturday, 22 January 2022, 17:13 GMT
my tt-rss instance works for me. The even logs shows following deprecations:


vendor/j4mie/idiorm/idiorm.php:2405 IdiormResultSet implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)

classes/debug.php:91 Function strftime() is deprecated
1. classes/debug.php(91): ttrss_error_handler(Function strftime() is deprecated, classes/debug.php)
2. classes/article.php(480): log(Purged 0 orphaned posts.)
3. classes/rssutils.php(1663): _purge_orphans()
4. update.php(253): housekeeping_common()



It worth updating tt-rss anyway
Comment by Anatol Pomozov (anatolik) - Saturday, 22 January 2022, 17:28 GMT
Actually after rebooting my server I see the issue now.
Comment by Anatol Pomozov (anatolik) - Saturday, 22 January 2022, 17:33 GMT
Oleksandr the PR you mentioned is too raw, it contains a lot of unrelated changes. Are you familiar with php8.1? Would it be possible for you to fork https://github.com/j4mie/idiorm and make php8.1 changes only? I'll be glad to apply the patch to Arch's package.
Comment by Lee Donaghy (deadite66) - Saturday, 22 January 2022, 17:40 GMT
have the same issue when i upgraded to php 8.1, just a blank page.


Comment by kyak (kyak) - Saturday, 22 January 2022, 18:07 GMT
I'm using the master branch of tt-rss, but reverted this commit: https://git.tt-rss.org/fox/tt-rss/commit/a201e10ee024f03fb6aad0ec1069cc4da72a9ac5

Note that I'm reverting the reverted commit.

I believe the reason if was reverted upstream is due to php 7 incompatibility. But we don't care about php 7.

This works for me.
Comment by Anatol Pomozov (anatolik) - Saturday, 22 January 2022, 18:43 GMT
Thanks kyak. I re-applied the upstream patch and pushed tt-rss-2:r11216.56fd06d61-1 package to the repo. Please try it and let me know if you have any issues with it.
Comment by Oleksandr Natalenko (post-factum) - Saturday, 22 January 2022, 19:58 GMT
> Are you familiar with php8.1? Would it be possible for you to fork https://github.com/j4mie/idiorm and make php8.1 changes only?

Umm. I'm familiar with PHP to some extent, but maintaining a fork of some random outdated stuff is not really my priority, sorry :).

The revert of upstream's revert works fine for me, so I'll stick to it. Thank you.
Comment by Lee Donaghy (deadite66) - Saturday, 22 January 2022, 21:04 GMT
working here also, though weirdly it did seem to download every article from some feeds but appears to have settled down now.
Comment by kyak (kyak) - Sunday, 23 January 2022, 07:38 GMT
Thanks Tolya, all works fine!
Comment by Chih-Hsuan Yen (yan12125) - Sunday, 23 January 2022, 14:13 GMT
Thanks! Could you also revert another reverted commit? https://git.tt-rss.org/fox/tt-rss/commit/aaebe55456b34b878b7bcccef021af7f2c8d3a75 fixes warnings from strftime

Here is a draft PKGBUILD: https://fars.ee/Xyu_ I use `git revert` instead of downloading patches. Just a personal taste :)
Comment by Anatol Pomozov (anatolik) - Monday, 24 January 2022, 18:57 GMT
Using git revert directly sounds like a good idea. Done. Reverted aaebe55456 as well.

Pushed tt-rss-2:r11216.56fd06d61-2-any.pkg.tar.zst to testing. Please verify that it works as expected.
Comment by Lee Donaghy (deadite66) - Monday, 24 January 2022, 21:12 GMT
working fine here.
Comment by Viliam Tokarcik (t0ki) - Tuesday, 25 January 2022, 14:00 GMT
After upgrade, clicking on element, doesn't mark article as read. Where can be problem?
Comment by Chih-Hsuan Yen (yan12125) - Tuesday, 25 January 2022, 14:56 GMT
Thanks I can also confirm tt-rss 2:r11216.56fd06d61-2 works fine here!

> After upgrade, clicking on element, doesn't mark article as read.

I manually mark an article as unread and clicking it turns it into read again. Maybe the issue is something other than PHP 8.1; the updated package in Arch involves not only PHP 8.1 patches but also the latest git commits from upstream.
Comment by Anatol Pomozov (anatolik) - Wednesday, 26 January 2022, 01:27 GMT
> I manually mark an article as unread and clicking it turns it into read again.

Yeah I see it as well. It looks like an upstream issue and need to be reported/fixed there.
Comment by Schrottfresse (Schrottfresse) - Wednesday, 26 January 2022, 09:10 GMT
> After upgrade, clicking on element, doesn't mark article as read. Where can be problem?

Do you use MySQL as database? I found a workaround in the code that tests for mysql and works around the problem that MySQL does not know about boolean values.
In my MySQL instance the values in the database weren't strings anymore but integers instead, so I added a switch to check for integers.
Comment by Jonathan Ketchker (Jark) - Wednesday, 26 January 2022, 23:36 GMT
tested the patch and it solved the issue of not being able to mark read.
still have many read items that got marked unread now...
also got duplicates
Comment by Anatol Pomozov (anatolik) - Wednesday, 26 January 2022, 23:42 GMT
Could you please folks worj with upstream on this fix? Once it lands master I'll cut a new release.
Comment by Viliam Tokarcik (t0ki) - Thursday, 27 January 2022, 00:25 GMT
I have mariadb. Your patch fixed marking articles as read. Thanks.
Comment by Schrottfresse (Schrottfresse) - Thursday, 27 January 2022, 12:19 GMT
Great. I'll try to get this implemented upstream.
Comment by Schrottfresse (Schrottfresse) - Friday, 28 January 2022, 07:44 GMT Comment by Anatol Pomozov (anatolik) - Monday, 31 January 2022, 05:50 GMT
Pushed an updated tt-rss-2:r11220.b59bde7b4-1-any.pkg.tar.zst to community. Please verify that it works as expected.
Comment by Schrottfresse (Schrottfresse) - Monday, 31 January 2022, 08:32 GMT
Just verified. Everything works as expected and the fix is in place.
Comment by Jonathan Ketchker (Jark) - Monday, 31 January 2022, 21:17 GMT
Seems stable here as well with php 8.1.2. I removed dublicates that was created due to the issue with an sql script in case anybody needs it:

```sql
DELETE f2 FROM ttrss_entries f1 INNER JOIN ttrss_entries f2
WHERE f1.id < f2.id AND f1.link = f2.link;
```

You could use other fields in the later condition. i removed the newer dublicates as the old ones was read and the new unread. you could replace f2 with f1 at the start to remove the older entries if you wish for it.

Loading...