[wp-trac] [WordPress Trac] #46313: WordPress 5.1 and $themes backward compatibility break-ish
WordPress Trac
noreply at wordpress.org
Fri Feb 22 10:54:28 UTC 2019
#46313: WordPress 5.1 and $themes backward compatibility break-ish
--------------------------+-----------------------------
Reporter: flexithemes | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 5.1
Severity: critical | Keywords:
Focuses: |
--------------------------+-----------------------------
First of all, thank you for maintaining WordPress and making it awesome.
That said, WordPress 5.1 introduced what I consider a backward
compatibility break, which has broken all 2,200+ of our WordPress themes.
The issue is with the $theme variable used in the themes. Seems that
WordPress will use that variable in the core code from this version
onward.
Therefore, this global variable produces null:
{{{#!php
<?php
global $theme;
}}}
And when reference through:
{{{#!php
<?php
$theme->hook('meta');
}}}
The result is a fatal error message now, when things were working
perfectly in 5.0 and previous.
Steps to replicate are simple:
1. Install any of our [https://flexithemes.com themes] on WordPress 5.1
2. After activating, check the front end of the site.
3. You'll see an error message like:
Fatal error: Call to a member function hook() on null in wp-
content/themes/Teva/header.php on line 6
If you want to try that specific theme (i.e. Teva), I've attached it to
this ticket.
Expected result: theme working as before
Server environment: PHP 7, LAMP ... I think it would repeatable on any
server
Thoughts for discussion if that's allowed here... should the WordPress
core namespace its variables?
Should theme developers be namespacing variables? Beyond this
[https://make.wordpress.org/themes/2012/03/14/theme-frameworks-and-
namespacing-guidelines/ old guideline for namespacing], I haven't been
able to find anything else official.
The conclusion there was:
"So, bottom line, TL:DR: forked/derivative stand-alone Themes ARE required
to re-namespace; Themes that use framework libraries are NOT required to
re-namespace the framework library code."
Final miscellaneous note: I set the severity to "critical". I wasn't able
to find a definition in the
[https://make.wordpress.org/core/handbook/glossary/ glossary] (or anywhere
else) for what constitutes "critical", but since it's a fatal error so I
decided to go with it.
Thank you for your time!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46313>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list