? ? Pending

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
21 Nov 2020

Currently, the language file lib_joomla.ini contains several strings which reference a PHP method. There are several issues with that:

  • The method name should not be translated, but is part of the language string.
  • The method is written in a format Classname: :Functionname (with a space between the : :). This isn't how a method is properly written.
  • The classname references the old JFoo class names, not the new namespaced ones.
  • The same message exists multiple times, just for different classes/functions. This is redundant work for TTs and not reuseable.

Summary of Changes

I've started with the GET_NAME strings:
JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME="JApplication: :getName() : Can't get or parse class name."
JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME="JController: :getName() : Can't get or parse class name."
JLIB_APPLICATION_ERROR_MODEL_GET_NAME="JModel: :getName() : Can't get or parse class name."
JLIB_APPLICATION_ERROR_VIEW_GET_NAME="JView: :getName() : Can't get or parse class name."

I have replaced them with a new generic one:
JLIB_APPLICATION_ERROR_GET_NAME="%s: Can't get or parse class name."

I've changed all calling places so the current method name (__METHOD__) is passed as a variable.

JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME actually wasn't used anymore.
I also removed the string JLIB_APPLICATION_ERROR_VIEW_GET_NAME_SUBSTRING which also isn't used anymore in J4.

Testing Instructions

This should work with code review as there actually should be no way with a properly written extension to trigger this error.
If someone knows how to trigger the error, feel free to share.

Actual result BEFORE applying this Pull Request

Error message would be for example
JController: :getName() : Can't get or parse class name.

Expected result AFTER applying this Pull Request

Error message would be for example
Joomla\CMS\MVC\Controller\FormController::__construct: Can't get or parse class name.

Documentation Changes Required

None

avatar Bakual Bakual - open - 21 Nov 2020
avatar Bakual Bakual - change - 21 Nov 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Nov 2020
Category Administration Language & Strings Libraries
avatar Bakual
Bakual - comment - 21 Nov 2020

If this PR is accepted, I will do more of the same kind with other instances of the same issue.

avatar brianteeman
brianteeman - comment - 21 Nov 2020

Other than thinking it might be better as JLIB_APPLICATION_ERROR_GET_NAME ie remove the word GENERIC it all seems a good idea to me

avatar Bakual Bakual - change - 21 Nov 2020
Labels Added: ? ?
avatar Bakual
Bakual - comment - 21 Nov 2020

You're right, the GENERIC part isn't really needed. I've changed it.

avatar Bakual Bakual - change - 21 Nov 2020
The description was changed
avatar Bakual Bakual - edited - 21 Nov 2020
avatar ceford ceford - test_item - 22 Nov 2020 - Tested successfully
avatar ceford
ceford - comment - 22 Nov 2020

I have tested this item successfully on 6f37bc4

I applied the patch and looked through the code and it looks good. I also inserted a simple call to enqueueMessage and (separately) to throw new exception in the article display HtmlView.php file. That gave the expected behaviour - a warning message and a fatal error message.

Code $app->enqueueMessage(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 'warning');

Result Joomla\Component\Content\Site\View\Article\HtmlView::display: Can't get or parse class name.

Code throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500);

Result 500 Joomla\Component\Content\Site\View\Article\HtmlView::display: Can't get or parse class name.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31456.
avatar wilsonge wilsonge - change - 24 Nov 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-11-24 02:47:43
Closed_By wilsonge
avatar wilsonge wilsonge - close - 24 Nov 2020
avatar wilsonge wilsonge - merge - 24 Nov 2020
avatar wilsonge
wilsonge - comment - 24 Nov 2020

LGTM Thanks!

avatar HLeithner
HLeithner - comment - 25 Nov 2020

@wilsonge thats a b/c break

avatar Bakual
Bakual - comment - 25 Nov 2020

@HLeithner Yes it is, and an allowed one for J4.0.

Add a Comment

Login with GitHub to post a comment