site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

User is not able to set up analytics if Query Monitor plugin is active and PHP version is 8.2 or 8.3

Open mohitwp opened this issue 2 years ago • 4 comments

Bug Description

If Query monitor plugin is active on site having PHP v8.2. In this case user is redirecting to 404 page on step 4 of analytics setup and not able to connect analytics. On refreshing the page user is redirecting to SK dashboard and on clicking analytics 'Complete Setup' button user is getting ' The response is not a valid JSON response' error. Note - This issue is reproducible only if site have Query monitor plugin active and PHP version is 8.2

Steps to reproduce

  1. Create a site using PHP v8.2.
  2. Install and activate Query monitor plugin.
  3. Set up SK with Analytics.
  4. On step 4 user will navigate to 404 page.
  5. Refresh page.
  6. Site kit Dashboard will appear.
  7. Click on complete setup button for analytics.
  8. See JSON error. Note : User also navigate to 404 page after 3rd step if user set up Site kit without Analytics. But, in this case set up gets complete which is not happening in case of analytics.

Screenshots

image

image

https://github.com/google/site-kit-wp/assets/94359491/19a0e992-2411-4572-bd05-a57c4335a00a

Additional Context

  • PHP Version: 8.2
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: []
  • Device: [e.g. iPhone6]

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

mohitwp avatar Nov 09 '23 07:11 mohitwp

@mohitwp @wpdarren I am also running into issues with this particular setup. In my case, I am getting a 500 internal server error message after step 4:

image

I then run into invalid JSON response error messages when trying to complete the Analytics setup:

image

This is on an InstaWP fresh site with PHP 8.2 WordPress 6.4 and just the Query Monitor and Site Kit plugins active.

adamdunnage avatar Nov 09 '23 08:11 adamdunnage

After closer investigation, this issue is not specific to Analytics, it only seems to create a problem with Analytics.

The issue is due to deprecation notices which are being raised by code in the api-client-services package, like this:

Creation of dynamic property Google\\Site_Kit_Dependencies\\Google\\Service\\SearchConsole::$serviceName is deprecated

When Query Monitor is active, it reports these in the form of added response headers which includes a compressed stack trace. The problem is that there is a limit to the size of response headers that can be processed. Nginx will fail with a 502 Bad Gateway error for example when the response headers are too large. So any requests to the Google API which raise enough of these deprecation notices can exceed the allowed limit and cause the request to fail.

It is possible to work around this with an added filter to have Query Monitor ignore deprecated notices from Site Kit like so:

add_filter( 'qm/collect/php_error_levels', function( $levels ) {
	$levels['plugin']['google-site-kit'] = ( E_ALL & ~E_DEPRECATED );
	return $levels;
} );

More information about silencing errors in Query Monitor here.

Of course this is not really a solution, but the issue is one that we need to update the client services library to fix it and newer versions of the library require a minimum of PHP 7.4 which is higher than our current minimum supported version. We're already planning on raising our minimum version for this reason but don't have a specific date set yet. It also seems that upgrading to the latest version of the library wouldn't fix this either as many instances of this deprecated usage are still present in the package.

I've opened an issue on the package's repository to address this.

aaemnnosttv avatar Nov 10 '23 17:11 aaemnnosttv

Update : Getting same issue if PHP version is 8.3 and query monitor is active. If user install and active query monitor after set up of analytics then GA4 widgets display errors.

image

mohitwp avatar Feb 29 '24 11:02 mohitwp

Related: https://github.com/google/site-kit-wp/issues/8331.

archon810 avatar Mar 23 '24 07:03 archon810