frontity / wp-plugins

» Frontity - Create amazing sites using WordPress & React

Home Page:https://frontity.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Head tags plugin causes a critical error when using api

MarkHjorth opened this issue · comments

Trying to access the posts endpoint while having the 'REST API - Head Tags' plugin enabled will yield a Wordpress error message.

Tried to access posts endpoint:
https://markhjorth.com/wp-json/wp/v2/posts

Error message:
"There has been a critical error on your website."

Plugin version:
Version 1.1.3

Wordpress version:
Version 5.4.1

Yoast version:
Version 14.1

Stack trace:

Fatal error: Uncaught Error: Class 'DOMDocument' not found in /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php:155 Stack trace: #0 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php(133): Frontity_Headtags->parse('\n\t<!-- This sit...') #1 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php(100): Frontity_Headtags->compute_headtags(Array) #2 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/hooks/class-frontity-headtags-post-type-hooks.php(99): Frontity_Headtags->get_headtags('post_614', Array) #3 /var/www/markhjorth.com/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(458): Frontity_Headtags_Post_Type_Hooks->get_post_headtags(Array, 'head_tags', Object(WP_REST_Request), 'post') #4 /var/www/markhjorth.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1795): WP_REST_Controller->add_additional_fields_to_object(Array, Object(WP_RES in /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php on line 155

The above issue was solved by installing php-dom using
apt-get install php-dom

Now I run into this error:

Fatal error: Uncaught Error: Call to undefined function mb_convert_encoding() in /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php:156 Stack trace: #0 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php(133): Frontity_Headtags->parse('\n\t<!-- This sit...') #1 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php(100): Frontity_Headtags->compute_headtags(Array) #2 /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/hooks/class-frontity-headtags-post-type-hooks.php(99): Frontity_Headtags->get_headtags('post_614', Array) #3 /var/www/markhjorth.com/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(458): Frontity_Headtags_Post_Type_Hooks->get_post_headtags(Array, 'head_tags', Object(WP_REST_Request), 'post') #4 /var/www/markhjorth.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1795): WP_REST_Controller->add_additional_fields_to_object(A in /var/www/markhjorth.com/wp-content/plugins/rest-api-head-tags/includes/class-frontity-headtags.php on line 156

And that issue was solved by installing mbstring using
apt-get install php7.0-mbstring

Hey, @MarkHjorth, thanks for opening the issue!

Yes, the package depends on the php DOM library and it looks like not all php servers include it by default, so it would be a good idea to metion the requisites somewhere in the documentation.

Anyway, I'm glad you solved it by your own. 😊

I'm going to close the issue. If you have more questions or need help you can write in the Frontity community.

@DAreRodz can you inform about this problem to the documentation team? Or maybe we should switch to something that doesn't have any dependencies, like https://simplehtmldom.sourceforge.io/?

I would prefer to use a standard library, and also it is supposed to be included in PHP by default, but it isn't... 🤷 Yeah, maybe it's a good idea to add a different library in our code.

Well, @juanmaguitar, @mburridge I guess we should add the PHP dependencies for the Head Tags plugin in our documentation, right? What do you think?

PR created w/ this info → frontity/docs#68

Great! Thanks @juanmaguitar. 😄

Shouldn't we add this to the plugin description as well? https://wordpress.org/plugins/rest-api-head-tags/

I can add it to the plugin, @luisherranz.

And I can take care of upload the docs to the WP repository.