Using Selfoss with PHP 8

by Triskaideka, Wednesday, December 08, 2021, 17:03 (360 days ago)

Has anybody been using, or tried to use, Selfoss on a web server that runs PHP 8? How has your experience been?

I've been using Selfoss for about a year and it's been fine so far. This weekend I tried to migrate it to a new server with upgraded software, something I've done before without any trouble, but this time I encountered some errors.

The biggest difference between the servers is that the old one had PHP 7.4.3 and the new one has PHP 8.0.13. That's why I suspect that PHP 8 is the culprit. But it's certainly possible that the problem lies elsewhere and the PHP upgrade is a coincidence.

Here's what I see when I visit my Selfoss installation's home page on the PHP 8 server:


Internal Server Error
Undefined array key "ERROR"

Internal Server Error
Unknown named parameter $expire [/path/to/selfoss/vendor/bcosca/fatfree-core/base.php:2284]

Strangely, there's no reference to a variable named "$expire" on line 2284 or anywhere else in fatfree-core/base.php. Here's what line 2284 looks like:


                call_user_func_array('session_set_cookie_params',$jar);

When I check Apache's error logs, there are dozens of lines that look like this:


[Sun Dec 05 17:03:25.833416 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "DEBUG" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1184
[Sun Dec 05 17:03:25.833434 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "CLI" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1239
[Sun Dec 05 17:03:25.833443 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "AJAX" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1239
[Sun Dec 05 17:03:25.833452 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "HIGHLIGHT" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1240
[Sun Dec 05 17:03:25.833462 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "CLI" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1110
[Sun Dec 05 17:03:25.833470 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "PACKAGE" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1112
[Sun Dec 05 17:03:25.833478 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "XFRAME" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1114
[Sun Dec 05 17:03:25.833490 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "VERB" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1118
[Sun Dec 05 17:03:25.833518 2021] [php:warn] [pid 5850] [client 104.237.193.54:36666] PHP Warning:  Undefined array key "HALT" in /home/kermit/websites/selfoss/vendor/bcosca/fatfree-core/base.php on line 1272

I visited the GitHub page for fatfree-core and noticed that there's a newer version than what ships with Selfoss 2.18. Hoping to get lucky, I downloaded fatfree-core 3.7.3 and replaced Selfoss' version with it. This *may have* resulted in some progress, in the sense that the error messages changed. The web page no longer showed Internal Server Error messages; it was devoid of text but had Selfoss' recognizeable checkered background image. Here are the Apache logs that I saw after that:


[Sun Dec 05 17:20:36.115668 2021] [php:notice] [pid 5855] [client 104.237.193.54:36948] Undefined property: helpers\\View::$loggedin
[Sun Dec 05 17:20:36.115725 2021] [php:notice] [pid 5855] [client 104.237.193.54:36948] [templates/home.phtml:145] Base->{closure}()
[Sun Dec 05 17:20:36.115738 2021] [php:notice] [pid 5855] [client 104.237.193.54:36948] [helpers/View.php:94] include()
[Sun Dec 05 17:20:36.115746 2021] [php:notice] [pid 5855] [client 104.237.193.54:36948] [controllers/Index.php:35] helpers\\View->render()
[Sun Dec 05 17:20:36.115754 2021] [php:notice] [pid 5855] [client 104.237.193.54:36948] [index.php:80] Base->run()

I don't really know what to try next, and even if I did, I suspect it'd just lead me deeper down a rabbit hole of error messages. So coming here for help seems like the next step. Has anybody else had success with PHP 8? Anybody seen error messages like these before? Could I have misconfigured something?

Some background on my setup: it's a basic DigitalOcean droplet, so the CPU is shared but I'm in control of what's on the OS. Ubuntu version 20.04.3, Apache version 2.4.41, PHP version 8.0.13. I'm using an SQLite database. I use the droplet for other things, but Selfoss is the arguably the biggest/most complex.

Using Selfoss with PHP 8

by jtojnar, Wednesday, December 08, 2021, 18:55 (360 days ago) @ Triskaideka

As you have noticed selfoss 2.18 does not work with PHP 8. In addition to fatfree, there were many incompatibilities in other libraries and even selfoss itself so I would not recommend trying to fix it piecemeal. You can use nightly builds as those are tested on PHP 8.0 and are quite stable (plus they include tons of other fixes and new features).

Using Selfoss with PHP 8

by Triskaideka, Thursday, December 09, 2021, 04:44 (360 days ago) @ jtojnar

jtojnar, thank you for the advice. I've downloaded the latest nightly build and it seems to be working well so far.

Using Selfoss with PHP 8

by nickrickard, Sunday, January 16, 2022, 16:02 (321 days ago) @ Triskaideka

Having also migrated my server to PHP8, I've downloaded a recent nightly (selfoss-2.19-fdbdb80). Previous selfoss 2.18 on PHP7.4 was working fine.

Now the 'star' and 'mark as read' buttons don't seem to now work. Selfoss is updating feeds (on both a cron job and typing /update into the web bar) so seems to have appropriate permissions for the database. The 'open' and 'share on email' buttons are working.

I've set "logger_level=DEBUG" in config.ini and am not getting anything in the logs when I click 'star' or 'mark as read'. The keyboard shortcuts for these don't work either.

I suspect I've missed something obvious in the docs on the migration from 2.18 to 2.19. Grateful for any pointers as to what it might be, please.

Using Selfoss with PHP 8

by jtojnar, Sunday, January 16, 2022, 22:35 (321 days ago) @ nickrickard

I am assuming this is PHP 8.0, since 8.1 is still broken.

No special upgrade procedure should be required so if something does not work, it is a bug.

I was unable to reproduce it.

Could you check if there are any messages in your browser’s developer tools’ console (F12 key), or anything weird in network panel when you press the buttons? Is that desktop or mobile interface? Or did you perhaps enable the offline mode?

Using Selfoss with PHP 8

by nickrickard, Monday, January 17, 2022, 09:11 (320 days ago) @ jtojnar

Yes, PHP8.0 (8.0.8-1).

How would I know (or enable/disable) offline mode?

The developer console has a few error messages related to css declarations (things like -moz-box-shadow which I can't see would be relevant to this.) There aren't any script errors or warnings. My adblockers are turned off for my local home site. I'm not sure I'm going to be able to provide much help.

It's the same behaviour on my desktop and mobile, both through Firefox (91ESR desktop, 96 mobile). Clicking on or using keyboard shortcuts for the other buttons work.

If selfoss was trying to write to the database and was denied, would I expect to see something in the logs? I get
"[2022-01-17 07:54:34] selfoss.DEBUG: Established database connection"
when I refresh the page, but nothing that corresponds to a failed click on 'star' or 'mark as read'.

If others aren't seeing this then I don't want to distract your time on something that might be curious or unique to my setup.

Thanks.

Using Selfoss with PHP 8

by Triskaideka, Monday, January 17, 2022, 16:47 (320 days ago) @ nickrickard

FWIW, I'm using Selfoss 2.19-8941a31 on PHP 8.0.13 and am not seeing any problems with the "star" or "mark as read" features.

I am seeing other problems, most significantly, that some RSS feeds are not getting updated (with a "connection timed out" message) even though they were fine under Selfoss 2.18 and I can visit them in my browser with no problem. I wasn't sure whether it made sense to submit a bug report for a nightly build, but I can make a fuller post about this here or on GitHub if anyone wants.

Using Selfoss with PHP 8

by jtojnar, Monday, January 17, 2022, 19:33 (320 days ago) @ Triskaideka

I am seeing other problems, most significantly, that some RSS feeds are not getting updated (with a "connection timed out" message) even though they were fine under Selfoss 2.18 and I can visit them in my browser with no problem. I wasn't sure whether it made sense to submit a bug report for a nightly build, but I can make a fuller post about this here or on GitHub if anyone wants.

Please report any issues you see in nightly builds, either on issue tracker or here. Some nightly build will (hopefully) eventually become a release so it is important to catch bugs before then.

If timeouts when fetching feed persist, they may be caused by the website’s bot detection in some cases but then I would expect it to fail in old selfoss version too so we cannot rule out a bug.

Using Selfoss with PHP 8

by jtojnar, Monday, January 17, 2022, 18:10 (320 days ago) @ nickrickard

How would I know (or enable/disable) offline mode?

It should be disabled by default since it is still experimental and buggy. It should not be a problem unless you enabled it by checking the checkbox on login page. If you accidentally enabled it, you can disable it by clicking the log out button.

The developer console has a few error messages related to css declarations (things like -moz-box-shadow which I can't see would be relevant to this.) There aren't any script errors or warnings.

If you click on XHR toggle button in the top right of the console, you should see AJAX requests when clicking the star button:

[image]

If selfoss was trying to write to the database and was denied, would I expect to see something in the logs? I get
"[2022-01-17 07:54:34] selfoss.DEBUG: Established database connection"

when I refresh the page, but nothing that corresponds to a failed click on 'star' or 'mark as read'.

Yeah, “Established database connection” should be logged for each action. So maybe the issue is indeed in the client not sending the requests.

If others aren't seeing this then I don't want to distract your time on something that might be curious or unique to my setup.

Even if you misconfigured something, selfoss should still work. Or at least log some info that would tell you what is wrong. So either way, it is a selfoss bug and we need to figure it out.

Using Selfoss with PHP 8

by nickrickard, Monday, January 17, 2022, 18:51 (320 days ago) @ jtojnar

Thank you for your patience.

I get the XHR log messages on first loading the selfoss page:


17:19.57.337 XHRGEThttps://[mysite]/nickfeed/api/about
[HTTP/1.1 200 OK 0ms]

17:19:57.880
XHRGEThttps://[mysite]/nickfeed/?type=unread&extraIds[]=&sourcesNav=false&search=&itemsPerPage=50
[HTTP/1.1 200 OK 0ms]

But I don't get any XHR message for clicking 'star' or 'mark as read'. Inspecting the source of the button shows that there is an event listener, which seems to be linked to react-dom.production.min.js.

Using your screenshot I could reverse-engineer the page https://[mysite]/nickfeed/mark/103653 which came up with 'Page not Found'. 103653 is a valid unread article number. So I can't manually trigger it to mark an article as read. But clicking on the 'Mark [All] as Read' button in the top left green logo and box does mark all my articles as read.

(Still nothing beyond selfoss.DEBUG: Established database connection in the logs which occurs on a page refresh but nothing on a button click.)

Using Selfoss with PHP 8

by jtojnar, Monday, January 17, 2022, 21:08 (320 days ago) @ nickrickard

I get the XHR log messages on first loading the selfoss page:


17:19.57.337 XHRGEThttps://[mysite]/nickfeed/api/about
[HTTP/1.1 200 OK 0ms]

17:19:57.880
XHRGEThttps://[mysite]/nickfeed/?type=unread&extraIds[]=&sourcesNav=false&search=&itemsPerPage=50
[HTTP/1.1 200 OK 0ms]

But I don't get any XHR message for clicking 'star' or 'mark as read'. Inspecting the source of the button shows that there is an event listener, which seems to be linked to react-dom.production.min.js.

Yeah, that sounds like a problem.

Using your screenshot I could reverse-engineer the page https://[mysite]/nickfeed/mark/103653 which came up with 'Page not Found'.

The API route only works with POST method. Using something like curl -X POST 'https://mysite/nickfeed/mark/230130?username=...&password=...' on command line should work (or it is also possible to edit and resend an existing request in Network panel of developer tools). But given that no XHR is shown when clicking the button, the issue is most likely in the client.

Just to check, do you perhaps have some customization enabled (e.g. you created `user.js` or `user.css` files in your selfoss directory)?

Using Selfoss with PHP 8

by nickrickard, Tuesday, January 18, 2022, 08:43 (319 days ago) @ jtojnar

curl -X POST 'https://mysite/nickfeed/mark/230130?username=...&password=...' returns {"success":true} and the article is correctly marked as read.

selfoss.entriesPage.markEntryRead(103678, true) in the browser console returns undefined. And doesn't change the article to read.

I haven't done any customisation of user.js, user.css, or similar. I have config.ini carried across from my selfoss 2.18 installation. I have (for this subsite) turned off all Content-Security-Protection in nginx so that shouldn't be blocking any scripts or inline code.

Using Selfoss with PHP 8

by jtojnar, Tuesday, January 18, 2022, 14:30 (319 days ago) @ nickrickard

The function only seems to have a single return statement before triggering the XHR request. What do you get for selfoss.loggedin.value in the devtools console?

Using Selfoss with PHP 8

by nickrickard, Tuesday, January 18, 2022, 15:51 (319 days ago) @ jtojnar

Bingo!

selfoss.loggedin.value was false.

That's because I have an empty user= and password= in my config.ini. That's always seemed okay on previous versions of selfoss.

Setting a user= in config.ini and then reloading selfoss so it forces a login fixes the problem! 'Star' and 'Read/Unread' buttons now work as expected.

So, the headline is that it now works. Thank you so much. Additional question: how do I now log out of selfoss so I can create a better user/pwd combination and re-login?

The question is if someone runs with a user= then is that acceptable practice, in which case there might be a bug that needs fixing? Or does a user have to be specified?

Using Selfoss with PHP 8

by jtojnar, Thursday, January 20, 2022, 08:09 (317 days ago) @ nickrickard

That's because I have an empty user= and password= in my config.ini. That's always seemed okay on previous versions of selfoss.

Yeah, that is definitely a bug. It should be fixed by #1309 (included in the latest build).

Additional question: how do I now log out of selfoss so I can create a better user/pwd combination and re-login?

If you are logged in, you should see log out button in the toolbar at the bottom of the sidebar.

But you do not need to log out if you change the username or password since currently selfoss only supports a single user anyway.

The question is if someone runs with a user= then is that acceptable practice, in which case there might be a bug that needs fixing? Or does a user have to be specified?

Yeah, no user (authentication disabled) is the default setting – selfoss is designed to work out of the box without any configuration at all. It should be fully supported since it is useful for local installations and when one uses a different authentication method (e.g. nginx auth_request module).

Using Selfoss with PHP 8

by nickrickard, Friday, January 21, 2022, 11:41 (316 days ago) @ jtojnar

Yeah, that is definitely a bug. It should be fixed by #1309 (included in the latest build).

I've installed 2.19-210fa62 and that works, thanks. Unauthenticated user (user= in config.ini) and 'star' and 'read/unread' toggle properly.

Using Selfoss with PHP 8

by jtojnar, Monday, January 17, 2022, 21:22 (320 days ago) @ nickrickard

Also, could you try running something like selfoss.entriesPage.markEntryRead(383030, true) in your browser console?

That is basically all the button event handler does:

https://github.com/fossar/selfoss/blob/e9551d7d95a2b29907e8e9e06644832e081848f0/assets/js/templates/Item.jsx#L347

RSS Feed of thread
powered by my little forum