[wp-trac] [WordPress Trac] #59723: Pattern file containing PHP constant from theme causes fatal error on update to WordPress 6.4
WordPress Trac
noreply at wordpress.org
Tue Oct 24 20:40:35 UTC 2023
#59723: Pattern file containing PHP constant from theme causes fatal error on
update to WordPress 6.4
-----------------------------+-----------------------------
Reporter: fabiankaegy | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
I have a theme that sets up some PHP constants in its `functions.php`
file. These constants for example reference the dist directory of the
built assets.
{{{#!php
<?php
define( 'NAMESPACE_THEME_TEMPLATE_URL', get_template_directory_uri() );
define( 'NAMESPACE_THEME_DIST_URL', NAMESPACE_THEME_TEMPLATE_URL .
'/dist/' );
}}}
This theme then also contains some patterns in the `patterns` directory.
Some of these patterns reference one of the globals defined in the
`functions.php` file to load an image from the dist folder.
{{{#!php
<?php
<?php
/**
* Title: Hero - Default
* Slug: namespace/hero-default
* Categories: header
* Viewport Width: 500
*/
?>
<!-- wp:cover {"url":"<?php echo esc_url( NAMESPACE_THEME_DIST_URL .
'images/placeholder/pattern--no-text.jpg' );
?>","dimRatio":70,"minHeight":70,"minHeightUnit":"vh","contentPosition":"bottom
left","isDark":false,"align":"full"} -->
}}}
This works great when just using the site. But when installing WordPress
6.4 RC1 or RC2 via CLI the update appears to run through but when I try to
log into the Admin I get a blank white screen on the URL: `/wp-
admin/upgrade.php`
When I look at the `debug.log` file I get a fatal error saying that the
constant used in the pattern file isn't defined.
So it appears the patterns are getting loaded before the theme is loaded.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59723>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list