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

Potential fatal error when previewing Customizer drafts #8077

Closed
1 task
aaemnnosttv opened this issue Jan 12, 2024 · 2 comments
Closed
1 task

Potential fatal error when previewing Customizer drafts #8077

aaemnnosttv opened this issue Jan 12, 2024 · 2 comments
Labels
P1 Medium priority PHP Type: Bug Something isn't working

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Jan 12, 2024

Bug Description

The theme customizer provides the ability to preview drafts using a special URL. While previewing, it is possible for Site Kit to raise an error such as the one below

PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Google\\Site_Kit\\Core\\Util\\get_plugin_data() in /.../google-site-kit/includes/Core/Util/Auto_Updates.php:105
Stack trace:
#0 /.../google-site-kit/includes/Core/Util/Auto_Updates.php(56): Google\\Site_Kit\\Core\\Util\\Auto_Updates::sitekit_forced_autoupdates_status()
#1 /.../google-site-kit/includes/Core/Authentication/Authentication.php(902): Google\\Site_Kit\\Core\\Util\\Auto_Updates::is_plugin_autoupdates_enabled()
#2 /.../google-site-kit/includes/Core/Util/Method_Proxy_Trait.php(25): Google\\Site_Kit\\Core\\Authentication\\Authentication->inline_js_base_data()
#3 /.../example.com/public_html/...', referer: https://example.com/wp-admin/customize.php?return=%2Fwp-admin%2Fthemes.php

This is because the WP core function get_plugin_data is not loaded in this specific scenario.

Steps to reproduce

  1. Set up Site Kit
  2. Enable a theme that supports the customizer, e.g. Twenty Twenty
  3. Go into the customizer and make any change
  4. Click the cog next to Publish and choose Save Draft
  5. Follow the URL given to preview the draft
  6. See error

Screenshots

image image

Additional Context

Related support request
https://wordpress.org/support/topic/i-get-a-critical-error-but-only-through-customizer/


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

Acceptance criteria

  • No errors should be raised by Site Kit while previewing a customizer draft

Implementation Brief

  • Update Auto_Updates::sitekit_forced_autoupdates_status to conditionally load wp-admin/includes/plugin.php if the get_plugin_data does not exist prior to calling

Test Coverage

  • No changes necessary

QA Brief

  • Follow the "Steps to reproduce" in the issue description.
  • Verify that the reported error no longer occurs.

Changelog entry

  • Fix error when previewing Customizer drafts.
@aaemnnosttv aaemnnosttv added Type: Bug Something isn't working P1 Medium priority PHP labels Jan 12, 2024
@techanvil techanvil self-assigned this Jan 12, 2024
@techanvil
Copy link
Collaborator

IB ✅

@techanvil techanvil removed their assignment Jan 12, 2024
@nfmohit nfmohit self-assigned this Jan 16, 2024
@nfmohit nfmohit removed their assignment Jan 16, 2024
@10upsimon 10upsimon assigned 10upsimon and unassigned 10upsimon Jan 16, 2024
@techanvil techanvil self-assigned this Jan 16, 2024
techanvil added a commit that referenced this issue Jan 16, 2024
Fix bug causing fatal error in customizer draft
@techanvil techanvil removed their assignment Jan 16, 2024
@wpdarren wpdarren self-assigned this Jan 16, 2024
@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • Tested to ensure I could recreate the error message in the issue description on the latest release.
  • On the develop branch, I followed the steps to reproduce and the reported error no longer occurs.
Screenshots

image

image

@wpdarren wpdarren removed their assignment Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Medium priority PHP Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants