Performance 2 (libraries/legacy)#12220
Performance 2 (libraries/legacy)#12220mbabker merged 33 commits intojoomla:stagingfrom frankmayer:Performance_2
Conversation
|
Could you explain when '== 0' is oke and when it needs '=== 0' ? |
|
=== is more strict than ==, it will validate that something matches both the value and data type (so in that case 0 === '0' would fail but 0 == '0' is OK). It's useful with some of the string functions where you can have a boolean false and an integer zero return. With == the values are compared to represent the same thing but with === they aren't. |
| // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0), | ||
| // then remove the node from the list | ||
| if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) | ||
| if (!($result->parent_id == 0 || isset($this->_nodes[$result->parent_id]))) |
There was a problem hiding this comment.
Shouldn't this be === 0 ?
There was a problem hiding this comment.
I didn't strict type those comparisons where it was not clear if the value is really strict. In that case it could be an integer or a string with a number. So, not to break BC I left those alone.
There was a problem hiding this comment.
You could use (int) and them do the strict comparation .
There was a problem hiding this comment.
Yes, but they also do involve a lot more research. It's not always just doing some casting.
I thought that those kind of changes would/could be done later by me or someone else.
Don't these batches already have enough changes?
|
@sovainfo The main issue with echo (0 == 'asd') ? 'true' : 'false'; // trueWhich is just wrong. On the other hand you really need to be careful with echo (0 === '0') ? 'true' : 'false'; // false |
|
Thank you all for the feedback. For some reason thought that 'null' would never compare equal to anything, not even 'null'. Maybe that only applies to SQL, requiring you to use 'IS NULL'. Concerning values coming from the database, expect the driver to make sure the right datatype to be returned. Apparently it doesn't. |
- Codestyle
|
I have tested this item ✅ successfully on 0148c52 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12220. |
| public function isSSLConnection() | ||
| { | ||
| return (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || getenv('SSL_PROTOCOL_VERSION'); | ||
| return (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on')) || getenv('SSL_PROTOCOL_VERSION'); |
There was a problem hiding this comment.
Remove parentheses ($_SERVER['HTTPS'] === 'on')
|
|
||
| $ids = $this->input->post->get('cid', array(), 'array'); | ||
| $inc = ($this->getTask() == 'orderup') ? -1 : 1; | ||
| $inc = ($this->getTask() === 'orderup') ? -1 : 1; |
libraries/legacy/model/list.php
Outdated
| $input = $app->input; | ||
| $old_state = $app->getUserState($key); | ||
| $cur_state = (!is_null($old_state)) ? $old_state : $default; | ||
| $cur_state = ($old_state !== null) ? $old_state : $default; |
libraries/legacy/table/menu.php
Outdated
|
|
||
| // Verify that the default home menu set to "all" languages" is not unset | ||
| if ($this->home == '1' && $this->language == '*' && ($array['language'] != '*')) | ||
| if ($this->home == '1' && $this->language === '*' && ($array['language'] != '*')) |
|
I have tested this item ✅ successfully on 0148c52 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12220. |
libraries/legacy/table/menu.php
Outdated
| { | ||
| // Verify that the default home menu is not unset | ||
| if ($this->home == '1' && $this->language == '*' && ($array['home'] == '0')) | ||
| if ($this->home == '1' && $this->language === '*' && ($array['home'] == '0')) |
|
I have tested this item ✅ successfully on 0148c52 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12220. |
|
I have tested this item ✅ successfully on 0148c52 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12220. |
|
RTC please, thank you |
|
RTC after two successful tests. |
|
Thanks for Hint, @frankmayer |
|
Merge pls? |
# Conflicts: # libraries/legacy/categories/categories.php # libraries/loader.php # libraries/src/Joomla/CMS/Controller/Controller.php # libraries/src/Joomla/CMS/Controller/Form.php # libraries/src/Joomla/CMS/Model/Model.php
* staging: (274 commits) Add JCryptCipherSodium to support libsodium (joomla#16754) Performance 2 (libraries/legacy) (joomla#12220) Performance 6 (templates) (joomla#12233) Fixed typehint (joomla#16425) Fix for: Repeatable field is no longer rendered with Chosen layout (joomla#16471) Fix the path for the ajax-loader.gif (joomla#16701) Menu items list parent filter (joomla#17060) Text Filters layout (joomla#17113) mod_login showon option (joomla#17153) com_banners incorret tooltip (joomla#17157) fix joomla.content.options_default (joomla#17123) remove the never working limitstart call (joomla#17184) Update phpDocumentor build set 3.8.0 Dev State Prepare 3.7.4 Stable Release fixed a logic change in joomla#12294, thanks @Hoffi1 Update sv-SE.ini Update pt-BR.ini Update lv-LV.ini Update fa-IR.ini ...
[UPDATED (6.1.2017) - see second paragraph]
Performance (and a bit of cleanup) Batch #2
The changes in this batch are all in files under
libraries/legacy.This PR modifies code to be a bit more performant and also does some cleanup.
I have mostly done work on low hanging fruit. There are still other ways of improving, but whose involve more deep research in the code and probably more drastic changes in order to be implemented.
[Update 6.1.2017]
In order to lighten this PR up, I have introduced 6 sub-PRs, which are easier to digest and mostly with very specific changes. In order to continue with this one, those ones should be tested/reviewed/merged first. After that, I can resolve the conflicts and there should finally be only a few changes left.