-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.2] com_users: Simplifying empty check in login layout #41677
Conversation
if you look in the history you will see that it was deliberately changed from what you are proposing to what it is now |
The PR in question is #9896. Even looking at the PR, I can't understand why this was merged. Regardless of that, the browser in question is EOL and not supported by us anymore. I still think that this PR is the right way to go. |
When reading that old PR‘s code changes I can’t see that it had any trim before. It was comparing the complete unmodified string. So this PR here is not a roll back of the changes from the other PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the code is to rule out strings which contains only spaces. For this case, the proposed code has the same result, is more effective and better readable.
@Hackwar If you want to make it work exactly the same way as the old code regarding other kinds of white space than a single space character, you could use a string with a single space as 2nd parameter for trim, then it would trim only space characters. Not sure if it needs that, but we would play safe and it still has all advantages of your code change. |
interesting your change changes the behavior more then I expected: https://3v4l.org/7LM6I (yours is $z) |
Hmm, the zero evaluates to false, too. Indeed a change. |
Seems I was not looking close enough.
This is why it is always important to look at why code was written the way that it was before changing it |
my suggestion is to move it to |
Yes, this "changes" behavior. It actually fixes it to be in line with what people expect. The goal is to only show the text when it contains anything. Right now it only removes spaces, but would keep a line break or tab and then show the text. Yes, it also hides it, when the content is only a |
This pull request has been automatically rebased to 5.1-dev. |
Seeing the logic comes back with the summary. However, it is not possible for me to perform a test. |
I have tested this item ✅ successfully on 7ca9182 " " (ASCII 32 (0x20)), an ordinary space. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41677. |
I have tested this item ✅ successfully on 7ca9182 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41677. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41677. |
This pull request has been automatically rebased to 5.2-dev. |
Thanks @Hackwar ! |
Summary of Changes
I fixed bugs in an old layout override and stumbled over this. This is a very complex way of checking if there is anything in that parameter. We could make it worse by using regex and maybe doing an !empty() check around all of this... Anyway, this check just tries to find out if the description parameter does contain anything of relevance. Relevant is everything that remains after removing spaces from beginning and end of the string, thus a trim() is enough.
Testing Instructions
Codereview
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed