Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Head tags plugin causes a critical error when using api #35

Closed
MarkHjorth opened this issue May 17, 2020 · 9 comments
Closed

Head tags plugin causes a critical error when using api #35

MarkHjorth opened this issue May 17, 2020 · 9 comments

Comments

@MarkHjorth
Copy link

MarkHjorth commented May 17, 2020

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

@MarkHjorth
Copy link
Author

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

@MarkHjorth
Copy link
Author

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

@DAreRodz
Copy link
Member

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.

@luisherranz
Copy link
Member

@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/?

@DAreRodz
Copy link
Member

DAreRodz commented May 21, 2020

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?

@juanmaguitar
Copy link
Member

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

@DAreRodz
Copy link
Member

Great! Thanks @juanmaguitar. 😄

@luisherranz
Copy link
Member

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

@DAreRodz
Copy link
Member

DAreRodz commented May 22, 2020

I can add it to the plugin, @luisherranz.

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

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

No branches or pull requests

4 participants