? Success

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
14 Apr 2015

PR Summary

In display method of many backend controllers, we are having this code:

$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');

These two lines of code is used to set an error message to controller object and display to end-user if users try to edit a record by typing the link directly on browser.

The two lines of code can be replaced with just one line of code:

$this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');

This is more logic to me. There is no reason to set error message, then call a command to get the same error message to display.

I made change to few classes as a sample. If people think that this change is valid, I will do the same changes on other classes.

avatar joomdonation joomdonation - open - 14 Apr 2015
avatar joomla-cms-bot joomla-cms-bot - change - 14 Apr 2015
Labels Added: ?
avatar nueckman
nueckman - comment - 15 Apr 2015

Possible BC issue. Even if JControllerLegacy doesn't care about it's origin JObject, there might be third party code which counts on getError/s().

avatar joomdonation
joomdonation - comment - 15 Apr 2015

In theory, Yes, it might be BC issue. However, in reality, I don't think there will be any third party code which count on getError/s of these backend controllers.

avatar nueckman
nueckman - comment - 15 Apr 2015

B/C is not about guessing ;) I don't like it too, but it should be mentioned.

avatar Bakual
Bakual - comment - 15 Apr 2015

Since this PR deals with controllers of extensions, there is no B/C to keep in mind. That would only be the case if wtouch the library classes.
setError and getError is also already deprecated, so it is a good move to get rid of using them.

avatar joomdonation
joomdonation - comment - 15 Apr 2015

Thanks Thomas. So I am correct that I can do the same change for remaining controllers in backend?

avatar Bakual
Bakual - comment - 15 Apr 2015

Imho, it should be fine. But I don't know why it was done this way originally :smile:

avatar joomdonation
joomdonation - comment - 15 Apr 2015

Who know :D, sometime, we still see strange code like that in Joomla core. I will modify the remaining controllers and then PLT can decide to merge it or not.

avatar joomdonation
joomdonation - comment - 15 Apr 2015

OK. I completed the modification for all backend controllers. Hope it will get merged :).

avatar nueckman
nueckman - comment - 15 Apr 2015

To clarify: I'm not against this PR. But if have to disagree with @Bakual

That would only be the case if wtouch the library classes.

Of course libraries are the main suspects, but core elements like mandatory extensions have to take care of B/C too. Hard example: Let's rename a components view.

avatar Bakual
Bakual - comment - 15 Apr 2015

Of course libraries are the main suspects, but core elements like mandatory extensions have to take care of B/C too. Hard example: Let's rename a components view.

Renaming a view would actually be possible with proper redirects/alias in place. As long as it doesn't break a link. :smile:
Our B/C promise regarding API and code is only for the libraries. This is because those classes are intended to be extended by 3rd party extensions.
However the classes from the components are not meant to be extended or directly used by 3rd party extensions. We strongly discourage you from doing that. If you do, you're on your own.

That's why this PR is fine from a B/C point of view. It doesn't break anything.

avatar nueckman
nueckman - comment - 15 Apr 2015

Taking the discussion to the Mailinglist: https://groups.google.com/forum/#!topic/joomla-dev-cms/GTnqEDMgOwk

avatar zero-24 zero-24 - change - 29 Apr 2015
Category Administration Code style Components
avatar joomdonation joomdonation - close - 8 Dec 2015
avatar joomdonation joomdonation - change - 8 Dec 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-12-08 07:06:44
Closed_By joomdonation
avatar joomdonation joomdonation - close - 8 Dec 2015
avatar joomdonation joomdonation - head_ref_deleted - 19 Dec 2015

Add a Comment

Login with GitHub to post a comment