Feed entries wrongly shown as read on PHP 8.1

  • [ ] I’m using stock docker compose setup, unmodified.
  • [ ] I’m using docker compose setup, with modifications (modified .yml files, third party plugins/themes, etc.) - if so, describe your modifications in your post. Before reporting, see if your issue can be reproduced on the unmodified setup.
  • [x] I’m not using docker on my primary instance, but my issue can be reproduced on the aforementioned docker setup and/or official demo.

I’m using TT-RSS with MariaDB. With one of the last updates (most probably PHP 8 to PHP 8.1) my instances started to show a number of unread entries, but when clicking on the feed, all unread entries were shown as read (dark grey on light grey, not black on white). Toggling the read marking two times marked them then as read.

  • Tiny Tiny RSS version (including git commit id): 2:r11216.56fd06d61-2
  • Platform (i.e. Linux distro, Docker, PHP, PostgreSQL, etc) versions:
    • Linux distro: ArchLinux
    • Docker: no
    • MySQL: 10.6.5-MariaDB Arch Linux

I already found the culprit. The tables ttrss_user_entries is created with the following attributes:

create table ttrss_user_entries (
	[...]
	marked bool not null default 0,
	published bool not null default 0,
	[...]
	unread bool not null default 1,
	[...]
)

In PHP 8 it seems they were evaluated to a string, because there is some code in classes/feed.php that checks for a MySQL database and then “converts” the string to a boolean:

				// frontend doesn't expect pdo returning booleans as strings on mysql
				if (Config::get(Config::DB_TYPE) == "mysql") {
					foreach (["unread", "marked", "published"] as $k) {
						$line[$k] = $line[$k] === "1";
					}
				}

With the following patch I made it work again:

--- feeds.php   2022-01-26 09:49:24.721006194 +0100
+++ feeds_mod.php       2022-01-26 09:50:12.997754011 +0100
@@ -195,7 +195,11 @@
                                // frontend doesn't expect pdo returning booleans as strings on mysql
                                if (Config::get(Config::DB_TYPE) == "mysql") {
                                        foreach (["unread", "marked", "published"] as $k) {
-                                               $line[$k] = $line[$k] === "1";
+                                                if (is_integer($line[$k])) {
+                                                   $line[$k] = $line[$k] === 1;
+                                                } else {
+                                                   $line[$k] = $line[$k] === "1";
+                                                }
                                        }
                                }

Shall I create a pull request for this?

sure, go ahead. thanks for reporting this.