Closed jamesozzie closed 3 years ago
I tested this with the plugin you suggested and was able to reproduce the issue on the setup screen. We should be able to improve the experience here:
I also tried testing activating the plugin after setting up Site Kit. For the existing implementation, I saw pulsating boxes that never filled in; in our newer data layer implementation (still in development), I actually see an error message: "Data error in Search Console / Page not found." which matches the "page not found" response you get when this type of plugin is installed. I'm less concerned about addressing this case, since it will probably be obvious to users why Site Kit stopped working.
Thanks @Hazlitte – a few points to address here:
edit
assets/js/components/setup/CompatibilityChecks/constants.js
and add a new constant:export const ERROR_API_ENABLED = 'check_api_enabled';
The error should be named in a way to indicate what is wrong (e.g. ERROR_INVALID_HOSTNAME
or ERROR_FETCH_FAIL
for those checks). So semantically we would want to throw the opposite "api disabled" error rather than "enabled". In this case, we don't really know if it is disabled or blocked for some other reason; maybe the site had an error, etc so we should make this more generic to indicate that the API is simply not available. Temporary or otherwise, this is a problem for Site Kit.
edit
assets/js/components/setup/CompatibilityChecks/checks.js
. Import the new constantERROR_API_ENABLED
and update thecheckHealthChecks
function so that thecatch()
conditionally outputs a different error if the response is a404
Similar to the first point, we should not scope this to a 404 error specifically. You're correct that we also want to account for the ERROR_FETCH_FAIL
case here but apart from the fetch being blocked completely (i.e. fetch
throws/catches) then any non-successful response should result in the API unavailable error.
Rather than checking the status, we should check if the caught error.code === 'fetch_error'
(note catch blocks should always reference an error
rather than an event
). If it does, then throw ERROR_FETCH_FAIL
, otherwise throw the API unavailable error since WP apiFetch
will throw for any non-successful response.
edit
assets/js/components/setup/CompatibilityChecks/index.js
and change the order of the checks array returned by thecreateCompatibilityChecks
function:
Good idea to use the existing call and make it the first one 👍
All-in-all, this is pretty close to ready, it just needs a few revisions 👍
IB updated
Thanks @Hazlitte – the IB is looking much better now, although it still references a 404 response in the second point.
I'll remove this for you since that seems to have been simply missed in the revision. Regarding the IB as a whole, we generally prefer the IB to be less copy-pasteable (if that makes sense). It reads a bit too much like a todo list rather than as an outline of the approach to use. It doesn't need to be rewritten, but please keep in mind for the future and of course let me know if you have any questions or ideas about IB writing 👍
I've updated your second point there accordingly, so this is good to go 👍
As for the estimate, 3 is generally what we use for the smallest issues since it also needs to account for CR + QA. In this case, I think we should allow a little more time for QA in particular since we might want to try different plugins/methods of blocking the REST API when testing, so I'm going to bump it up to a 7.
IB ✅
@felixarntz added this to the release since it's a very small change and I basically QA'd it during CR.
Verified:
@aaemnnosttv thanks for these super useful instructions!!
Bug Description
Some users have plugins enabled which disable the WP REST API. While in most cases these plugins disable for non authenticated users only there are some plugins that perform this across the board. When this is identified there could be a notice during the compatibility check to inform users of this incompatibility.
Example experience of trying to activate Site Kit with the REST API disable. The "Checking compatibility" bar remains in a loading stage:
Console errors below:
Additional Context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
assets/js/components/setup/CompatibilityChecks/constants.js
and add a new constant:export const ERROR_API_UNAVAILABLE = 'check_api_unavailable';
assets/js/components/setup/CompatibilityChecks/checks.js
. Import the new constantERROR_API_UNAVAILABLE
and update thecheckHealthChecks
function so that thecatch()
conditionally throws a different error depending on the response:error.code
isfetch_error
, then throwERROR_FETCH_FAIL
ERROR_API_UNAVAILABLE
assets/js/components/setup/CompatibilityChecks/CompatibilityErrorNotice.js
. Import the new constantERROR_API_UNAVAILABLE
and add a case to the CompatibilityErrorNotice function for the new error message: `case ERROR_API_UNAVAILABLE: return ({ __( 'Site Kit cannot access the WordPress REST API. Please ensure it is enabled on your site.', 'google-site-kit' ) }
assets/js/components/setup/CompatibilityChecks/index.js
and change the order of the checks array returned by thecreateCompatibilityChecks
function:return [ checkHostname, checkHealthChecks, registryCheckSetupTag( registry ), checkAMPConnectivity, checkWPVersion, ];
QA Brief
Install the Disable REST API for Real plugin (or any other plugin that disables the REST API)
Attempt Site Kit setup
See warning about REST API disabled
Now with the REST API disabling plugin deactivated, configure the
wp-json/*
requests to be blocked (e.g. using Chrome Network request blocking)Check the splash page again
You should now see an alternate message about the staging environment
Changelog entry