PHP7.4 deprecations

I know you’ll probably shout at me for being a hipster and running a bleeding edge .0 release of PHP. But I thought I would just report a couple of things so that you are aware and before other people come asking about it.

TTRSS works perfectly fine with 7.4.0 with two exceptions.

The favicon color script appears to be broken and none of the feeds have colors any longer. There is an error logged in the console on every feed update which is E_DEPRECATED. It looks like hexdec on line 208 of colors.php is getting some input that it doesn’t like. I’m assuming it’s the # character.

Invalid characters passed for attempted conversion, these have been ignored

  1. include/colors.php(208): hexdec(#cc66cc)
  2. classes/feeds.php(371): _color_unpack(#cc66cc)
  3. classes/feeds.php(557): format_headlines_list(-3, ForceUpdate, adaptive, 30, , 0, , 1, , , default)
  4. backend.php(123): view()

The other issue is this line is being logged in my PHP error log.

PHP Deprecated: Function get_magic_quotes_gpc() is deprecated in /www/ttrss/backend.php on line 7

hexdec() likely expects a hex triplet without #, which makes sense. i’ll make a note to take a look at this unless someone files a PR first.

we only call it to ensure it is disabled, i think. i’m not sure if this is really needed anymore tbh.

I was gonna take a look at this and re-registered on your Gogs; tried to fork but it said I had hit the limit (0); When you get a chance, can you do the needful? Gogs account is tsimmons?

Thanks &
Cheers.

the needful should be done now :slight_smile:

Awesome, thanks! And of course today I’m slammed and cannot get to it. :rofl:

My event log has been spammed with this E_DEPRECATED warning since I upgraded to php 7.4:

Array and string offset access syntax with curly braces is deprecated
1. include/autoload.php(24): ttrss_error_handler(8192, Array and string offset access syntax with curly braces is deprecated, classes/feeds.php, 1927, Array)
2. include/autoload.php(24): include()
3. classes/rssutils.php(1580): spl_autoload_call(Feeds)
4. classes/rssutils.php(543): load_filters(17, 2)
5. classes/rssutils.php(148): update_rss_feed(17, 1, )
6. update.php(250): update_daemon_common(50)

e: I noticed the mention of filters in the backtrace, some of my filters use “match any rule”, if that helps.

i’m not even sure why is this using { } :man_shrugging: this is ancient code though.

this should deal with both, i think:

https://git.tt-rss.org/fox/tt-rss/commit/565547f5a19ff8af7e882bdb23b2a916a05e5b00

tell me if i broke anything.

e: i’ve also removed that magic quote thing entirely. apparently it didn’t do anything since php 5.4 anyway so it was only there because nobody bothered to ask for its removal.

Updated. Warnings have gone away. Nothing seems broken. Thanks :slight_smile:

Sorry for potential hijacking the thread, but I recenty upgraded to PHP 7.4 and I’m getting this:

Array and string offset access syntax with curly braces is deprecated1. plugins/af_comics/filters/af_comics_gocomics.php(34): ttrss_error_handler(8192, Array and string offset access syntax with curly braces is deprecated, lib/MiniTemplator.class.php, 888, Array)
2. plugins/af_comics/filters/af_comics_gocomics.php(34): require_once()
3. plugins/af_comics/init.php(89): on_fetch(https://www.gocomics.com/wumo)
4. classes/rssutils.php(345): hook_fetch_feed(, https://www.gocomics.com/wumo, 1, 68, 0, , )
5. classes/rssutils.php(148): update_rss_feed(68, 1, )
6. update.php(250): update_daemon_common(50)

minitemplator is unmaintained i think. i don’t care much for bleeding edge software, so if someone wants to fix it, be my guest. otherwise this will have to wait until i’m bored enough to take a look at this.

e: its very likely going to be a trivially easy fix tho

I think this fixed the issue on my instance. However I’m not sure if you plan to drop MiniTemplator so here is the diff:

diff --git a/lib/MiniTemplator.class.php b/lib/MiniTemplator.class.php
index e70f0a470..1eb1c3bed 100644
--- a/lib/MiniTemplator.class.php
+++ b/lib/MiniTemplator.class.php
@@ -309,7 +309,7 @@ function processTemplateCommand ($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFrom
          $resumeFromStart = true;
          break;
       default:
-         if ($cmd{0} == '$' && !(strlen($cmd) >= 2 && $cmd{1} == '{')) {
+         if ($cmd{0} == '$' && !(strlen($cmd) >= 2 && $cmd[1] == '{')) {
             $this->triggerError ("Unknown command \"$cmd\" in template at offset $cmdTPosBegin.");
             return false; }}
     return true; }
@@ -856,10 +856,10 @@ function readFileIntoString ($fileName, &$s) {
 */
 function parseWord ($s, &$p, &$w) {
    $sLen = strlen($s);
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
+   while ($p < $sLen && ord($s[$p]) <= 32) $p++;
    if ($p >= $sLen) return false;
    $p0 = $p;
-   while ($p < $sLen && ord($s{$p}) > 32) $p++;
+   while ($p < $sLen && ord($s[$p]) > 32) $p++;
    $w = substr($s, $p0, $p - $p0);
    return true; }

@@ -869,11 +869,11 @@ function parseWord ($s, &$p, &$w) {
 */
 function parseQuotedString ($s, &$p, &$w) {
    $sLen = strlen($s);
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
+   while ($p < $sLen && ord($s[$p]) <= 32) $p++;
    if ($p >= $sLen) return false;
    if (substr($s,$p,1) != '"') return false;
    $p++; $p0 = $p;
-   while ($p < $sLen && $s{$p} != '"') $p++;
+   while ($p < $sLen && $s[$p] != '"') $p++;
    if ($p >= $sLen) return false;
    $w = substr($s, $p0, $p - $p0);
    $p++;
@@ -885,7 +885,7 @@ function parseQuotedString ($s, &$p, &$w) {
 */
 function parseWordOrQuotedString ($s, &$p, &$w) {
    $sLen = strlen($s);
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
+   while ($p < $sLen && ord($s[$p]) <= 32) $p++;
    if ($p >= $sLen) return false;
    if (substr($s,$p,1) == '"')
       return $this->parseQuotedString($s,$p,$w);

e: I think there are few more places to fix :frowning:
e2: I don’t see any more errors in my logs

like i said, this is basically search and replace. can you file a PR?

Can you grant me access to git? Username: skibbi

sure, done.

20charrr

anyway, https://git.tt-rss.org/fox/tt-rss/commit/491090d21b838c1c9a04acf516dbc5c913d1a3fb

:rofl:

/20charrrrrrrrrrrrr

Still alive despite virus :slight_smile:
https://git.tt-rss.org/fox/tt-rss/pulls/134/commits

:face_with_raised_eyebrow:

lol

thanks for the PR but since i did essentially same changes already it can’t be merged. :slight_smile: