wpengine / wp-graphql-content-blocks

Plugin that extends WPGraphQL to support querying (Gutenberg) Blocks as data
https://faustjs.org/docs/gutenberg/wp-graphql-content-blocks
GNU General Public License v2.0
111 stars 14 forks source link

Getting domdocument::loadHTML(): Argument #1 ($source) must not be empty when button is empty #315

Open Skatox opened 4 days ago

Skatox commented 4 days ago

If you do:

  1. Add a regular Gutenberg button without text, like dragging it from the left panel.
  2. Leave the button there and publish a new page.
  3. Query the page with Faust.js and get the Button attributes.

You'll get an internal server error saying that domdocument::loadHTML(): Argument #1 ($source) must not be empty when the button is empty. If you add some text to the button, the problem will disappear.

This is a problem if you rebuild multiple pages and one of them has an information skeleton without any values. It won't work.

justlevine commented 4 days ago

Not sure if it's preexisting or linked via one of our PRs, but I'm pretty sure I've addressed this upstream (assumed the issue was only in the branch) at https://github.com/rtCamp/wp-graphql-content-blocks/pull/31

Should have time to backport a fix this week 🤞

justlevine commented 20 hours ago

On second look, I'm unable to replicate this using the latest main (v4.3.0)

@Skatox would you be able to confirm what version of plugin you are using and provide a replicable test case?

Here's mine:

Post content:

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button"></a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

Query:

query TestButtons($uri: String!) {
  nodeByUri(uri:$uri){
    ... on NodeWithEditorBlocks {
      editorBlocks{
        __typename
        ... on CoreButtons {
          attributes {
            align
            anchor
            backgroundColor
            borderColor
            className
            cssClassName
            fontFamily
            fontSize
            gradient
            layout
            lock
            metadata
            style
          }
        }
        ... on CoreButton {
          attributes {
            anchor
            backgroundColor
            borderColor
            className
            cssClassName
            fontFamily
            fontSize
            gradient
            placeholder
            linkClassName
            linkTarget
            lock
            metadata
            placeholder
            rel
            style
            tagName
            text
            textAlign
            textColor
            title
            type
            url
            width
          }
        }
      }
    }
  }
}

Results:

image