akirk / friends

A social network between WordPresses. Privacy focused, by itself a self-hosted RSS++ reader with notifications.
https://wpfriends.at/
GNU General Public License v2.0
80 stars 15 forks source link

Feeds Refresh seems to be broken and PHP issuing warnings about missing keys. #269

Open alecmuffett opened 10 months ago

alecmuffett commented 10 months ago

So I set up a WP ActivityPub/Friends instance last night, and subscribed ~120 feeds to it.

Apart from the initial load of articles upon subscription, no feeds are refreshing and they are all stale unless individually refreshed.

2023/11/07 23:01:57 [error] 985#985: *2171 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "id" in /PATH/wordpress/wp-content/plugins/friends/feed-parsers/class-feed-parser-activitypub.php on line 406" while reading upstream, client: ADDRESS, server: SITE, request: "POST /wp-admin/admin.php?page=add-friend&url=%40jennifer%40defcon.social HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "SITE", referrer: "https://SITE/wp-admin/admin.php?page=add-friend&url=%40jennifer%40defcon.social"
2023/11/07 23:05:06 [error] 985#985: *2586 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "id" in /PATH/wordpress/wp-content/plugins/friends/feed-parsers/class-feed-parser-activitypub.php on line 406" while reading upstream, client: ADDRESS, server: SITE, request: "POST /wp-admin/admin.php?page=add-friend&url=%40neil%40mastodon.neilzone.co.uk HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "SITE", referrer: "https://SITE/wp-admin/admin.php?page=add-friend&url=%40neil%40mastodon.neilzone.co.uk"
2023/11/07 23:06:31 [error] 985#985: *2802 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "id" in /PATH/wordpress/wp-content/plugins/friends/feed-parsers/class-feed-parser-activitypub.php on line 406" while reading upstream, client: ADDRESS, server: SITE, request: "POST /wp-admin/admin.php?page=add-friend&url=%40marcia%40defcon.social HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "SITE", referrer: "https://SITE/wp-admin/admin.php?page=add-friend&url=%40marcia%40defcon.social"
2023/11/07 23:06:57 [error] 985#985: *2884 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "id" in /PATH/wordpress/wp-content/plugins/friends/feed-parsers/class-feed-parser-activitypub.php on line 406" while reading upstream, client: ADDRESS, server: SITE, request: "POST /wp-admin/admin.php?page=add-friend&url=%40kottke%40botsin.space HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "SITE", referrer: "https://SITE/wp-admin/admin.php?page=add-friend&url=%40kottke%40botsin.space"
akirk commented 10 months ago

Sorry for the trouble! It looks like a two things come together here.

Thanks for quoting the requests above, it seems like these users have accounts on Mastodon servers that have "Authorized Fetch" activated, and it looks like for some reason the outgoing request was not signed. Could it be that for your blog the Rest URL is on another host? i.e. https://github.com/Automattic/wordpress-activitypub/blob/efd98acd0bf3f2c42f0ffc3d8f10920e74cb8512/includes/model/class-application-user.php#L38 returns a different host than your blog? I've learned today that Mastodon will try to do a Webfinger lookup on the URL, so for example for the code linked above returns https://alex.kirk.at/wp-json/activitypub/1.0/application upon which Mastodon queries https://alex.kirk.at/.well-known/webfinger?resource=application@alex.kirk.at to get the profile URL.

The other thing is that ActivityPub "feeds" are not refreshed since they'll receive new messages through push. If you manually refresh them, it fetches their ActivityPub outbox which should have been done upon initial add (so that their page doesn't appear empty after adding them even though nothing has been yet pushed to them).

I hope this helps. Since a bit of time passed since you reported this, did you observe new items coming in?

alecmuffett commented 10 months ago

I think you may have found it. Investigating...

alecmuffett commented 10 months ago

Okay, so some more interesting stuff here.

I moved my ActivityPub Friends aggregation to a standalone WP instance, and decided to webfinger it per your recommendation:

IPADDR - - [15/Nov/2023:19:46:24 +0000] "GET /.well-known/webfinger?resource=acct:USER@DOMAIN HTTP/1.1" 500 297 "-" "curl/8.1.2"
IPADDR - - [15/Nov/2023:19:52:23 +0000] "GET /.well-known/webfinger?resource=acct: USER@DOMAIN HTTP/1.1" 500 297 "-" "curl/8.1.2"
2023/11/15 19:46:24 [error] 985#985: *365596 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method WP_Error::get_url() in /big/www-elsewhere/wordpress/wp-content/plugins/activitypub/integration/class-webfinger.php:36
2023/11/15 19:52:23 [error] 985#985: *365717 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method WP_Error::get_url() in /big/www-elsewhere/wordpress/wp-content/plugins/activitypub/integration/class-webfinger.php:36

This seems relevant. Running latest WP with full patches on latest Ubuntu LTS with PHP 8.1.2

alecmuffett commented 10 months ago

So a WPError got passed into a routine which was expecting a User; possibly this is because the only user on the instance is the admin account and is not posting anything and/or is somehow not fully set up?

akirk commented 10 months ago

Interesting. Looks like this is then more a problem on the ActivityPub side of things. For the USER@DOMAIN above, is the USER an existing username on your site? cc @pfefferle

alecmuffett commented 10 months ago

Okay... so...

I have 2x WP instances: my blog, and a dedicated "friends plugin" aggregator, which is the one we are talking about here.

On that instance, I have ActivityPub Enable Blog set — in the expectation that the aggregator will never "post" anything - and I have put a token/name into the box provided, in the expectation that that would propagate. For the record (trying to keep this away from casual scrapers rather than human beings) the ID is @foo@foo.alecmuffett.com where foo=='elsewhere'

I also don't have Enable Authors set, which I presume is why when I did my webfinger test against the administrator, the webfinger failed against the admin-username for the wp-instance. My bad for reporting that / forgetting that the admin user is not enabled. Webfinger of the above-cited ID, seems to work reasonably.

There are ~120 subscriptions on the aggregator, and only a mere handful of them are updating, and of those most are updating once per day. I can't easily/clearly correlate which of them are RSS vs: ActivityPub subscriptions - and for some reason RSS appears to be the default even/if/when I subscribe to a Mastodon user using the Bookmarklet when visiting their page.

alecmuffett commented 10 months ago

Aside: maybe I should log a request for the Users page to enumerate which types of feed are enabled for each user, in a concise fashion?

akirk commented 10 months ago

If you install the Friends debugger, there is a "Feed Log" at wp-admin/admin.php?page=friends-last-log which might be helpful but probably it's easier to download the OPML file from the Friends Settings page to get that list:

Screenshot 2023-11-15 at 21 24 44
akirk commented 10 months ago

Trying to grasp what you wrote, I realize a better tool for double checking feeds across users would help you and be useful in general. I'll think of something and hope to provide that soon.

alecmuffett commented 10 months ago

Regarding the feed log: I found it referenced in the PHP and spent 20 minutes a couple of nights ago attempting to guess the URL. I couldn't find it in the documentation, perhaps I should have looked at the dashboard more carefully.

akirk commented 10 months ago

The Debug: Feed log is linked from the sidebar:

Screenshot 2023-11-15 at 21 43 16

Maybe you found this Feed Log bit in the source?

Screenshot 2023-11-15 at 21 44 29
alecmuffett commented 10 months ago

I see different:

Screenshot 2023-11-15 at 21 00 50 Screenshot 2023-11-15 at 21 01 14
alecmuffett commented 10 months ago

Here's a feed for 404 Media, which Friends has not updated since November 9th when I added it, but that doesn't match reality.

Screenshot 2023-11-15 at 21 04 50 Screenshot 2023-11-15 at 21 05 02
alecmuffett commented 10 months ago

I know something has changed with respect to user handling, so is it correct for ewadmin to be the post owner?

alecmuffett commented 10 months ago

Okay, so I accessed wp-admin/admin.php?page=friends-last-log and it says:

Feed Log
No active feeds found.

...which is worrying.

akirk commented 9 months ago

Could you try to just go into one of the friends and check if it really is the case, and if no, try to activate the feed?

activate-feed