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

Global Styles REST API endpoint: check custom CSS is included before attempting to validate #46561

Conversation

andrewserong
Copy link
Contributor

What?

Follow up to #46141 to make sure that $request['styles']['css'] is set before attempting to validate it.

Why?

Without an additional check, saving global styles without custom CSS values resulted in a PHP warning being thrown:

image

How?

Add an isset() check before attempting to validate the custom CSS in global styles.

Testing Instructions

  • In a blocks theme go to make an update to global styles without adding any custom CSS
  • Add custom CSS and ensure that the CSS saves
  • In both cases there shouldn't be any PHP warnings logged

@andrewserong andrewserong added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Dec 15, 2022
@andrewserong andrewserong self-assigned this Dec 15, 2022
Copy link
Contributor

@glendaviesnz glendaviesnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!

Tests well for me:

✅ In a blocks theme made an update to global styles without adding any custom CSS - saved without PHP warnings
✅ Added custom CSS - saved without PHP warnings

@glendaviesnz glendaviesnz added this to the Gutenberg 14.8 milestone Dec 15, 2022
@andrewserong andrewserong added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Dec 15, 2022
@andrewserong andrewserong enabled auto-merge (squash) December 15, 2022 03:46
@glendaviesnz
Copy link
Contributor

@ryanwelcher can we please get this one cherry-picked into the 14.8 release?

@andrewserong andrewserong merged commit 489d48a into trunk Dec 15, 2022
@andrewserong andrewserong deleted the fix/php-warning-when-saving-global-styles-without-custom-css branch December 15, 2022 04:02
dmsnell pushed a commit that referenced this pull request Dec 15, 2022
…attempting to validate (#46561)

* Global Styles REST API endpoint: check custom CSS is included before attempting to validate

* Fix linting issue
ryanwelcher pushed a commit that referenced this pull request Dec 20, 2022
…attempting to validate (#46561)

* Global Styles REST API endpoint: check custom CSS is included before attempting to validate

* Fix linting issue
@ryanwelcher
Copy link
Contributor

I just cherry-picked this PR to the release/14.8 branch to get it included in the next release: 6ce4f45

@ryanwelcher ryanwelcher removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants