Performance 6 (templates)#12233
Performance 6 (templates)#12233mbabker merged 41 commits intojoomla:stagingfrom frankmayer:Performance_6
Conversation
|
|
||
|
|
||
| <?php if (($params->get('show_author')) or ($params->get('show_parent_category')) or ($params->get('show_category')) or ($params->get('show_create_date')) or ($params->get('show_modify_date')) or ($params->get('show_publish_date')) or ($params->get('show_hits'))) : ?> | ||
| <?php if ($params->get('show_author') || $params->get('show_parent_category') || $params->get('show_category') || $params->get('show_create_date') || $params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_hits')) : ?> |
There was a problem hiding this comment.
In template layout files (everything within the /tmpl/ folders) we prefer or and and over || and &&. So please leave those alone.
There was a problem hiding this comment.
Didn't know that. Why is this?
There was a problem hiding this comment.
It's easier to read for people (users) which aren't that familiar with PHP.
Same for the if (...) : ... endif instead of if (...) { ... }
There was a problem hiding this comment.
When did that become a thing? Because last I remember that's NOT in our codestyle rules or documented guidelines. Not to mention there are (mostly small) behavioral differences between $foo and $bar versus $foo && $bar.
There was a problem hiding this comment.
Is there some kind of system with those? I ask because there are also plenty of && and || in those files.
A quick count revealed
84 x && | 29 x and
49 x || vs x 48 or
There was a problem hiding this comment.
When did that become a thing? Because last I remember that's NOT in our codestyle rules or documented guidelines.
Agreed, it's not in the codestyle rules. But I was under the impression that it is usally done like this and I always followed that unspoken rule. Same as the if ... endif stuff which isn't (imho) written in the codestyle rules as well.
|
I hadn't heard that either but I can see the logic behind it.
|
|
Definitely easier to read but it's not just a 1-for-1 swap between |
|
@mbabker could you elaborate on that? |
|
http://php.net/manual/en/language.operators.logical.php will probably cover it better than I can. |
|
@mbabker Got it. Thanks. |
|
@mbabker ok but from what I see, most - if not all of those are swap-able 1-for-1. Why is it preferred then? And why specifically for the tmpl? |
|
The tmpl folder contains the HTML output, which is the stuff users likely want to adjust.
In the layout files, they usually are interchangeable. It only starts to matter if you have them mixed in a assignments and ternaries (see http://php.net/manual/en/language.operators.precedence.php). But there I prefer to use |
|
Ok, I see, but still it's a mix of both styles, with the |
Agreed, but please don't do it in this PR. If we want to choose one way, the proper way is to define a codestyle rule and then apply it. Otherwise you're going to change it now and the next guy wants to change it back 😄 |
|
😄 Yes, of course! I have already reversed those changes. |
| <dd class="createdby"> | ||
| <?php $author = $item->author; ?> | ||
| <?php $author = ($item->created_by_alias ? $item->created_by_alias : $author);?> | ||
| <?php $author = ($item->created_by_alias ?: $author);?> |
There was a problem hiding this comment.
like the other PR just
<?php $author = $item->created_by_alias ?: $item->author; ?>| <dd class="createdby"> | ||
| <?php $author = $this->item->author; ?> | ||
| <?php $author = ($this->item->created_by_alias ? $this->item->created_by_alias : $author);?> | ||
| <?php $author = ($this->item->created_by_alias ?: $author);?> |
There was a problem hiding this comment.
again, just
<?php $author = $this->item->created_by_alias ?: $this->item->author; ?>| <?php endif; ?> | ||
| <?php | ||
| $introcount = (count($this->intro_items)); | ||
| $introcount = count($this->intro_items); |
There was a problem hiding this comment.
actually this seems to be only used once ahead so it should only be there.
see ahead
<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>| <dd class="createdby"> | ||
| <?php $author = $this->item->author; ?> | ||
| <?php $author = ($this->item->created_by_alias ? $this->item->created_by_alias : $author);?> | ||
| <?php $author = ($this->item->created_by_alias ?: $author);?> |
There was a problem hiding this comment.
again, just
<?php $author = $this->item->created_by_alias ?: $this->item->author; ?>| <?php if (!empty($article->author) || !empty($article->created_by_alias)) : ?> | ||
| <?php $author = $article->author ?> | ||
| <?php $author = ($article->created_by_alias ? $article->created_by_alias : $author); ?> | ||
| <?php $author = ($article->created_by_alias ?: $author); ?> |
There was a problem hiding this comment.
again, just
<?php $author = $article->created_by_alias ?: $article->author; ?>| <dd class="createdby"> | ||
| <?php $author = $this->item->author; ?> | ||
| <?php $author = ($this->item->created_by_alias ? $this->item->created_by_alias : $author);?> | ||
| <?php $author = ($this->item->created_by_alias ?: $author);?> |
There was a problem hiding this comment.
again, just
<?php $author = $this->item->created_by_alias ?: $this->item->author; ?>| var bildauf = '" . $this->baseurl . "/templates/" . $this->template . "/images/plus.png'; | ||
| var bildzu = '" . $this->baseurl . "/templates/" . $this->template . "/images/minus.png'; | ||
| var bildauf = '" . $this->baseurl . '/templates/' . $this->template . "/images/plus.png'; | ||
| var bildzu = '" . $this->baseurl . '/templates/' . $this->template . "/images/minus.png'; |
There was a problem hiding this comment.
dont't understand why this change, before the baseurl var you have " and after '. IMHO or we use always ' or we use always "
There was a problem hiding this comment.
Thanks, this was an automated change which I obviously reviewed poorly... 😄
There was a problem hiding this comment.
Actually this was supposed to be a HEREDOC.. Forgot to implement...
templates/beez3/index.php
Outdated
| }"); | ||
| background: " . $this->params->get('backgroundcolor') . '; | ||
| }' | ||
| ); |
There was a problem hiding this comment.
dont't understand why this change, before you have " and after '. IMHO or we use always ' or we use always "
|
|
||
| <?php if ($this->item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) | ||
| || ((strtotime($this->item->publish_down) < strtotime(JFactory::getDate())) && $this->item->publish_down != JFactory::getDbo()->getNullDate())) : ?> | ||
| || ((strtotime($this->item->publish_down) < strtotime(JFactory::getDate())) && $this->item->publish_down !== JFactory::getDbo()->getNullDate())) : ?> |
| <?php if ($this->params->get('show_page_heading') and ($this->params->get('show_category_title') or $this->params->get('page_subheading'))) : ?> | ||
| <?php | ||
| if ($this->params->get('show_page_heading')) : ?> | ||
| <?php if ($this->params->get('show_page_heading') and ($showCategoryTitle === true or $pageSubHeading)) : ?> |
There was a problem hiding this comment.
Redundant checking with the previous line $this->params->get('show_page_heading'.
| </h2> | ||
| <?php endif; ?> | ||
| <?php if ($this->params->get('show_page_heading') and $params->get('show_title')) :?> | ||
| <?php if ($showPageHeading and $params->get('show_title')) :?> |
There was a problem hiding this comment.
are you sure $showPageHeading defined at this time?
There was a problem hiding this comment.
It is defined in the first if() statement at line 30. Or, did I miss something?
There was a problem hiding this comment.
right sorry ... tought this instruction was inside an else
There was a problem hiding this comment.
No issue, thought I had messed up :)
| </article> | ||
| <?php $counter++; ?> | ||
| <?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?> | ||
| <?php if ($rowcount === $this->columns or $counter === $introcount) : ?> |
There was a problem hiding this comment.
are you sure $this->columns is an integer ? (see line above echo (int) $this->columns;)
There was a problem hiding this comment.
Thank you. Somehow got that wrong...
| <?php $author = ($this->item->created_by_alias ?: $author);?> | ||
| <?php if (!empty($this->item->contact_link ) && $params->get('link_author') == true) : ?> | ||
| <?php $author = $this->item->created_by_alias ?: $this->item->author; ?> | ||
| <?php if (!empty($this->item->contact_link) && $params->get('link_author') == true) : ?> |
|
I have tested this item ✅ successfully on 4f3c91f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12233. |
|
I have tested this item ✅ successfully on 4f3c91f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12233. |
|
RTC please, thank you |
|
RTC after two successful tests. |
| <?php if ($showPageHeading = $this->params->get('show_page_heading')) : ?> | ||
|
|
||
| <?php if ($this->params->get('show_page_heading') and $params->get('show_title')) :?> | ||
| <?php if ($showPageHeading and $params->get('show_title')) :?> |
There was a problem hiding this comment.
Is there any reason we are using and here? :-)
There was a problem hiding this comment.
Since this really big one is already RTC, and those seem to be no show-stoppers, do you mind marking those reviews as non-stoppers? It took a long time to go RTC for those bug ones :).
I will happily open a new PR for those ones after this is merged.
Also for this one and the one after the next, those are mixed files, and there has been lot of discussion on that in one of my other PR's.. in the code-standards Repo. Still ongoing I think.
|
|
||
| <?php if ($this->item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) | ||
| || ((strtotime($this->item->publish_down) < strtotime(JFactory::getDate())) && $this->item->publish_down != JFactory::getDbo()->getNullDate())) : ?> | ||
| || (strtotime($this->item->publish_down) < strtotime(JFactory::getDate()) && $this->item->publish_down !== JFactory::getDbo()->getNullDate())) : ?> |
There was a problem hiding this comment.
instead of calling strtotime on JFactory::getDate you can use JFactory::getDate()->getTimestamp();
| <?php endif; ?> | ||
|
|
||
| <?php if ($this->params->get('show_category_title') or $this->params->get('page_subheading')) : ?> | ||
| <?php if ($showCategoryTitle === true or $pageSubHeading) : ?> |
| <?php foreach ($this->children[$this->category->id] as $id => $child) : ?> | ||
| <?php | ||
| if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) : | ||
| if ($child->numitems || $this->params->get('show_empty_categories') || count($child->getChildren())) : |
There was a problem hiding this comment.
!empty is faster than count :-)
| // Make a link if not the last item in the breadcrumbs | ||
| $show_last = $params->get('showLast', 1); | ||
| if ($key != $last_item_key) | ||
| if ($key !== $last_item_key) |
There was a problem hiding this comment.
new line missing before (yep i know it has been like that)
|
I am not going to merge these types of PR into 3.7.4, we have seen that chances are good to miss something and then we introduce a bug as we have seen in the last release. Make the software more solid and stable is more important. |
|
That'd be helpful. |
|
Base changed to 3.8-dev without conflicts on this PR. |
|
@mbabker Base changed to 3.8-dev on this PR. Conflicts resolved. |
* 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 (10.6.2017) - see third paragraph]
Performance (and a bit of cleanup) Batch #6
The changes in this batch are all in files under
templates.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 and cleaning up, but those 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 4 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.
[Update 10.6.2017]
All Sub-PRs of this PR have now been merged. That means a lot less changes to be reviewed 😄
Attention potential testers: Those changes should only need code review.
Thank you!