? ? Pending

User tests: Successful: Unsuccessful:

avatar SharkyKZ
SharkyKZ
17 Jul 2020

Pull Request for Issue # .

Summary of Changes

Fixes an error on error page if an error occurs after after the template has been parsed (e.g. in a module).

Testing Instructions

Enable debug.
Edit some backend module file to cause an error. E.g. add foo() to administrator/modules/mod_menu/mod_menu.php.
Login to backend.

Actual result BEFORE applying this Pull Request

Error:

The 'atum' service key is already registered.

Expected result AFTER applying this Pull Request

Error:

Attempted to call function "foo" from the global namespace.

Documentation Changes Required

avatar SharkyKZ SharkyKZ - open - 17 Jul 2020
avatar SharkyKZ SharkyKZ - change - 17 Jul 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Jul 2020
Category Administration Templates (admin)
avatar alikon alikon - test_item - 18 Jul 2020 - Tested successfully
avatar alikon
alikon - comment - 18 Jul 2020

I have tested this item successfully on 3ddcf00


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30119.

avatar Bakual
Bakual - comment - 18 Jul 2020

Just thinking: Wouldn't it make more sense to change the register method itself, so it doesn't throw a RuntimeException if the service is already registered? That doesn't sound like an error condition to me, since actually the function did what it was asked to do, just already in an earlier call.

avatar SharkyKZ
SharkyKZ - comment - 18 Jul 2020

@Bakual the method already has an option for replacing existing service keys. But I don't see the point in re-registering it again here. And it's already done the same way in guest layout:

$htmlHelperRegistry = HTMLHelper::getServiceRegistry();
// We may have registered this trying to load the main login page - so check before registering again
if (!$htmlHelperRegistry->hasService('atum'))
{
$htmlHelperRegistry->register('atum', 'JHtmlAtum');
}

avatar Bakual
Bakual - comment - 18 Jul 2020

Yep, I saw the replacement argument, but replacement isn't exactly what we want. Replacement would be to register another class for an existing service, thus replacing the original one.
Imho if the service already exists and replacement isn't set, it could just return empty as there is nothing to do. It doesn't have to raise an exception.

avatar bonzani bonzani - test_item - 19 Jul 2020 - Tested successfully
avatar bonzani
bonzani - comment - 19 Jul 2020

I have tested this item successfully on 3ddcf00


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30119.

avatar SharkyKZ
SharkyKZ - comment - 19 Jul 2020

@Bakual You wouldn't know whether your class was registered or not. It's fine as it is. There are many issues with HTML registry but this isn't one.

avatar SharkyKZ SharkyKZ - change - 19 Jul 2020
Status Pending Ready to Commit
Labels Added: ?
avatar SharkyKZ
SharkyKZ - comment - 19 Jul 2020

RTC.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30119.

avatar Bakual
Bakual - comment - 19 Jul 2020

You wouldn't know whether your class was registered or not.

You don't know either with your code. You only know that a service with the name "atum" is registered, not if it is your class.
But I don't really care for now. It was just a thought how it could made easier for all potential instances.

avatar wilsonge
wilsonge - comment - 25 Jul 2020

The entire point is that it may not be your class. Some services that aren’t protected may be overloaded.

avatar wilsonge wilsonge - change - 25 Jul 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-07-25 18:30:21
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 25 Jul 2020
avatar wilsonge wilsonge - merge - 25 Jul 2020
avatar wilsonge
wilsonge - comment - 25 Jul 2020

Thanks!

Add a Comment

Login with GitHub to post a comment