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

Use of WordPress 5.9.0 function in Thank with Google module causing error for older WordPress versions.

Open techanvil opened this issue 2 years ago • 2 comments

Bug Description

In the Thank with Google PHP module code, we are using the wp_get_sidebar function which was introduced in WordPress 5.9.0.

This is causing the site to be non-functional for pre-5.9.0 when Thank with Google is enabled.

Steps to reproduce

Using a pre-5.9.0 version of WordPress:

  1. Enable and set up the Thank with Google module.
  2. Upon refreshing the page the error will be shown as per the screenshot below.

Screenshots

image.png

With stack trace displayed via Query Monitor: image.png

Additional Context

  • WordPress Version: pre-5.9.0
  • PHP Version: any
  • OS: any
  • Browser: any
  • Plugin Version: 1.85.0
  • Device: any

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

Acceptance criteria

  • An alternative to the core wp_get_sidebar function should be used which works across all supported versions of WordPress

Implementation Brief

  • Add wp_get_sidebar into the BC_Functions compatibility class, copying the implementation from the core source https://developer.wordpress.org/reference/functions/wp_get_sidebar/#source
  • Update its usage to use the new BC_Functions::wp_get_sidebar method

Test Coverage

  • No changes needed

QA Brief

  • Follow the Steps to reproduce and verify the error no longer occurs.

Changelog entry

  • N/A

techanvil avatar Oct 18 '22 13:10 techanvil

IB :white_check_mark:

techanvil avatar Oct 18 '22 15:10 techanvil

QA Update: ✅

Verified:

  • Was able to replicate the issue with an older version of WP prior to 5.9.
  • When switched to develop branch the error no longer appears when connecting TwG.
  • Switched back to the latest version of WP and ensured that I could still connect TwG with no errors.

https://user-images.githubusercontent.com/73545194/196563760-c8dbdaaa-be2e-4868-ad50-88a5ca9291b0.mp4

wpdarren avatar Oct 18 '22 23:10 wpdarren