Gatsby-Source-Wordpress configuration - wordpress

Gatsby-Source-WordPress
Gatsby Develop
returns:
"The server response was "404 Not Found"
Running Gatsby default Starter
Fresh install of wordpress all on localhost.
wordpress is here: localhost/freshinstall
I see json data here: localhost/freshinstall/wp-json/
Permalinks in wordpress set to: Post Name
gatsby-source-wordpress is the only plugin installed in gatsby:
{
resolve: `gatsby-source-wordpress`,
options: {
// your wordpress source
baseUrl: `localhost/freshinstall`,
protocol: `http`,
hostingWPCOM: false,
useACF: true
}
},
Expecting to be able to access information in wordPress.
The following is what I see:
my-default-starter dk$ gatsby develop
success open and validate gatsby-configs - 0.067 s
success load plugins - 42.771 s
success onPreInit - 0.034 s
success initialize cache - 0.061 s
success copy gatsby files - 2.423 s
success onPreBootstrap - 0.052 s
Path: /freshinstall/wp-json
The server response was "404 Not Found"
ERROR
Plugin gatsby-source-wordpress returned an error Cannot read property 'data' of undefined
TypeError: Cannot read property 'data' of undefined
- fetch.js:134 fetch
[my-default-starter]/[gatsby-source-wordpress]/fetch.js:134:21
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
warn The gatsby-source-wordpress plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes - 1.840 s
success building schema - 1.270 s
success createPages - 0.007 s
success createPagesStatefully - 1.266 s
success onPreExtractQueries - 0.089 s
success update schema - 0.078 s
success extract queries from components - 25.299 s
success write out requires - 0.165 s
success write out redirect data - 0.044 s
success Build manifest and related icons - 0.402 s
success onPostBootstrap - 0.458 s
⠀
info bootstrap finished - 269.881 s
⠀
success Generating image thumbnails — 6/6 - 2.762 s
success run static queries - 3.311 s — 3/3 0.91 queries/second
success run page queries - 0.077 s — 5/5 93.18 queries/second
DONE Compiled successfully in 105741ms 3:25:50 PM
⠀
You can now view gatsby-starter-default in the browser.
⠀
http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use npm run build
⠀
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.

Turns out my own machine was messed up.
It took forever to resolve, what ultimately solved the issue was changing how apache was setup on the machine. The link localhost/domain wasn't literally what it was. I broke apache, broke mysql, then fixed both then had to change a port and finally it works like this now:
localhost:8888/domain
Everything in Gatsby-Source-WordPress worked after that.

I stumbled on this same problem and here are the things I did:
My MAMP settings had the default port as 80. Local Wordpress could be accessed through http://localhost. I reverted MAMP ports to default, so the local url became http://localhost:8888/your domain name if applied
I forced stop sqld which was running concurrently on my Mac.
I went to phpMyAdmin and disabled all the active plugins.
I went to wp-admin and reset permalinks to post name. That had already been set as post name, but still click the Save button anyway to commit the change.
Looking back, I have no idea what was the culprit, but hope this helps someone.

Hey your config should look like this but if not let me know and i'll fix :).
{
resolve: `gatsby-source-wordpress`,
options: {
baseUrl: process.env.API_URL,
protocol: process.env.API_PROTOCOL,
hostingWPCOM: false,
useACF: true,
includedRoutes: [
"**/categories",
"**/posts",
"**/pages",
"**/media",
"**/tags",
"**/taxonomies",
"**/users",
"**/menus",
"**/portfolio",
"**/services",
"**/qualifications",
"**/gallery",
"**/logo",
"**/location",
],
},
},
}

Related

Gatsby / WooCommerce not processing mediaItems

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

WooCommerce 302 redirect to homepage after checkout is finished

I have an unusual error I don't seem able to fix myself ... I have a WordPress website, with WooCommerce as shop-part of the site. Today I noticed, that after I make an order, (Select product > Add to cart > Proceed to Checkout ) after I fulfill the order-form, choose the payment and click "FINISH ORDER" ... I don't see the "Thank you for your order", with order details, but instead, I get automatically redirected to homepage via 302 redirection.
I tried to switch themes back to TwentySeventeen - not working.
I reverted .htaccess back to "original" WordPress one - not working.
I deleted quite a lot of the plugins website normaly uses - not working.
I removed whole CDN integration - not working.
For some unknown reason, "thank-you-page" redirects via 302 redirection back to homepage.
The order is processed and customers get e-mail notification properly, it's just that thank you page (where order details should be seen) isn't loaded.
I already checked this Stack question - but I don't have the "Force the HTTP after checkout" option within WooCommerce Dashboard.
You can see the "Network" part of Dev Tools here:
Image 1: https://prnt.sc/lnbqcs
Image 2: https://prnt.sc/lnbq5o
Image 3: https://prnt.sc/lnbqqj
This is the System report:
WC Version: 3.5.1
Log Directory Writable: ✔
WP Version: 4.9.8
WP Multisite: –
WP Memory Limit: 1 GB
WP Debug Mode: –
WP Cron: –
Language: sl_SI
External object cache: –
Server Environment
Server Info: Apache
PHP Version: 7.0.32
PHP Post Max Size: 64 MB
PHP Time Limit: 900
PHP Max Input Vars: 20000
cURL Version: 7.60.0
OpenSSL/1.0.2k
SUHOSIN Installed: –
MySQL Version: 10.0.37-MariaDB
Max Upload Size: 64 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
Please try to help me ... I'm stuck here for the past 3 hrs and didn't figure it out (today) ... Much appreciated!
Thank you,
T.

Google App Engine Flex: Wordpress Plugin's Read/Write File Permissions

We are trying to see if Google App Engine will be a good fit for our Wordpress Sites. I just ran into an issue with a plugin that needs to have a folder with read/write/execute permissions.
"All in One WP Migration is not able to create /app/wordpress/wp-content/plugins/all-in-one-wp-migration/storage folder. You will need to create this folder and grant it read/write/execute permissions (0777) for the All in One WP Migration plugin to function properly."
I noticed in order to upload media files, you need to activate the Google Cloud Storage plugin. So this takes care of that issue, but how should I handle plugins and other I/O?
I thought using Flex instead of Standard would fix this.
App.yaml
runtime: php
env: flex
beta_settings:
cloud_sql_instances: my-project:us-east4:test-instance
runtime_config:
document_root: wordpress
env_variables:
WHITELIST_FUNCTIONS: escapeshellarg,escapeshellcmd,exec,pclose,popen,shell_exec,phpversion,php_uname
php.ini
extension=bcmath.so
extension=gd.so
zend_extension=opcache.so
short_open_tag=On
google_app_engine.disable_readonly_filesystem = 1
EDIT:
I found something to put in app.yaml HOWEVER I don't know if this should be something on production
In the runtime_config I added
skip_lockdown_document_root: true
I'd like to know if this acceptable to put on a live site.
I also put:
handlers:
- url: /(.*\.(htm|html|css|js))$
static_files: wordpress/\1
upload: wordpress/.*\.(htm|html|css|js)$
application_readable: true
- url: /wp-content/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/\1
upload: wordpress/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /wp-includes/images/media/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/wp-includes/images/media/\1
upload: wordpress/wp-includes/images/media/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
If you want to use standard, there's the limitation that GAE apps can't write to the filesystem.
If the plugin requires to write to the filesystem, then you should use flex.
Even when using flex, whatever is written in the filesystem will not be persisted as the only current storage option is to create a ramdisk in the instance, but the data stored there is not shared among instances, and will be lost on instance death.
There seems to be some workaround to use GCSfuse to mount a somewhat persistent storage in GAE flex, but I would not suggest it as you would run into concurrent write issues.
To summarize, if you need to read and write data into a persistent storage shared between all the instances, GAE is not the solution for you. After all, the whole point of serverless is the idempotence of executions. If your app depends on locally stored files (as this Wordpress plugin seems to do), then the result of the execution will depend on what instance is handling the request.

Kong refuses to recognise custom plugin as enabled

I was developing a Custom plugin for Kong.
To start off I followed guidelines listed in this tutorial
http://streamdata.io/blog/developing-an-helloworld-kong-plugin/
Few changes that I made along the way were changing dependency in the rockspec file for "lrexlib-pcre" from version 2.8.0-1 to 2.7.2-1 due to compilation problems that I faced with 2.8.0-1 version.
Please note that I am working in the next branch. The master branch has version 2.7.2-1 listed.
The tutorial assumes Kong version 0.4.2-1 while I am working with Kong version 0.5.2-1.
I have listed my plugin in kong.yml. Last listed is helloworld plugin
plugins_available:
- ssl
- jwt
- acl
- cors
- oauth2
- tcp-log
- udp-log
- file-log
- http-log
- key-auth
- hmac-auth
- basic-auth
- ip-restriction
- mashape-analytics
- request-transformer
- response-transformer
- request-size-limiting
- rate-limiting
- response-ratelimiting
- helloworld
I have listed the helloworld files in rockspec file at the last.
["kong.plugins.helloworld.handler"] =
"kong/plugins/helloworld/handler.lua",
["kong.plugins.helloworld.access"] = "kong/plugins/helloworld/access.lua",
["kong.plugins.helloworld.schema"] = "kong/plugins/helloworld/schema.lua"
Compilation is successful but kong refuses to list helloworld plugin as available in the node. All other builtin plugins are shown as available in the server
I tried enabling the plugin anyway with mock api. It doesn't work as expected and trying to restart kong lists error
nginx: [error] [lua] init_by_lua:5: Startup error:
/usr/local/share/lua/5.1/kong.lua:82: You are using a plugin that has
not been enabled in the configuration: helloworld [INFO] dnsmasq
stopped [ERR] Could not start Kong
I know there were some breaking changes introduced in Kong version 0.5. I followed the changelog, but I found nothing that would help.
Am i missing a setting a configuration somewhere?
Any help would be appreciated.
Try the following in your kong.yml:
custom_plugins:
- helloworld
I fixed this issue by adding things in custom_plugins and lua_package_path.
Here are the steps to enable and use custom plugin in kong Env.
1 - Add custom plugin name in --- custom_plugins = hello-world
2 - Install hello-world plugin by using following steps ---
If you have source code of your plugin then move into it and execute the command --- "luarocks make"
it will install your plugin.
now you have to execute a command "make install-dev" make sure your plugin have makefile like as --
Once you execute this command "make install-dev". it will create lua file at a location something like that -
/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
just copy this path and add it into the kong configuration file in lua_package_path
Something like that --
lua_package_path=/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
Now you done your job.
Just start kong -- kong start --vv
You will see that the plugin loaded into kong plugin env.
#Enjoy

How to deploy WordPress site to Google App Engine with Codenvy?

I have a WordPress repository cloned to Codenvy and it runs normally when clicking the Codenvy's "Run Application" button. However, when trying to deploy the site to Google App Engine, it gives the following error:
Unable to update app: Error posting to URL:
https://appengine.google.com/api/appversion/getresourcelimits?app_id=WordPress&version=1& 400
Bad Request Client Error (400) The request is invalid for an unspecified reason.
The app.yaml file:
application: WordPress
version: 1
runtime: php
api_version: 1
handlers:
- url: dgdxdfgxdfgxdfgdrg.appspot.com
script: index.php
I would prefer to develop with Codenvy, but if that is impossible, what other cloud IDEs are an option?

Resources