Call the JHtml class in a case sensitive manner
echo JHTML::_( 'form.token' );
and
echo JHtml::_( 'form.token' );
Class is loaded in both cases
Class is loaded only as JHtml but no more as JHTML throwing an error
Labels |
Added:
?
|
This caused a B/C break in several extension still using JHTML flavor to call that class
JHTML
has been the incorrect way to call the class name for quite some time (since at least 2.5.0 the class has been named as JHtml
and in an autoloaded path). In fact you can only use the full uppercase variant if something else has already loaded it into the system either with a manual include or the correctly cased JHtml
.
The problem is the autoloader is case sensitive, as is the case with most autoloaders (PHP itself could care less about the casing). The autoloader would never be able to parse the string JHTML
and autoload the correct file because of how it processes camel casing.
Is there some solutions to avoid a B/C break or all those extensions using JHTML will require a mandatory update?
Revert the namespacing PR and force a hard B/C break at 4.0. Literally the only option if you want to account for everyone who has been Doing It Wrong™. You can't alias a single class name with multiple casing variants, PHP considers the class already declared and has an issue with it.
I did some digging. Between 1.5 and 1.6 is when the casing changed. And at some point in 1.7 (before 2.5) is when the autoloader was added. So the all uppercase variants haven't been "right" for years, but if you were either making a call after manually including the class or made a call after something else had loaded JHtml into memory then that's why the full uppercase variation works.
You right... but definitely what's the planned answer?
Category | ⇒ | Code style |
Status | New | ⇒ | Discussion |
this is surely ok for J4.0
but for J3.8 too ?
now 50% or more of current version of extensions is using JHTML in some of their files or everywhere
and for extensions that have been updated
probably there are custom templates that are using JHTML
I'm going to make a pr with this variant in the next days. Glad we found it.
Good shout. I've seen hundreds of users on JSE defining this class in uppercase.
As a side note, the same issue could happen with JURI/JUri
Is it the same with getDBO/getDbo?
I dont think that's the case for getDBO/getDbo, it's a function call not a class name managed by the autoloader
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-09-02 09:26:47 |
Closed_By | ⇒ | franz-wohlkoenig |
Closed_Date | 2017-09-02 09:26:47 | ⇒ | 2017-09-02 09:26:48 |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
closed as havin Pull Request #17834
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17804
@laoneo This is probably namespacing issue.