Skip to content

Conversation

@frankmayer
Copy link
Contributor

@frankmayer frankmayer commented Sep 30, 2016

[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!

$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";
Copy link
Contributor

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>');
Copy link
Contributor

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?

}

if (($context == 'com_content.article') && ($view == 'article') && $params->get('show_item_navigation'))
if (($context === 'com_content.article') && ($view === 'article') && $params->get('show_item_navigation'))
Copy link
Contributor

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


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'])
Copy link
Contributor

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

@andrepereiradasilva
Copy link
Contributor

I have tested this item ✅ successfully on 42a5a54

code review


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
@frankmayer
Copy link
Contributor Author

This PR is waiting on merge of sub PR #13272, so I can resolve conflicts here and get this reviewed / tested / merged, too.

$item->fields[$field->id] = $field;
}

return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed?

Copy link
Contributor Author

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.

@frankmayer
Copy link
Contributor Author

Edited initial post to show which sub-PRs still have to go through, in order to make this one easier to digest.
It would be great if the initial big batch PRs of mine could make it into alpha2. Thanks!

# 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
@frankmayer
Copy link
Contributor Author

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
@frankmayer
Copy link
Contributor Author

All Sub-PRs of this PR have now been merged. That means a lot less changes to be reviewed 😄
Please review.
Thank you!

@andrepereiradasilva
Copy link
Contributor

next in my list of tests - tomorrow probably

$response = '';

if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == false )
if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) === false )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space after 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'))
Copy link
Contributor

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')


$htmlProfile = ($info[$id]->profile ? $info[$id]->profile : JText::_('PLG_DEBUG_NO_PROFILE'));
$htmlProfile = ($info[$id]->profile ?: JText::_('PLG_DEBUG_NO_PROFILE'));

Copy link
Contributor

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).

Copy link
Contributor Author

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!


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'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove parenthesis ($task === 'register').

@frankmayer
Copy link
Contributor Author

@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?
Thanks guys!!!

@Quy
Copy link
Contributor

Quy commented Jun 1, 2017

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.

@ghost
Copy link

ghost commented Jun 1, 2017

RTC after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jun 1, 2017
Copy link
Contributor

@andrepereiradasilva andrepereiradasilva left a 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

// Bind using Connect Username/password
// Force anon bind to mitigate misconfiguration like [#7119]
if (strlen($this->params->get('username')))
if ($this->params->get('username'))
Copy link
Contributor

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', '') !== ''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. thanks

$pubkey = $this->params->get('public_key', '');

if ($pubkey == null || $pubkey == '')
if ($pubkey === null || $pubkey === '')
Copy link
Contributor

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

Copy link
Contributor Author

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

$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 === '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

$challenge = null;
$response = $input->get('g-recaptcha-response', '', 'string');
$spam = ($response == null || strlen($response) == 0);
$spam = ($response === null || $response === '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

$recaptchaResponse = new JReCaptchaResponse();

if (trim($answers['success']) == true)
if (trim($answers['success']))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict? trim($answers['success']) !== ''


// Check if the extension that owns the category is also enabled.
if (JComponentHelper::isEnabled($item->extension) === false)
if (!JComponentHelper::isEnabled($item->extension))
Copy link
Contributor

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?

{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) === false)
if (!JComponentHelper::isEnabled($this->extension))
Copy link
Contributor

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?


// Check if the extension is enabled.
if (JComponentHelper::isEnabled($this->extension) == false)
if (!JComponentHelper::isEnabled($this->extension))
Copy link
Contributor

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?

{
// Check if the extension is enabled.
if (JComponentHelper::isEnabled($this->extension) === false)
if (!JComponentHelper::isEnabled($this->extension))
Copy link
Contributor

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?

{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) === false)
if (!JComponentHelper::isEnabled($this->extension))
Copy link
Contributor

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?

@ghost
Copy link

ghost commented Jun 2, 2017

@andrepereiradasilva set Status back on Pending?

@frankmayer
Copy link
Contributor Author

@franz-wohlkoenig Let me just fly over those comments and I'll come back to you.

@frankmayer
Copy link
Contributor Author

@franz-wohlkoenig @andrepereiradasilva updated according to reviewer's comments.
Please check and RTC.
Thanks!!

@andrepereiradasilva
Copy link
Contributor

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.

@rdeutz rdeutz merged commit d434df3 into joomla:staging Jun 8, 2017
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jun 8, 2017
@rdeutz rdeutz added this to the Joomla 3.7.3 milestone Jun 8, 2017
@frankmayer frankmayer deleted the Performance_4 branch June 8, 2017 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants