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

Gatsby / WooCommerce not processing mediaItems #692

Open
Steppio opened this issue Jan 5, 2023 · 8 comments
Open

Gatsby / WooCommerce not processing mediaItems #692

Steppio opened this issue Jan 5, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@Steppio
Copy link

Steppio commented Jan 5, 2023

I'm having major problems trying to build a Gatsby / WooCommerce site - whenever wp-graphql-woocommerce is activated it simply will not process any media items, with this error:

--

gatsby-source-wordpress  Error category: undefined

Error:
  Internal server error

Debug message:
  in_array(): Argument #2 ($haystack) must be of type array, string given

Error path: mediaItems

info  gatsby-source-wordpress  GraphQL vars: {"first":100,"url":"http://178.62.90.26/graphql","in":["13"],"after":null}

--

Steps to reproduce:

I have created a completely fresh install of Wordpress (v6+) on a php8+ environment (Digital Ocean Wordpress 1 click install image)

https://marketplace.digitalocean.com/apps/wordpress

I open the console and finish the wordpress installation process

Next I install wp-graphql (latest master version) and run composer install in the directory, then activate the plugin

Next I install WooCommerce, run through the installation process and create a dummy product

Then I install WP-Gatsby (v2.3.3) and activate.

Next I install the latest version of wp-graphql-woocommerce (v12 master), upload the plugin and activate
I then change the permalink structure and check that the /graphql route is working - everything is fine

At this point I have a single dummy product, a single Hello World post with a featured image attached, and I have only the following plugins installed on the site:

WooCommerce (v7.2.2)

WP Gatsby (v2.3.3)

WP GraphQL (v1.13.7)

WPGraphQL WooCommerce (WooGraphQL) (v0.12.0)

I then clone this simple blog repo:
https://github.com/gatsbyjs/gatsby-starter-wordpress-blog.git

I run yarn install for dependencies.

I change my gatsby-config to point toward my server and add an option in gatsby-source-wordpress to ignore ShippingMethod (or else it takes forever to build), and add some debugging in to help define the issue:

--

resolve: 'gatsby-source-wordpress',
      
options: {
 url: process.env.WPGRAPHQL_URL || 'http://178.62.90.26/graphql',      
 
type: {
          
 ShippingMethod: {
  exclude: true
 },
},
debug: {
 graphql: {
   showQueryVarsOnError: true,
   showQueryOnError: true,
   onlyReportCriticalErrors: false,
 },          
},          
},

--

I then add define( 'GRAPHQL_DEBUG', true ); to my wp-config.php and restart Apache just to be sure

I then run gatsby develop and get the error I mentioned earlier when it gets to MediaItems:

--

gatsby-source-wordpress  Error category: undefined

Error:
  Internal server error
 
Debug message:
  in_array(): Argument #2 ($haystack) must be of type array, string given
 
Error path: mediaItems

info  gatsby-source-wordpress  GraphQL vars: {"first":100,"url":"http://178.62.90.26/graphql","in":["13"],"after":null}

--

And it creates 0 MediaItem nodes:

no MediaItems processed

And in my debug.log it’s just this over and over again:

--

[05-Jan-2023 10:21:40 UTC] PHP Deprecated:  Function WPGraphQL\Connection\TermObjects::get_connection_args is <strong>deprecated</strong> since version 1.13.0! Use \WPGraphQL\Type\Connection\TermObjects::get_connection_args instead. in /var/www/html/wp-includes/functions.php on line 5379


[05-Jan-2023 10:21:40 UTC] PHP Deprecated:  Function WPGraphQL\Connection\Comments::get_connection_config is <strong>deprecated</strong> since version 1.13.0! Use \WPGraphQL\Type\Connection\Comments::get_connection_config instead. in /var/www/html/wp-includes/functions.php on line 5379

--

If I deactivate wp-graphql-woocommerce the image is processed absolutely fine and creates the one mediaItem node that I have:

MediaItems processed with wp-graphql-woocommerce disabled

I need the woocommerce aspect of things though so this isn’t a solution. It just seems to happen whenever wp-graphql-woocommerce is activated.

Any help with this would be hugely, hugely appreciated as I’ve been banging my head against a brick wall for a while now and I'm really starting to worry that this isn't going to work

I have tried the following versions of wp-graphql / wp-graphql-woocommerce

wp-graphql - v1.12.2, v1.12.3, v1.13.0, v1.13.4, v1.13.7

wp-graphql-woocommerce - v12, v11.2, v10.7

Node Versions - v16.11.1, v18.12.1

I've tried with both Digital Ocean and AWS Lightsail servers - same outcome

And it just never seems to process the mediaItems. The strangest thing is that this did work in September, however lately it just flatly refuses to process the images whilst wp-graphql-woocommerce is activated

@Jon-Hudak
Copy link

Jon-Hudak commented Jan 10, 2023

I'm also having issues with this. Works perfectly without WC plugin but as soon as I add it, it no longer sees any media items including pages, posts, and products. I'm running Wordpress through Local by Flywheel and the gatsby development server.

@Hazmatyre
Copy link

Hazmatyre commented Jan 11, 2023

I am having this issue as well, and can reproduce it easily on my machine with a fresh Gatsby V5 starter and a wordpress instance with one dummy product. As soon I enable WooCommerce I get the same error: in_array(): Argument #2 ($haystack) must be of type array, string given

I can query these featured images on wordpress' GraphQL client too no problem.

I'm not sure what combination of plugins in both gatsby and wordpress is considered stable, but if anyone has a working repo I would greatly appreciate it.

@Steppio
Copy link
Author

Steppio commented Jan 20, 2023

I'm also having issues with this. Works perfectly without WC plugin but as soon as I add it, it no longer sees any media items including pages, posts, and products. I'm running Wordpress through Local by Flywheel and the gatsby development server.

Hi Jon-Hudak - are you using a AWS / Digital Ocean server by any chance? I've tested on a brand spanking new install on both of these and it's the same issue - it just won't build the mediaItems nodes.

Today I'm going to try the same approach using a local server just to rule out the possibility of it being something on the AWS / Digital Ocean end

@kidunot89 kidunot89 added the bug Something isn't working label Jan 20, 2023
@kidunot89
Copy link
Member

kidunot89 commented Jan 20, 2023

@Steppio @Jon-Hudak @Hazmatyre Sorry for the delayed response, I'm not experienced with Gatsby and actively avoided using it for awhile now. I'll investigate more and see if I can get a solution pushed.

But please note, there is a chance the issue is with WP-Gatsby and not WooGraphQL.

@Steppio
Copy link
Author

Steppio commented Jan 21, 2023

Hi @kidunot89 - I've tried a huge variation of plugins versions etc, and last night I had a breakthrough - downgrading my version of PHP 8+ to 7.4 fixed the issue completely. Version 7.4 is no longer supported, but I can confirm it does work.

I will list out the WP / npm plugin versions I am using in a separate comment when I get back to my computer for future reference.

@Steppio
Copy link
Author

Steppio commented Jan 23, 2023

I can confirm that PHP 7.4 works with the following plugins:

Wordpress plugin versions

WPGraphQL WooCommerce (WooGraphQL)
Version 0.12.0

WP GraphQL
Version 1.13.7

WP Gatsby
Version 2.3.3

WooCommerce
Version 6.9.4

NPM versions:

@pasdo501/gatsby-source-woocommerce
^0.17.2

gatsby
^4.23.0,

gatsby-link
4.23.0,

gatsby-plugin-image
^2.23.0,

gatsby-plugin-manifest
^4.0.0,

gatsby-plugin-offline
^5.0.0,

gatsby-plugin-sitemap
^5.12.1,

gatsby-source-filesystem
^4.23.0

gatsby-source-wordpress
^7.4.1

react
^18.1.0

react-dom
^18.1.0

If anyone is stuck on the same issue and needs any more information please let me know, thanks.

@kidunot89
Copy link
Member

@Steppio I patched the errors you were receive here, and the solution is available on the develop branch right now and will be in the next release.

@kidunot89
Copy link
Member

kidunot89 commented Feb 7, 2023

@Steppio @Hazmatyre @Jon-Hudak Can anyone confirm if this issue has been resolve in v0.12.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants