Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Fatal error: must be of type Countable #258

Closed
bekopharm opened this issue Feb 23, 2022 · 6 comments
Closed

Fatal error: must be of type Countable #258

bekopharm opened this issue Feb 23, 2022 · 6 comments
Labels

Comments

@bekopharm
Copy link

Semantic-Linkbacks 3.11.0
Wordpress 5.8.3
PHP 8.0

A Webmention didn't make it due to an Fatal Error at this line:

PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($item) must be of type Countable|array

For unknown reasons $item was undefined.

The Webmention in question was https://php.microformats.io/?url=https%3A%2F%2Finhji.de%2Fnotes%2F1644845272

I added this little hack to wp-content/plugins/semantic-linkbacks/includes/class-linkbacks-mf2-handler.php:

        public static function flatten_microformats( $item ) {
                $flat = array();
                if(!$item) {
                        return $flat;
                }
                if ( 1 === count( $item ) ) {

And pulled it in manually via wp-json/webmention/1.0/endpoint. The Webmention is now live.

@pfefferle
Copy link
Owner

pfefferle commented May 24, 2022

Would you like to make a PR?

@lordmatt
Copy link

Can confirm. Some static functions return null when they give up but nulls are not checked for. I used a similar hack.

@bekopharm
Copy link
Author

Don't have a dev system set up and I'm unaware of side effects so I don't feel comfortable with a PR at this point.

@pfefferle
Copy link
Owner

No problem!

@stale
Copy link

stale bot commented Sep 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 25, 2022
@stale stale bot closed this as completed Oct 2, 2022
@bekopharm
Copy link
Author

Good thing I noted this down. Some update removed my hack again and it started failing again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants