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

Call to undefined function libxml_disable_entity_loader() with php 8 #162

Open
tedc opened this issue Nov 9, 2022 · 5 comments
Open

Call to undefined function libxml_disable_entity_loader() with php 8 #162

tedc opened this issue Nov 9, 2022 · 5 comments

Comments

@tedc
Copy link

tedc commented Nov 9, 2022

Hi, WP Graphql Gutenberg is returning this error, if I run php 8:

Internal Sever Error - Call to undefined function libxml_disable_entity_loader()

This is a big issue, libxml_disable_entity_loader() is strongly deprecated in php 8 and my hosting provider, Kinsta, is is abandoning support for php <8.

How can I solve?

@MKlblangenois
Copy link

👍

I'm in the same issue, changing PHP to version 8 throw me an error and I'm the same case as @tedc, All my site on Kinsta need to be updated to PHP 8.

In my case, somes update on the plugin has solved the issue.

Trying with wp-graphql-gutenberg@3.1.1 (not tried with @3.1.2, related to #153

➡️ On vendor package voku/simple_html_dom, this issue was fixed on original repo)

# /vender/voku/simple_html_dom/src/voku/helperHtmlDomParser.php
# line 303
- $disableEntityLoader = \libxml_disable_entity_loader(true);
+ if (\PHP_VERSION_ID < 80000) {
+    $disableEntityLoader = \libxml_disable_entity_loader(true);
+ }

# line 381
- \libxml_disable_entity_loader($disableEntityLoader);
+ if (\PHP_VERSION_ID < 80000 && isset($disableEntityLoader)) {
+    \libxml_disable_entity_loader($disableEntityLoader);
+ }
# /vender/voku/simple_html_dom/src/voku/XmlDomParser.php
# line 112
- $disableEntityLoader = \libxml_disable_entity_loader(true);
+ if (\PHP_VERSION_ID < 80000) {
+    $disableEntityLoader = \libxml_disable_entity_loader(true);
+ }

# line 175
- \libxml_disable_entity_loader($disableEntityLoader);
+ if (\PHP_VERSION_ID < 80000 && isset($disableEntityLoader)) {
+    \libxml_disable_entity_loader($disableEntityLoader);
+ }

In addition of that, plugin seems to return error when loadHtml($source) have an empty $source. To solve that, I've updated this file :

# /src/Blocks/Block.php
# Line 153
if ($result->isValid()) {
+ // Avoid error if innerHTML is empty
+ if (empty($data['innerHTML'])) {
+    return [
+      'attributes' => $attributes,
+      'type' => $type
+    ];
+ }

 return [
    'attributes' => array_merge(
       self::source_attributes(HtmlDomParser::str_get_html($data['innerHTML']), $type),
    $attributes
    ),
    'type' => $type
 ];
}

I hope this helps other people the time to have a plugin update

@jaredcbaum
Copy link

I am running Kinsta and PHP 8.0 and am encountering the same problem. On the latest graphql Gutenberg plugin version (0.4.1), I had to SSH into the wp-graphql-gutenberg plugin and navigate to the directory wp-graphql-gutenberg-develop/vender/voku/helper/HtmlDomParser.php and delete 2 lines of code that contained libxml_disable_entity_loader.

@MKlblangenois
Copy link

@pristas-peter @jasonbahl any update on this issue ?

@jaredcbaum
Copy link

jaredcbaum commented Dec 1, 2023

This should be considered as an alternative for those using javascript:
https://github.com/wpengine/faustjs

it uses wp-graphql-content-blocks under the hood instead of wp-graphql-gutenberg

@praburangki
Copy link

For those that is hosting this in kinsta, just contact the support team using the live chat. I just sent a screenshot and they fixed it. Not sure how but maybe there's some hosting configuration that they have to tweak.

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