-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Performance 4 (plugins) #12228
Performance 4 (plugins) #12228
Conversation
@@ -258,14 +258,14 @@ private function _recaptcha_http_post($host, $path, $data, $port = 80) | |||
$http_request = "POST $path HTTP/1.0\r\n"; | |||
$http_request .= "Host: $host\r\n"; | |||
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; | |||
$http_request .= "Content-Length: " . strlen($req) . "\r\n"; | |||
$http_request .= 'Content-Length: ' . strlen($req) . "\r\n"; |
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.
again why use '
when you use "
in all others?
{ | ||
die("To use reCAPTCHA you must get an API key from <a href='" | ||
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>"); | ||
. self::$_signupUrl . "'>" . self::$_signupUrl . '</a>'); |
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.
again why use '
when you use "
in all others?
@@ -39,7 +39,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) | |||
return false; | |||
} | |||
|
|||
if (($context == 'com_content.article') && ($view == 'article') && $params->get('show_item_navigation')) | |||
if (($context === 'com_content.article') && ($view === 'article') && $params->get('show_item_navigation')) |
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.
you could remove the parenthisis here
plugins/user/profile/profile.php
Outdated
|
||
if (($task == 'register') && ($tosenabled) && ($tosarticle) && ($option == 'com_users')) | ||
// Check that the tos is checked. | ||
if (($task === 'register') && $tosenabled && $tosarticle && ($option === 'com_users') && !$data['profile']['tos']) |
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.
you could remove the parenthisis here
I have tested this item ✅ successfully on 42a5a54 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12228. |
# Conflicts: # plugins/content/pagebreak/pagebreak.php # plugins/content/pagenavigation/pagenavigation.php # plugins/system/debug/debug.php # plugins/system/languagefilter/languagefilter.php # plugins/user/profile/field/dob.php # plugins/user/profile/profile.php
This PR is waiting on merge of sub PR #13272, so I can resolve conflicts here and get this reviewed / tested / merged, too. |
plugins/system/fields/fields.php
Outdated
@@ -472,6 +472,8 @@ public function onContentPrepare($context, $item) | |||
{ | |||
$item->fields[$field->id] = $field; | |||
} | |||
|
|||
return; |
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.
This isn't needed?
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.
Reverted this one to its prior state, so it won't raise conflicts with @laoneo 's efforts.
Edited initial post to show which sub-PRs still have to go through, in order to make this one easier to digest. |
# Conflicts: # plugins/authentication/gmail/gmail.php # plugins/editors-xtd/image/image.php # plugins/editors/tinymce/tinymce.php # plugins/system/debug/debug.php # plugins/system/fields/fields.php # plugins/user/joomla/joomla.php # plugins/user/profile/field/dob.php
Pls don't review this yet. There was a git problem. Need to resolve first. |
# Conflicts: # plugins/captcha/recaptcha/recaptchalib.php # plugins/content/contact/contact.php # plugins/finder/categories/categories.php # plugins/finder/contacts/contacts.php # plugins/finder/newsfeeds/newsfeeds.php # plugins/finder/tags/tags.php
All Sub-PRs of this PR have now been merged. That means a lot less changes to be reviewed 😄 |
next in my list of tests - tomorrow probably |
@@ -268,7 +268,7 @@ private function _recaptcha_http_post($host, $path, $data, $port = 80) | |||
|
|||
$response = ''; | |||
|
|||
if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == false ) | |||
if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) === false ) |
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.
Remove space after false
.
@@ -39,7 +39,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) | |||
return false; | |||
} | |||
|
|||
if (($context === 'com_content.article') && ($view === 'article') && $params->get('show_item_navigation')) | |||
if (($context === 'com_content.article') && $view === 'article' && $params->get('show_item_navigation')) |
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.
Remove parenthesis ($context === 'com_content.article')
plugins/system/debug/debug.php
Outdated
@@ -1110,7 +1106,7 @@ protected function displayQueries() | |||
$title = '<span class="dbg-noprofile">' . $title . '</span>'; | |||
} | |||
|
|||
$htmlProfile = ($info[$id]->profile ? $info[$id]->profile : JText::_('PLG_DEBUG_NO_PROFILE')); | |||
$htmlProfile = ($info[$id]->profile ?: JText::_('PLG_DEBUG_NO_PROFILE')); | |||
|
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.
Remove outside parenthesis (ignore if done in a different 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.
Don't remember if that is in any other PR. There are so many PR's still open, that some may overlap. I'll just do that here and move on 😄
Thanks for reviewing!
plugins/user/profile/profile.php
Outdated
@@ -384,13 +384,10 @@ public function onUserBeforeSave($user, $isnew, $data) | |||
$tosarticle = $this->params->get('register_tos_article'); | |||
$tosenabled = ($this->params->get('register-require_tos', 0) == 2); | |||
|
|||
if (($task === 'register') && $tosenabled && $tosarticle && ($option === 'com_users')) | |||
// Check that the tos is checked. | |||
if (($task === 'register') && $tosenabled && $tosarticle && $option === 'com_users' && !$data['profile']['tos']) |
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.
Remove parenthesis ($task === 'register')
.
@Quy would you be so kind and check the changes of your reviews for this one, too? So maybe we can get this RTC as soon as @andrepereiradasilva also has time to check it? |
I have tested this item ✅ successfully on 475b880 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12228. |
RTC after two successful tests. |
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.
some minor issues/sugestions
plugins/authentication/ldap/ldap.php
Outdated
@@ -72,7 +72,7 @@ public function onUserAuthenticate($credentials, $options, &$response) | |||
{ | |||
// Bind using Connect Username/password | |||
// Force anon bind to mitigate misconfiguration like [#7119] | |||
if (strlen($this->params->get('username'))) | |||
if ($this->params->get('username')) |
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.
strict? $this->params->get('username', '') !== ''
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.
Yes.. thanks
@@ -40,7 +40,7 @@ public function onInit($id = 'dynamic_recaptcha_1') | |||
{ | |||
$pubkey = $this->params->get('public_key', ''); | |||
|
|||
if ($pubkey == null || $pubkey == '') | |||
if ($pubkey === null || $pubkey === '') |
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.
question: can pubkey be null? when in line above default to ''
if doesn't exist
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.
I think it can't... changing
@@ -117,13 +117,13 @@ public function onCheckAnswer($code = null) | |||
case '1.0': | |||
$challenge = $input->get('recaptcha_challenge_field', '', 'string'); | |||
$response = $input->get('recaptcha_response_field', '', 'string'); | |||
$spam = ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0); | |||
$spam = ($challenge === null || $challenge === '' || $response === null || $response === ''); |
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.
same as above
break; | ||
case '2.0': | ||
// Challenge Not needed in 2.0 but needed for getResponse call | ||
$challenge = null; | ||
$response = $input->get('g-recaptcha-response', '', 'string'); | ||
$spam = ($response == null || strlen($response) == 0); | ||
$spam = ($response === null || $response === ''); |
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.
same as above
@@ -131,7 +131,7 @@ public function verifyResponse($remoteIp, $response) | |||
$answers = json_decode($getResponse, true); | |||
$recaptchaResponse = new JReCaptchaResponse(); | |||
|
|||
if (trim($answers['success']) == true) | |||
if (trim($answers['success'])) |
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.
strict? trim($answers['success']) !== ''
{ | ||
return; | ||
} | ||
|
||
// Check if the extension that owns the category is also enabled. | ||
if (JComponentHelper::isEnabled($item->extension) === false) | ||
if (!JComponentHelper::isEnabled($item->extension)) |
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.
why remove the strict compare?
plugins/finder/contacts/contacts.php
Outdated
@@ -251,7 +251,7 @@ public function onFinderChangeState($context, $pks, $value) | |||
protected function index(FinderIndexerResult $item, $format = 'html') | |||
{ | |||
// Check if the extension is enabled | |||
if (JComponentHelper::isEnabled($this->extension) === false) | |||
if (!JComponentHelper::isEnabled($this->extension)) |
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.
why remove the strict compare?
plugins/finder/content/content.php
Outdated
@@ -246,7 +246,7 @@ protected function index(FinderIndexerResult $item, $format = 'html') | |||
$item->setLanguage(); | |||
|
|||
// Check if the extension is enabled. | |||
if (JComponentHelper::isEnabled($this->extension) == false) | |||
if (!JComponentHelper::isEnabled($this->extension)) |
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.
why remove the strict compare?
@@ -252,7 +252,7 @@ public function onFinderChangeState($context, $pks, $value) | |||
protected function index(FinderIndexerResult $item, $format = 'html') | |||
{ | |||
// Check if the extension is enabled. | |||
if (JComponentHelper::isEnabled($this->extension) === false) | |||
if (!JComponentHelper::isEnabled($this->extension)) |
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.
why remove the strict compare?
plugins/finder/tags/tags.php
Outdated
@@ -206,7 +206,7 @@ public function onFinderChangeState($context, $pks, $value) | |||
protected function index(FinderIndexerResult $item, $format = 'html') | |||
{ | |||
// Check if the extension is enabled | |||
if (JComponentHelper::isEnabled($this->extension) === false) | |||
if (!JComponentHelper::isEnabled($this->extension)) |
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.
why remove the strict compare?
@andrepereiradasilva set Status back on Pending? |
@franz-wohlkoenig Let me just fly over those comments and I'll come back to you. |
@franz-wohlkoenig @andrepereiradasilva updated according to reviewer's comments. |
I have tested this item ✅ successfully on 475b880 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12228. |
[UPDATED (1.6.2017) - see third paragraph]
Performance (and a bit of cleanup) Batch #4
The changes in this batch are all in files under
plugins
.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 5 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 1.6.2017]
All Sub-PRs of this PR have now been merged. That means a lot less changes to be reviewed 😄
Please review.
Thank you!