secure-blocks-for-gutenberg icon indicating copy to clipboard operation
secure-blocks-for-gutenberg copied to clipboard

php warning `DOMDocument::loadXML(): EntityRef: expecting ';' in Entity, line: 4`

Open paulkirspuu opened this issue 6 years ago • 6 comments

gutenberg setup: https://i.snag.gy/HUfCul.jpg

results in: php warning DOMDocument::loadXML(): EntityRef: expecting ';' in Entity, line: 4

how to proceed?

paulkirspuu avatar Feb 13 '19 15:02 paulkirspuu

@paulkirspuu were you able to set a breakpoint and inspect what the string contents is at the time this warning is thrown?

It doesn't look like @mattwatsoncodes is able to do much based on this vague issue report.

lkraav avatar Feb 25 '19 13:02 lkraav

Hmmm, unless things have changed @paulkirspuu the DOMDocument only used to parse the parent block, so the innerblock shouldn't be an issue.

I'll have to investigate how it's working now. As I say, things may very well have changed.

mattwatsoncodes avatar Feb 25 '19 13:02 mattwatsoncodes

Hi @mattwatsoncodes

Based on what I'm reading at https://stackoverflow.com/questions/9760208/php-domdocument-error-entity-nbsp-not-defined I think we should be using $dom->loadHTML(), instead of current https://github.com/mattwatsoncodes/secure-blocks-for-gutenberg/blob/13628f85f0c806f2427703cdf3a8d4c8891b3414/blocks/secure-block/php/class-secure-block.php#L94

$dom->loadXML() is generating thousands of PHP Warnings per day. Your thoughts?

lkraav avatar Jun 22 '20 12:06 lkraav

Hi @lkraav I no longer support this plugin, however the correct way to do things would be to use the pre_render_block hook, and just return false if the conditions are met.

The approach I previously used is completely the wrong one.

mattwatsoncodes avatar Jun 22 '20 12:06 mattwatsoncodes

Is there another plugin on the market? Block Context by @kasparsd doesn't have user roles implemented yet https://github.com/preseto/block-context/issues/3

lkraav avatar Jun 22 '20 12:06 lkraav

General learning: DomDocument also has problems with HTML5 tags https://stackoverflow.com/questions/6090667/php-domdocument-errors-warnings-on-html5-tags

Therefore it might be completely unsuitable for this type of HTML processing and an external library might have to be integrated.

lkraav avatar Jun 22 '20 12:06 lkraav