Opened 6 weeks ago
Last modified 6 weeks ago
#65412 new defect (bug)
Namespace collision in WP 7.0 Font Library query var overrides custom router page_slug
| Reported by: | sgovaerts | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Query | Version: | 7.0 |
| Severity: | normal | Keywords: | dev-feedback 2nd-opinion |
| Cc: | Focuses: |
Description (last modified by )
After upgrading to WordPress 7.0, websites utilizing a custom routing system or custom rewrite rules that register and use the query variable page_slug experience breaking behavior.
With the introduction of the new Font Library feature in WP 7.0, the core now internally claims and heavily uses the page_slug query/global variable. If a custom route is accessed where our custom page_slug is intended to be empty or null (e.g., viewing a main archive/overview page), WordPress 7.0 forcefully overwrites this empty variable with the string 'font-library'.
Steps to Reproduce
- Register a custom route via a routing system or standard
add_rewrite_rule()that captures a variable namedpage_slug. - Navigate to a URL corresponding to the route where the
page_slugparameter should remain empty/unset (e.g.,mysite.com/department/service/docs). - Dump the variable inside the loaded template file using
get_query_var('page_slug')or inspection of global arguments.
Expected Behavior
get_query_var('page_slug') should return null, false, or an empty string, allowing the template logic to process the page as a root/archive page.
Actual Behavior
The variable is hijacked by the WP 7.0 core. get_query_var('page_slug') unexpectedly returns the string 'font-library'.
This causes severe backward compatibility issues. Template logic checking if ( !empty($page_slug) ) gets triggered falsely. Functions like get_page_by_path('font-library') are subsequently executed, returning 0 results and leading to blank pages (broken template loops) for existing custom implementations.
Suggested Fix
The Font Library core feature should use a more strictly namespaced query variable (e.g., wp_font_page_slug or wp_font_library_slug) instead of the generic page_slug to maintain backward compatibility with existing custom themes, routers, and plugins that have been using this common variable name for years.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)