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

Use of undefined constants STYLESHEETPATH and TEMPLATEPATH PHP warning #26359

Closed
david-binda opened this issue Oct 21, 2020 · 4 comments · Fixed by #28942
Closed

Use of undefined constants STYLESHEETPATH and TEMPLATEPATH PHP warning #26359

david-binda opened this issue Oct 21, 2020 · 4 comments · Fixed by #28942
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Dev Ready for, and needs developer efforts [Type] Bug An existing feature does not function as intended

Comments

@david-binda
Copy link
Contributor

Describe the bug
The Gutenberg's Global Styles feature is throwing following PHP warnings in curtomizer context on some requests:

Warning: Use of undefined constant STYLESHEETPATH - assumed 'STYLESHEETPATH' (this will throw an Error in a future version of PHP) in /srv/www/wordpress-default/public_html/wp-includes/template.php on line 663
Warning: Use of undefined constant TEMPLATEPATH - assumed 'TEMPLATEPATH' (this will throw an Error in a future version of PHP) in /srv/www/wordpress-default/public_html/wp-includes/template.php on line 666

This is caused by the call of the locate_template in

return is_readable( locate_template( 'experimental-theme.json' ) );

which is being hooked to the wp_enqueue_scripts action via some function chain in

add_action( 'wp_enqueue_scripts', 'gutenberg_experimental_global_styles_enqueue_assets' );

However, the WordPress customizer may call the wp_enqueue_scripts prior setting up a theme and defining the templating constants ( STYLESHEETPATH, TEMPLATEPATH ) in case a user w/o necessary capabilities for switching theme is attempting to review a customizer changeset. Customizer is hooking the setup_theme action and eventually dying. See:

https://github.com/WordPress/WordPress/blob/a7d6e929c96f2d1e6e0307e781d36c338b8bf877/wp-includes/class-wp-customize-manager.php#L366 and https://github.com/WordPress/WordPress/blob/a7d6e929c96f2d1e6e0307e781d36c338b8bf877/wp-includes/class-wp-customize-manager.php#L505

To reproduce
Steps to reproduce the behavior:

  1. Go to a customizer screen of your site under a user account with all appropriate caps needed for making changes in customizer
  2. Make any changes ( does not really matter which ones ), but don't publish those
  3. Copy the customizer preview iframe URL ( should be something like: ?customize_changeset_uuid=c0af4551-5b8c-4260-ad4e-368af589c737&customize_theme=twentyseventeen&customize_messenger_channel=preview-0 )
  4. Open the copied URL while logged in as a subscriber (or any other user w/o switch_themes capability)
  5. Notice the PHP warning

Expected behavior
No PHP warning

Editor version (please complete the following information):

  • WordPress version: 5.5.1
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? "gutenberg plugin"
  • If the Gutenberg plugin is installed, which version is it? 920
@annezazu annezazu added [Feature] Templates API Related to API powering block template functionality in the Site Editor [Type] Bug An existing feature does not function as intended Customizer Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Dev Ready for, and needs developer efforts labels Oct 27, 2020
@gziolo gziolo removed the [Feature] Templates API Related to API powering block template functionality in the Site Editor label Nov 8, 2020
@ockham
Copy link
Contributor

ockham commented Nov 18, 2020

This might have been fixed by #27021. I'll defer to @Addison-Stavlo as to whether we can close this issue.

@Addison-Stavlo
Copy link
Contributor

I think this is unrelated. My change didn't touch the functions noted above, also I don't think the function I changed even existed 29 days ago.

is this still happening?

@oandregal
Copy link
Member

This was discussed in this thread and there's a path forward to fix it, in case anyone is interested in picking this up.

@oandregal
Copy link
Member

I couldn't repro this error. However, in #28942 we're replacing locate_template by something else, so it arguably fixes this.

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 Needs Dev Ready for, and needs developer efforts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants