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
107 stars 14 forks source link

v1.1.1 throwing error: Class "WPGraphQL\ContentBlocks\Utilities\WPGraphQLHelpers" not found #132

Closed cherrygot-personal closed 1 year ago

cherrygot-personal commented 1 year ago

This is the error message in my debug logs when I try consuming one of the blocks using graphql.

[18-Jul-2023 06:28:02 UTC] PHP Fatal error:  Uncaught Error: Class "WPGraphQL\ContentBlocks\Utilities\WPGraphQLHelpers" not found in /var/www/wordpress/web/app/mu-plugins/wp-graphql-content-blocks/includes/Registry/Registry.php:173

The problem: The /includes/utilities does not follow the PSR-4 standard and there the composer dump-autoload may have not produced a rule to resolve the Utilities in the namespaces.

Solution: As soon as I changed the utilities directory name to Utilities, made a autload dump, the error disappeared. I think you guys should look into that, just to you know check if there are any side-effects of this change. I'm surprised this issue has not been mentioned in the active set of issues.

cherrygot-personal commented 1 year ago

Here's how I'm fixing it at the moment.

"post-package-install": [
      "cd wordpress/web/app/mu-plugins/wp-graphql-content-blocks/; mv ./includes/utilities ./includes/Utilities; composer dump-autoload -o"
    ]
theodesp commented 1 year ago

Hey @CherryGot thank you very much for the report.

How did you install this plugin? Did you used the releases option? I'm just using the latest zip file and I don't see any errors when enabling debug mode and by inspecting the error.log.

We also run integration tests as well so we don't experience issues with PHP Fatal errors.

We will provide a fix just in case since there is a difference in the filename casing.

cherrygot-personal commented 1 year ago

I used composer to install the plugin because we are using it to manager all our plugins, like so, composer require wpengine/wp-graphql-content-blocks and it installed the v1.1.1 as I can see in the lock file.

Although, the documentation did not mention it, the composer require worked just fine. But yeah, maybe it's one of those things that it was never tested for.

Anyways, thanks for the considering the change, it'd be huge help.

theodesp commented 1 year ago

Hey @CherryGot we don't register the plugin in composer registry for now. Maybe thats the issue.

cherrygot-personal commented 1 year ago

Yeah, agree. We are not using the plugin from composer registry but with repositories field of composer.json, like so

"repositories": [
    {
      "type": "github",
      "url": "https://github.com/wpengine/wp-graphql-content-blocks.git"
    }
  ]
justlevine commented 1 year ago

@CherryGot we're installing wp-graphql-content-blocks as a vcs composer repository, and other than the silly backend warning (since the vendor files are not included locally) I'm not seeing any errors regarding WPGraphQLHelpers.

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/wpengine/wp-graphql-content-blocks.git"
  },
 ]

Could be that its type:github specific, or could be the fatal warning is only triggered sometimes (e.g. on specific blocks).

cherrygot-personal commented 1 year ago

The type:github can be a reason. But I guess my focus will be on "triggered sometimes". Yes, this happened only when I was trying to access the attributes of a paragraph block. Other times, it didn't throw any errors. Sorry, I should've mentioned it in the original comment.

Like

... on CoreParagraph {
    attributes {
        content
    }
}
justlevine commented 1 year ago

Just tested and debug.log is clean. Hopefully type:vcs will be a good workaround until the folder can get properly renamed 🤞

image
blakewilson commented 1 year ago

Wanted to follow up here that 1.1.3 has been released with the Utilities folder rename:

https://github.com/wpengine/wp-graphql-content-blocks/releases/tag/v1.1.3