From d020e052bb87a7ef24c9f99cf54b8715b2274375 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:08:01 +0300 Subject: [PATCH 01/37] Use Elvis instead of full ternary --- plugins/editors/tinymce/tinymce.php | 2 +- plugins/system/debug/debug.php | 4 ++-- plugins/system/stats/stats.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 8753a4960b87a..48b6bc4bc2e52 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -1012,7 +1012,7 @@ private function tinyButtons($name, $excluded) // Set some vars $name = 'button-' . $i . str_replace(" ", "", $button->get('text')); $title = $button->get('text'); - $onclick = ($button->get('onclick')) ? $button->get('onclick') : null; + $onclick = ($button->get('onclick')) ?: null; $options = $button->get('options'); $icon = $button->get('name'); diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 1b98e7db1145b..8f0aabf797eee 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -1021,7 +1021,7 @@ protected function displayQueries() $title = '' . $title . ''; } - $htmlProfile = ($info[$id]->profile ? $info[$id]->profile : JText::_('PLG_DEBUG_NO_PROFILE')); + $htmlProfile = ($info[$id]->profile ?: JText::_('PLG_DEBUG_NO_PROFILE')); $htmlAccordions = JHtml::_( 'bootstrap.startAccordion', 'dbg_query_' . $id, array( @@ -1526,7 +1526,7 @@ protected function displayUntranslatedStrings() if (is_array($occurance) && isset($occurance[0])) { $info = $occurance[0]; - $file = ($info['file']) ? $info['file'] : ''; + $file = ($info['file']) ?: ''; if (!isset($guesses[$file])) { diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php index 5cab6b078fc54..3547ba5999ed1 100644 --- a/plugins/system/stats/stats.php +++ b/plugins/system/stats/stats.php @@ -435,7 +435,7 @@ private function saveParams() $this->params->set('lastrun', time()); $this->params->set('unique_id', $this->getUniqueId()); $interval = (int) $this->params->get('interval', 12); - $this->params->set('interval', $interval ? $interval : 12); + $this->params->set('interval', $interval ?: 12); $query = $this->db->getQuery(true) ->update($this->db->quoteName('#__extensions')) From f8d247c517535995138829418ec8dcb3325ac11f Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:10:25 +0300 Subject: [PATCH 02/37] Use prefixed increment instead of assignment --- plugins/system/debug/debug.php | 4 ++-- plugins/system/redirect/redirect.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 8f0aabf797eee..28b17390bac7d 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -919,12 +919,12 @@ protected function displayQueries() // Increment the count. if (stripos($query, 'select') === 0) { - $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1; + ++$selectQueryTypeTicker[$fromString]; unset($otherQueryTypeTicker[$fromString]); } else { - $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1; + ++$otherQueryTypeTicker[$fromString]; unset($selectQueryTypeTicker[$fromString]); } diff --git a/plugins/system/redirect/redirect.php b/plugins/system/redirect/redirect.php index b580291ef6032..39896a4620448 100644 --- a/plugins/system/redirect/redirect.php +++ b/plugins/system/redirect/redirect.php @@ -233,7 +233,7 @@ private static function doErrorHandling($error) // We have an unpublished redirect object, increment the hit counter else { - $redirect->hits += 1; + ++$redirect->hits; try { From bcd884159ce2b2449493c2c856610c94eac30877 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:11:42 +0300 Subject: [PATCH 03/37] Use single quotes instead of doublequotes --- plugins/authentication/ldap/ldap.php | 4 +- plugins/captcha/recaptcha/recaptcha.php | 4 +- plugins/captcha/recaptcha/recaptchalib.php | 12 ++-- plugins/content/emailcloak/emailcloak.php | 6 +- .../content/pagenavigation/pagenavigation.php | 2 +- plugins/content/vote/vote.php | 2 +- plugins/editors/codemirror/codemirror.php | 6 +- plugins/editors/tinymce/tinymce.php | 64 +++++++++---------- plugins/search/contacts/contacts.php | 4 +- plugins/search/content/content.php | 6 +- plugins/search/newsfeeds/newsfeeds.php | 4 +- plugins/search/tags/tags.php | 2 +- plugins/system/debug/debug.php | 12 ++-- .../system/languagefilter/languagefilter.php | 2 +- plugins/system/log/log.php | 6 +- plugins/system/sef/sef.php | 8 +-- plugins/system/stats/stats.php | 2 +- plugins/user/joomla/joomla.php | 4 +- plugins/user/profile/field/tos.php | 4 +- plugins/user/profile/profile.php | 2 +- 20 files changed, 79 insertions(+), 77 deletions(-) diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index 34b7204b5822c..26a834906b42a 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -82,7 +82,7 @@ public function onUserAuthenticate($credentials, $options, &$response) if ($bindtest) { // Search for users DN - $binddata = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string'))); + $binddata = $ldap->simple_search(str_replace('[search]', $credentials['username'], $this->params->get('search_string'))); if (isset($binddata[0]) && isset($binddata[0]['dn'])) { @@ -112,7 +112,7 @@ public function onUserAuthenticate($credentials, $options, &$response) if ($success) { - $userdetails = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string'))); + $userdetails = $ldap->simple_search(str_replace('[search]', $credentials['username'], $this->params->get('search_string'))); } else { diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index bb8fc2c7f7585..897f750eda50a 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -226,7 +226,7 @@ private function getResponse($privatekey, $remoteip, $response, $challenge = nul */ private function _recaptcha_qsencode($data) { - $req = ""; + $req = ''; foreach ($data as $key => $value) { @@ -258,7 +258,7 @@ 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"; $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; $http_request .= "\r\n"; $http_request .= $req; diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index f7be8997a0841..3906b243edbc1 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -41,10 +41,10 @@ class JReCaptchaResponse class JReCaptcha { - private static $_signupUrl = "https://www.google.com/recaptcha/admin"; - private static $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify"; + private static $_signupUrl = 'https://www.google.com/recaptcha/admin'; + private static $_siteVerifyUrl = 'https://www.google.com/recaptcha/api/siteverify'; private $_secret; - private static $_version = "php_1.0"; + private static $_version = 'php_1.0'; /** * Constructor. @@ -53,10 +53,10 @@ class JReCaptcha */ public function __construct($secret) { - if ($secret == null || $secret == "") + if ($secret == null || $secret == '') { die("To use reCAPTCHA you must get an API key from " . self::$_signupUrl . ""); + . self::$_signupUrl . "'>" . self::$_signupUrl . ''); } $this->_secret = $secret; } @@ -70,7 +70,7 @@ public function __construct($secret) */ private function _encodeQS($data) { - $req = ""; + $req = ''; foreach ($data as $key => $value) { $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; diff --git a/plugins/content/emailcloak/emailcloak.php b/plugins/content/emailcloak/emailcloak.php index d6266af9ae225..51c137d6c2b91 100644 --- a/plugins/content/emailcloak/emailcloak.php +++ b/plugins/content/emailcloak/emailcloak.php @@ -68,13 +68,13 @@ protected function _getPattern ($link, $text) */ protected function _addAttributesToEmail($jsEmail, $before, $after) { - if ($before !== "") + if ($before !== '') { $before = str_replace("'", "\'", $before); $jsEmail = str_replace(".innerHTML += ''", "'\'{$after}>'", $jsEmail); @@ -123,7 +123,7 @@ protected function _cloak(&$text, &$params) $searchText = '((?:[\x20-\x7f]|[\xA1-\xFF]|[\xC2-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF4][\x80-\xBF]{3})[^<>]+)'; // Any Image link - $searchImage = "(]+>)"; + $searchImage = '(]+>)'; // Any Text with ||)'; diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index aac9b8fbeb4a9..a6003894848b0 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -139,7 +139,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) ->join('LEFT', '#__categories AS cc ON cc.id = a.catid') ->where( 'a.catid = ' . (int) $row->catid . ' AND a.state = ' . (int) $row->state - . ($canPublish ? '' : ' AND a.access IN (' . implode(",", JAccess::getAuthorisedViewLevels($user->id)) . ') ') . $xwhere + . ($canPublish ? '' : ' AND a.access IN (' . implode(',', JAccess::getAuthorisedViewLevels($user->id)) . ') ') . $xwhere ); $query->order($orderby); diff --git a/plugins/content/vote/vote.php b/plugins/content/vote/vote.php index fc4f15e0608c6..af91143eac7a2 100644 --- a/plugins/content/vote/vote.php +++ b/plugins/content/vote/vote.php @@ -30,7 +30,7 @@ class PlgContentVote extends JPlugin */ public function onContentBeforeDisplay($context, &$row, &$params, $page=0) { - $parts = explode(".", $context); + $parts = explode('.', $context); if ($parts[0] != 'com_content') { diff --git a/plugins/editors/codemirror/codemirror.php b/plugins/editors/codemirror/codemirror.php index 16e624d52e8ec..d3c6baa5c41b5 100644 --- a/plugins/editors/codemirror/codemirror.php +++ b/plugins/editors/codemirror/codemirror.php @@ -148,9 +148,11 @@ public function onGetInsertMethod() $done = true; - JFactory::getDocument()->addScriptDeclaration(" + JFactory::getDocument()->addScriptDeclaration( + ' ;function jInsertEditorText(text, editor) { Joomla.editors.instances[editor].replaceSelection(text); } - "); + ' + ); return true; } diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 48b6bc4bc2e52..5d0ede5d0cfd1 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -151,17 +151,17 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons if ($langMode) { - if (file_exists(JPATH_ROOT . "/media/editors/tinymce/langs/" . $language->getTag() . ".js")) + if (file_exists(JPATH_ROOT . '/media/editors/tinymce/langs/' . $language->getTag() . '.js')) { $langPrefix = $language->getTag(); } - elseif (file_exists(JPATH_ROOT . "/media/editors/tinymce/langs/" . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . ".js")) + elseif (file_exists(JPATH_ROOT . '/media/editors/tinymce/langs/' . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . '.js')) { $langPrefix = substr($language->getTag(), 0, strpos($language->getTag(), '-')); } else { - $langPrefix = "en"; + $langPrefix = 'en'; } } @@ -253,12 +253,12 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons if ($relative_urls) { // Relative - $relative_urls = "true"; + $relative_urls = 'true'; } else { // Absolute - $relative_urls = "false"; + $relative_urls = 'false'; } $newlines = $this->params->get('newlines', 0); @@ -324,11 +324,11 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons if (isset($access[$image_advtab])) { - $image_advtab = "true"; + $image_advtab = 'true'; } else { - $image_advtab = "false"; + $image_advtab = 'false'; } // The param is true for vertical resizing only, false or both @@ -520,7 +520,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $toolbar3_add[] = 'ltr rtl'; } - if ($extended_elements != "") + if ($extended_elements != '') { $elements = explode(',', $extended_elements); } @@ -583,27 +583,27 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $toolbar4_add[] = 'template'; // Note this check for the template_list.js file will be removed in Joomla 4.0 - if (is_file(JPATH_ROOT . "/media/editors/tinymce/templates/template_list.js")) + if (is_file(JPATH_ROOT . '/media/editors/tinymce/templates/template_list.js')) { // If using the legacy file we need to include and input the files the new way - $str = file_get_contents(JPATH_ROOT . "/media/editors/tinymce/templates/template_list.js"); + $str = file_get_contents(JPATH_ROOT . '/media/editors/tinymce/templates/template_list.js'); // Find from one [ to the last ] preg_match_all('/\[.*\]/', $str, $matches); - $templates = "templates: ["; + $templates = 'templates: ['; // Set variables foreach ($matches['0'] as $match) { preg_match_all('/\".*\"/', $match, $values); - $result = trim($values["0"]["0"], '"'); + $result = trim($values['0']['0'], '"'); $final_result = explode(',', $result); $templates .= "{title: '" . trim($final_result['0'], ' " ') . "', description: '" . trim($final_result['2'], ' " ') . "', url: '" . JUri::root() . trim($final_result['1'], ' " ') . "'},"; } - $templates .= "],"; + $templates .= '],'; } else { @@ -706,14 +706,14 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $custom_plugin = $this->params->get('custom_plugin', ''); - if ($custom_plugin != "") + if ($custom_plugin != '') { $plugins[] = $custom_plugin; } $custom_button = $this->params->get('custom_button', ''); - if ($custom_button != "") + if ($custom_button != '') { $toolbar4_add[] = $custom_button; } @@ -724,14 +724,14 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $tinyBtns = $btns['script']; // Drag and drop Images - $allowImgPaste = "false"; + $allowImgPaste = 'false'; $dragDropPlg = ''; $dragdrop = $this->params->get('drag_drop', 1); $user = JFactory::getUser(); if ($dragdrop && $user->authorise('core.create', 'com_media')) { - $allowImgPaste = "true"; + $allowImgPaste = 'true'; $isSubDir = ''; $session = JFactory::getSession(); $uploadUrl = JUri::base() . 'index.php?option=com_media&task=file.upload&tmpl=component&' @@ -780,11 +780,11 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons . implode(' ', $toolbar2_add) . ' | ' . implode(' ', $toolbar3_add) . ' | ' . implode(' ', $toolbar4_add) . ' | ' - . implode(" | ", $btnsNames); - $toolbar5 = implode(" | ", $btnsNames); + . implode(' | ', $btnsNames); + $toolbar5 = implode(' | ', $btnsNames); // The buttons script - $tinyBtns = implode("; ", $tinyBtns); + $tinyBtns = implode('; ', $tinyBtns); // See if mobileVersion is activated $mobileVersion = $this->params->get('mobile', 0); @@ -868,8 +868,8 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons case 1: default: /* Advanced mode*/ - $toolbar1 = "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | formatselect | bullist numlist " - . "| outdent indent | undo redo | link unlink anchor code | hr table | subscript superscript | charmap"; + $toolbar1 = 'bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | formatselect | bullist numlist ' + . '| outdent indent | undo redo | link unlink anchor code | hr table | subscript superscript | charmap'; $script .= " valid_elements : \"$valid_elements\", @@ -940,11 +940,11 @@ function jInsertEditorText( text, editor ) if (!empty($btnsNames)) { $modalFix = JHtml::_('script', 'system/tiny-close.min.js', false, true, true, false, true); - JFactory::getDocument()->addScript($modalFix, "text/javascript", true, false); + JFactory::getDocument()->addScript($modalFix, 'text/javascript', true, false); } JFactory::getDocument()->addScriptDeclaration($script); - JFactory::getDocument()->addStyleDeclaration(".mce-in { padding: 5px 10px !important;}"); + JFactory::getDocument()->addStyleDeclaration('.mce-in { padding: 5px 10px !important;}'); // Only add "px" to width and height if they are not given as a percentage if (is_numeric($width)) @@ -1010,13 +1010,13 @@ private function tinyButtons($name, $excluded) if ($button->get('name')) { // Set some vars - $name = 'button-' . $i . str_replace(" ", "", $button->get('text')); + $name = 'button-' . $i . str_replace(' ', '', $button->get('text')); $title = $button->get('text'); $onclick = ($button->get('onclick')) ?: null; $options = $button->get('options'); $icon = $button->get('name'); - if ($button->get('link') != "#") + if ($button->get('link') != '#') { $href = JUri::base() . $button->get('link'); } @@ -1076,21 +1076,21 @@ private function tinyButtons($name, $excluded) if ($onclick && ($button->get('modal') || $href)) { $tempConstructor .= "\r\n - " . $onclick . " - "; + " . $onclick . ' + '; } } else { $tempConstructor .= "\r\n - " . $onclick . " - "; + " . $onclick . ' + '; } - $tempConstructor .= " + $tempConstructor .= ' } }); - })();"; + })();'; // The array with the toolbar buttons $btnsNames[] = $name; diff --git a/plugins/search/contacts/contacts.php b/plugins/search/contacts/contacts.php index 80017f72e35c0..244f81793cd21 100644 --- a/plugins/search/contacts/contacts.php +++ b/plugins/search/contacts/contacts.php @@ -142,8 +142,8 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $query->select( 'a.name AS title, \'\' AS created, a.con_position, a.misc, ' . $case_when . ',' . $case_when1 . ', ' - . $query->concatenate(array("a.name", "a.con_position", "a.misc"), ",") . ' AS text,' - . $query->concatenate(array($db->quote($section), "c.title"), " / ") . ' AS section,' + . $query->concatenate(array('a.name', 'a.con_position', 'a.misc'), ',') . ' AS text,' + . $query->concatenate(array($db->quote($section), 'c.title'), ' / ') . ' AS section,' . '\'2\' AS browsernav' ); $query->from('#__contact_details AS a') diff --git a/plugins/search/content/content.php b/plugins/search/content/content.php index 1595d7b1d905a..9c94e4feb8b55 100644 --- a/plugins/search/content/content.php +++ b/plugins/search/content/content.php @@ -236,7 +236,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $query->select( 'a.title AS title, a.metadesc, a.metakey, a.created AS created, ' - . $query->concatenate(array("a.introtext", "a.fulltext")) . ' AS text,' + . $query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text,' . $case_when . ',' . $case_when1 . ', ' . 'c.title AS section, \'2\' AS browsernav' ); @@ -281,8 +281,8 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu { $date = JFactory::getDate($item->created); - $created_month = $date->format("n"); - $created_year = $date->format("Y"); + $created_month = $date->format('n'); + $created_year = $date->format('Y'); $list3[$key]->href = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); } diff --git a/plugins/search/newsfeeds/newsfeeds.php b/plugins/search/newsfeeds/newsfeeds.php index 320e3024d41fe..dbaa2327591bf 100644 --- a/plugins/search/newsfeeds/newsfeeds.php +++ b/plugins/search/newsfeeds/newsfeeds.php @@ -164,8 +164,8 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $case_when1 .= ' ELSE '; $case_when1 .= $c_id . ' END as catslug'; - $query->select('a.name AS title, \'\' AS created, a.link AS text, ' . $case_when . "," . $case_when1) - ->select($query->concatenate(array($db->quote($searchNewsfeeds), 'c.title'), " / ") . ' AS section') + $query->select('a.name AS title, \'\' AS created, a.link AS text, ' . $case_when . ',' . $case_when1) + ->select($query->concatenate(array($db->quote($searchNewsfeeds), 'c.title'), ' / ') . ' AS section') ->select('\'1\' AS browsernav') ->from('#__newsfeeds AS a') ->join('INNER', '#__categories as c ON c.id = a.catid') diff --git a/plugins/search/tags/tags.php b/plugins/search/tags/tags.php index c01b15e768405..d9098f09ccecd 100644 --- a/plugins/search/tags/tags.php +++ b/plugins/search/tags/tags.php @@ -156,7 +156,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu foreach ($rows as $key => $row) { $rows[$key]->href = TagsHelperRoute::getTagRoute($row->id); - $rows[$key]->text = ($row->description != "" ? $row->description : $row->title); + $rows[$key]->text = ($row->description != '' ? $row->description : $row->title); $rows[$key]->text .= $row->note; $rows[$key]->section = $section; $rows[$key]->created = $row->created; diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 28b17390bac7d..0fecb4a533d03 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -233,7 +233,7 @@ public function onAfterRespond() } // No debug for Safari and Chrome redirection. - if (strstr(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""), 'webkit') !== false + if (strstr(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''), 'webkit') !== false && substr($contents, 0, 50) == 'app->input->getMethod() == "POST" + if ($this->app->input->getMethod() == 'POST' || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) { diff --git a/plugins/system/log/log.php b/plugins/system/log/log.php index 83267025f9e8b..b41ac345f9058 100644 --- a/plugins/system/log/log.php +++ b/plugins/system/log/log.php @@ -32,12 +32,12 @@ public function onUserLoginFailure($response) switch ($response['status']) { case JAuthentication::STATUS_SUCCESS: - $errorlog['status'] = $response['type'] . " CANCELED: "; + $errorlog['status'] = $response['type'] . ' CANCELED: '; $errorlog['comment'] = $response['error_message']; break; case JAuthentication::STATUS_FAILURE: - $errorlog['status'] = $response['type'] . " FAILURE: "; + $errorlog['status'] = $response['type'] . ' FAILURE: '; if ($this->params->get('log_username', 0)) { @@ -50,7 +50,7 @@ public function onUserLoginFailure($response) break; default: - $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; + $errorlog['status'] = $response['type'] . ' UNKNOWN ERROR: '; $errorlog['comment'] = $response['error_message']; break; } diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index b9b8b534c59b6..3e58f2f1b0a37 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -198,16 +198,16 @@ private function checkBuffer($buffer) switch (preg_last_error()) { case PREG_BACKTRACK_LIMIT_ERROR: - $message = "PHP regular expression limit reached (pcre.backtrack_limit)"; + $message = 'PHP regular expression limit reached (pcre.backtrack_limit)'; break; case PREG_RECURSION_LIMIT_ERROR: - $message = "PHP regular expression limit reached (pcre.recursion_limit)"; + $message = 'PHP regular expression limit reached (pcre.recursion_limit)'; break; case PREG_BAD_UTF8_ERROR: - $message = "Bad UTF8 passed to PCRE function"; + $message = 'Bad UTF8 passed to PCRE function'; break; default: - $message = "Unknown PCRE error calling PCRE function"; + $message = 'Unknown PCRE error calling PCRE function'; } throw new RuntimeException($message); diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php index 3547ba5999ed1..de859270303cd 100644 --- a/plugins/system/stats/stats.php +++ b/plugins/system/stats/stats.php @@ -86,7 +86,7 @@ public function onAfterInitialise() return; } - if (JUri::getInstance()->getVar("tmpl") === "component") + if (JUri::getInstance()->getVar('tmpl') === 'component') { return; } diff --git a/plugins/user/joomla/joomla.php b/plugins/user/joomla/joomla.php index 1399acd7bc9dd..f383fc5983c28 100644 --- a/plugins/user/joomla/joomla.php +++ b/plugins/user/joomla/joomla.php @@ -245,7 +245,7 @@ public function onUserLogin($user, $options = array()) if ($this->app->isSite()) { - $this->app->input->cookie->set("joomla_user_state", "logged_in", 0, $cookie_path, $cookie_domain, 0); + $this->app->input->cookie->set('joomla_user_state', 'logged_in', 0, $cookie_path, $cookie_domain, 0); } return true; @@ -309,7 +309,7 @@ public function onUserLogout($user, $options = array()) if ($this->app->isSite()) { - $this->app->input->cookie->set("joomla_user_state", "", time() - 86400, $cookie_path, $cookie_domain, 0); + $this->app->input->cookie->set('joomla_user_state', '', time() - 86400, $cookie_path, $cookie_domain, 0); } return true; diff --git a/plugins/user/profile/field/tos.php b/plugins/user/profile/field/tos.php index 59b0b56df5dd3..ae0a8ac4b798c 100644 --- a/plugins/user/profile/field/tos.php +++ b/plugins/user/profile/field/tos.php @@ -51,10 +51,10 @@ protected function getLabel() // Add CSS and JS for the TOS field $doc = JFactory::getDocument(); - $css = "#jform_profile_tos {width: 18em; margin: 0 !important; padding: 0 2px !important;} + $css = '#jform_profile_tos {width: 18em; margin: 0 !important; padding: 0 2px !important;} #jform_profile_tos input {margin:0 5px 0 0 !important; width:10px !important;} #jform_profile_tos label {margin:0 15px 0 0 !important; width:auto;} - "; + '; $doc->addStyleDeclaration($css); JHtml::_('behavior.modal'); diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index 5766279836948..2dcae598cab52 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -148,7 +148,7 @@ public static function url($value) // Convert website url to utf8 for display $value = JStringPunycode::urlToUTF8(htmlspecialchars($value)); - if (substr($value, 0, 4) == "http") + if (substr($value, 0, 4) == 'http') { return '' . $value . ''; } From e1288c337ee285319a7828837dc86b286bd8a21e Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:12:17 +0300 Subject: [PATCH 04/37] Remove unnecessary parentheses --- plugins/content/emailcloak/emailcloak.php | 10 +++++----- plugins/content/pagebreak/pagebreak.php | 6 +++--- plugins/editors/tinymce/tinymce.php | 2 +- plugins/search/contacts/contacts.php | 4 ++-- plugins/system/debug/debug.php | 14 +++++++------- plugins/system/stats/stats.php | 2 +- .../updatenotification/updatenotification.php | 2 +- plugins/user/profile/profile.php | 6 +++--- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plugins/content/emailcloak/emailcloak.php b/plugins/content/emailcloak/emailcloak.php index 51c137d6c2b91..95f41057ab93f 100644 --- a/plugins/content/emailcloak/emailcloak.php +++ b/plugins/content/emailcloak/emailcloak.php @@ -283,12 +283,12 @@ protected function _cloak(&$text, &$params) * Search for derivatives of link code * email@example.org */ - $pattern = $this->_getPattern($searchEmail, ($searchImage . $searchEmail)); + $pattern = $this->_getPattern($searchEmail, $searchImage . $searchEmail); while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { $mail = $regs[2][0]; - $mailText = $regs[4][0] . ($regs[5][0]); + $mailText = $regs[4][0] . $regs[5][0]; $replacement = JHtml::_('email.cloak', $mail, $mode, $mailText); @@ -303,7 +303,7 @@ protected function _cloak(&$text, &$params) * Search for derivatives of link code * any text */ - $pattern = $this->_getPattern($searchEmail, ($searchImage . $searchText)); + $pattern = $this->_getPattern($searchEmail, $searchImage . $searchText); while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { @@ -435,7 +435,7 @@ protected function _cloak(&$text, &$params) * Search for derivatives of link code * email@amail.com */ - $pattern = $this->_getPattern($searchEmailLink, ($searchImage . $searchEmail)); + $pattern = $this->_getPattern($searchEmailLink, $searchImage . $searchEmail); while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { @@ -459,7 +459,7 @@ protected function _cloak(&$text, &$params) * Search for derivatives of link code * any text */ - $pattern = $this->_getPattern($searchEmailLink, ($searchImage . $searchText)); + $pattern = $this->_getPattern($searchEmailLink, $searchImage . $searchText); while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 076636ca771d2..8eb3730e81342 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -99,7 +99,7 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $matches = array(); preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER); - if (($showall && $this->params->get('showall', 1))) + if ($showall && $this->params->get('showall', 1)) { $hasToc = $this->params->get('multipage_toc', 1); @@ -351,7 +351,7 @@ protected function _createNavigation(&$row, $page, $n) { $page_next = $page + 1; - $link_next = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . ($page_next)); + $link_next = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . $page_next); // Next >> $next = '' . JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT') . JText::_('JGLOBAL_GT') . ''; @@ -365,7 +365,7 @@ protected function _createNavigation(&$row, $page, $n) { $page_prev = $page - 1 == 0 ? '' : $page - 1; - $link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . ($page_prev)); + $link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . $page_prev); // << Prev $prev = '' . JText::_('JGLOBAL_LT') . JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV') . ''; diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 5d0ede5d0cfd1..6fa61cb44665b 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -1012,7 +1012,7 @@ private function tinyButtons($name, $excluded) // Set some vars $name = 'button-' . $i . str_replace(' ', '', $button->get('text')); $title = $button->get('text'); - $onclick = ($button->get('onclick')) ?: null; + $onclick = $button->get('onclick') ?: null; $options = $button->get('options'); $icon = $button->get('name'); diff --git a/plugins/search/contacts/contacts.php b/plugins/search/contacts/contacts.php index 244f81793cd21..46e800b3f099b 100644 --- a/plugins/search/contacts/contacts.php +++ b/plugins/search/contacts/contacts.php @@ -183,8 +183,8 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu { $rows[$key]->href = ContactHelperRoute::getContactRoute($row->slug, $row->catslug); $rows[$key]->text = $row->title; - $rows[$key]->text .= ($row->con_position) ? ', ' . $row->con_position : ''; - $rows[$key]->text .= ($row->misc) ? ', ' . $row->misc : ''; + $rows[$key]->text .= $row->con_position ? ', ' . $row->con_position : ''; + $rows[$key]->text .= $row->misc ? ', ' . $row->misc : ''; } } diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 0fecb4a533d03..1ee88cffadae0 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -1025,7 +1025,7 @@ protected function displayQueries() $htmlAccordions = JHtml::_( 'bootstrap.startAccordion', 'dbg_query_' . $id, array( - 'active' => ($info[$id]->hasWarnings ? ('dbg_query_explain_' . $id) : '') + 'active' => $info[$id]->hasWarnings ? ('dbg_query_explain_' . $id) : '' ) ); @@ -1109,7 +1109,7 @@ protected function displayQueries() $html = array(); $html[] = '

' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $this->totalQueries) - . sprintf(' %.2f ms', ($totalQueryTime)) . '


'; + . sprintf(' %.2f ms', $totalQueryTime) . '
'; if ($total_duplicates) { @@ -1393,7 +1393,7 @@ public function mysqlDisconnectHandler(&$db) foreach ($this->sqlShowProfiles as $qn) { // Run SHOW PROFILE FOR QUERY for each query where a profile is available (max 100). - $db->setQuery('SHOW PROFILE FOR QUERY ' . (int) ($qn['Query_ID'])); + $db->setQuery('SHOW PROFILE FOR QUERY ' . (int) $qn['Query_ID']); $this->sqlShowProfileEach[(int) ($qn['Query_ID'] - 1)] = $db->loadAssocList(); } } @@ -1482,7 +1482,7 @@ protected function displayLanguageFilesLoaded() { $html[] = '
  • '; - $html[] = ($status) + $html[] = $status ? JText::_('PLG_DEBUG_LANG_LOADED') : JText::_('PLG_DEBUG_LANG_NOT_LOADED'); @@ -1526,7 +1526,7 @@ protected function displayUntranslatedStrings() if (is_array($occurance) && isset($occurance[0])) { $info = $occurance[0]; - $file = ($info['file']) ?: ''; + $file = $info['file'] ?: ''; if (!isset($guesses[$file])) { @@ -1706,7 +1706,7 @@ protected function renderBacktrace($error) protected function formatLink($file, $line = '') { $link = str_replace(JPATH_ROOT, 'JROOT', $file); - $link .= ($line) ? ':' . $line : ''; + $link .= $line ? ':' . $line : ''; if ($this->linkFormat) { @@ -1985,7 +1985,7 @@ protected function prettyPrintJSON($json = '') protected function writeToFile() { $app = JFactory::getApplication(); - $domain = ($app->isSite()) ? 'site' : 'admin'; + $domain = $app->isSite() ? 'site' : 'admin'; $input = $app->input; $file = $app->get('log_path') . '/' . $domain . '_' . $input->get('option') . $input->get('view') . $input->get('layout') . '.sql'; diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php index de859270303cd..423572f3d31e0 100644 --- a/plugins/system/stats/stats.php +++ b/plugins/system/stats/stats.php @@ -547,7 +547,7 @@ private function clearCacheGroups(array $clearGroups, array $cacheClients = arra { $options = array( 'defaultgroup' => $group, - 'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : + 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache') ); diff --git a/plugins/system/updatenotification/updatenotification.php b/plugins/system/updatenotification/updatenotification.php index 3be554507c17a..e26540163bd2b 100644 --- a/plugins/system/updatenotification/updatenotification.php +++ b/plugins/system/updatenotification/updatenotification.php @@ -400,7 +400,7 @@ private function clearCacheGroups(array $clearGroups, array $cacheClients = arra { $options = array( 'defaultgroup' => $group, - 'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : + 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache') ); diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index 2dcae598cab52..9c5aec2bc9030 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -376,10 +376,10 @@ public function onUserBeforeSave($user, $isnew, $data) $tosarticle = $this->params->get('register_tos_article'); $tosenabled = ($this->params->get('register-require_tos', 0) == 2) ? true : false; - if (($task == 'register') && ($tosenabled) && ($tosarticle) && ($option == 'com_users')) + if (($task == 'register') && $tosenabled && $tosarticle && ($option == 'com_users')) { // Check that the tos is checked. - if ((!($data['profile']['tos']))) + if (!$data['profile']['tos']) { throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); } @@ -402,7 +402,7 @@ public function onUserAfterSave($data, $isNew, $result, $error) { $userId = ArrayHelper::getValue($data, 'id', 0, 'int'); - if ($userId && $result && isset($data['profile']) && (count($data['profile']))) + if ($userId && $result && isset($data['profile']) && count($data['profile'])) { try { From fdd996c8bea0277cf531bc790ae38989b7e47954 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:13:13 +0300 Subject: [PATCH 05/37] Replace alias function with original --- plugins/system/languagefilter/languagefilter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index f9a2016f61ae5..009b5fefefa81 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -504,7 +504,7 @@ public function parseRule(&$router, &$uri) */ public function onUserBeforeSave($user, $isnew, $new) { - if ($this->params->get('automatic_change', '1') == '1' && key_exists('params', $user)) + if ($this->params->get('automatic_change', '1') == '1' && array_key_exists('params', $user)) { $registry = new Registry; $registry->loadString($user['params']); @@ -533,7 +533,7 @@ public function onUserBeforeSave($user, $isnew, $new) */ public function onUserAfterSave($user, $isnew, $success, $msg) { - if ($this->params->get('automatic_change', '1') == '1' && key_exists('params', $user) && $success) + if ($this->params->get('automatic_change', '1') == '1' && array_key_exists('params', $user) && $success) { $registry = new Registry; $registry->loadString($user['params']); From dfc5b9825ffebdbf51129b3a847a843d90590528 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:14:38 +0300 Subject: [PATCH 06/37] Remove useless return --- plugins/content/pagenavigation/pagenavigation.php | 2 -- plugins/editors/none/none.php | 1 - plugins/editors/tinymce/tinymce.php | 3 --- 3 files changed, 6 deletions(-) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index a6003894848b0..f468b19d662e0 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -217,8 +217,6 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) $row->paginationrelative = $this->params->get('relative', 0); } } - - return; } /** diff --git a/plugins/editors/none/none.php b/plugins/editors/none/none.php index 55608adc6724f..96b032ac76160 100644 --- a/plugins/editors/none/none.php +++ b/plugins/editors/none/none.php @@ -40,7 +40,6 @@ public function onInit() */ public function onSave() { - return; } /** diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 6fa61cb44665b..3f946df454e61 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -47,8 +47,6 @@ class PlgEditorTinymce extends JPlugin public function onInit() { JHtml::script($this->_basePath . '/tinymce.min.js', false, false, false, false, false); - - return; } /** @@ -99,7 +97,6 @@ public function onSave($editor) */ public function onGetInsertMethod($name) { - return; } /** From aac191655336ac39c3bfc12e321bdb6a54cbc53f Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:15:39 +0300 Subject: [PATCH 07/37] Removed unnecessary ternary operators --- plugins/user/profile/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index 9c5aec2bc9030..232de9ac8bb82 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -374,7 +374,7 @@ public function onUserBeforeSave($user, $isnew, $data) $task = JFactory::getApplication()->input->getCmd('task'); $option = JFactory::getApplication()->input->getCmd('option'); $tosarticle = $this->params->get('register_tos_article'); - $tosenabled = ($this->params->get('register-require_tos', 0) == 2) ? true : false; + $tosenabled = ($this->params->get('register-require_tos', 0) == 2); if (($task == 'register') && $tosenabled && $tosarticle && ($option == 'com_users')) { From 90ffc542cbcf2df53ad7bf446c71ddca0e35822d Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:17:41 +0300 Subject: [PATCH 08/37] Fixed callable call in loop termination condition --- plugins/editors/tinymce/field/skins.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/field/skins.php b/plugins/editors/tinymce/field/skins.php index 1704863f2e62a..a4e8cf1f1cdf1 100644 --- a/plugins/editors/tinymce/field/skins.php +++ b/plugins/editors/tinymce/field/skins.php @@ -37,7 +37,7 @@ public function getOptions() $directories = glob(JPATH_ROOT . '/media/editors/tinymce/skins' . '/*', GLOB_ONLYDIR); - for ($i = 0; $i < count($directories); ++$i) + for ($i = 0, $iMax = count($directories); $i < $iMax; ++$i) { $dir = basename($directories[$i]); $options[] = JHtml::_('select.option', $i, $dir); From a9d98bd0b85adf06bb321630939957aa40e8030e Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:19:31 +0300 Subject: [PATCH 09/37] Replace is_null() with ... === null --- plugins/authentication/cookie/cookie.php | 2 +- plugins/system/debug/debug.php | 2 +- plugins/system/redirect/redirect.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/authentication/cookie/cookie.php b/plugins/authentication/cookie/cookie.php index 8f1d8b747b8de..675aab57712ef 100644 --- a/plugins/authentication/cookie/cookie.php +++ b/plugins/authentication/cookie/cookie.php @@ -269,7 +269,7 @@ public function onUserAfterLogin($options) { $results = $this->db->setQuery($query)->loadResult(); - if (is_null($results)) + if ($results === null) { $unique = true; } diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 1ee88cffadae0..91a20b00e54b7 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -322,7 +322,7 @@ private function isAuthorisedDisplayDebug() { static $result = null; - if (!is_null($result)) + if ($result !== null) { return $result; } diff --git a/plugins/system/redirect/redirect.php b/plugins/system/redirect/redirect.php index 39896a4620448..e13f34a579443 100644 --- a/plugins/system/redirect/redirect.php +++ b/plugins/system/redirect/redirect.php @@ -179,7 +179,7 @@ private static function doErrorHandling($error) } // A redirect object was found and, if published, will be used - if (!is_null($redirect) && ((int) $redirect->published === 1)) + if ($redirect !== null && ((int) $redirect->published === 1)) { if (!$redirect->header || (bool) JComponentHelper::getParams('com_redirect')->get('mode', false) === false) { @@ -205,7 +205,7 @@ private static function doErrorHandling($error) JErrorPage::render(new RuntimeException($error->getMessage(), $redirect->header, $error)); } // No redirect object was found so we create an entry in the redirect table - elseif (is_null($redirect)) + elseif ($redirect === null) { $params = new Registry(JPluginHelper::getPlugin('system', 'redirect')->params); From 33ba088e3f7df365dc0e867daf8634a652f68bc7 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:21:02 +0300 Subject: [PATCH 10/37] Shortened syntax for applied operations --- plugins/system/debug/debug.php | 6 +++--- plugins/user/profile/field/tos.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 91a20b00e54b7..2499f4938c6b2 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -644,7 +644,7 @@ protected function displayProfileInformation() } } - $totalQueryTime = $totalQueryTime * 1000; + $totalQueryTime *= 1000; if ($totalQueryTime > ($totalTime * 0.25)) { @@ -1776,7 +1776,7 @@ protected function displayLogs() } ) ); - $logEntriesTotal = $logEntriesTotal - $logEntriesDatabasequery; + $logEntriesTotal -= $logEntriesDatabasequery; } // Deprecated log entries @@ -1792,7 +1792,7 @@ protected function displayLogs() if (!$showDeprecated) { - $logEntriesTotal = $logEntriesTotal - $logEntriesDeprecated; + $logEntriesTotal -= $logEntriesDeprecated; } $showEverything = $this->params->get('log-everything', 0); diff --git a/plugins/user/profile/field/tos.php b/plugins/user/profile/field/tos.php index ae0a8ac4b798c..d7012f733a255 100644 --- a/plugins/user/profile/field/tos.php +++ b/plugins/user/profile/field/tos.php @@ -60,7 +60,7 @@ protected function getLabel() // Build the class for the label. $class = !empty($this->description) ? 'hasTooltip' : ''; - $class = $class . ' required'; + $class .= ' required'; $class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class; // Add the opening label tag and main attributes attributes. From 5c7afbf22aeec1c157db57dec3a747460de9ae02 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:32:07 +0300 Subject: [PATCH 11/37] Don't use strlen() to check if string is empty. --- plugins/authentication/gmail/gmail.php | 2 +- plugins/authentication/ldap/ldap.php | 4 ++-- plugins/captcha/recaptcha/recaptcha.php | 4 ++-- plugins/captcha/recaptcha/recaptchalib.php | 2 +- plugins/extension/joomla/joomla.php | 2 +- plugins/system/cache/cache.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/authentication/gmail/gmail.php b/plugins/authentication/gmail/gmail.php index 28240a81dbf8e..017c9035f5385 100644 --- a/plugins/authentication/gmail/gmail.php +++ b/plugins/authentication/gmail/gmail.php @@ -65,7 +65,7 @@ public function onUserAuthenticate($credentials, $options, &$response) } // Check if we have a username and password - if (strlen($credentials['username']) == 0 || strlen($credentials['password']) == 0) + if ($credentials['username'] === '' || $credentials['password'] === '') { $response->type = 'GMail'; $response->status = JAuthentication::STATUS_FAILURE; diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index 26a834906b42a..a42371d22e6ce 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -70,7 +70,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' !== '')) { $bindtest = $ldap->bind(); } @@ -126,7 +126,7 @@ public function onUserAuthenticate($credentials, $options, &$response) { $response->status = JAuthentication::STATUS_FAILURE; - if (!strlen($response->error_message)) + if ($response->error_message === '') { $response->error_message = JText::_('JGLOBAL_AUTH_INCORRECT'); } diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index 897f750eda50a..c5b148346fe2c 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -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 === ''); 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 === ''); break; } diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index 3906b243edbc1..e22758b09cf13 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -111,7 +111,7 @@ private function _submitHTTPGet($path, $data) public function verifyResponse($remoteIp, $response) { // Discard empty solution submissions - if ($response == null || strlen($response) == 0) + if ($response == null || $response === '') { $recaptchaResponse = new JReCaptchaResponse(); $recaptchaResponse->success = false; diff --git a/plugins/extension/joomla/joomla.php b/plugins/extension/joomla/joomla.php index 6f1d85c3b0d67..3e63778daa15a 100644 --- a/plugins/extension/joomla/joomla.php +++ b/plugins/extension/joomla/joomla.php @@ -254,7 +254,7 @@ private function processUpdateSites() { $data = trim((string) $updateservers); - if (strlen($data)) + if ($data !== '') { // We have a single entry in the update server line, let us presume this is an extension line $this->addUpdateSite(JText::_('PLG_EXTENSION_JOOMLA_UNKNOWN_SITE'), 'extension', $data, true); diff --git a/plugins/system/cache/cache.php b/plugins/system/cache/cache.php index c3064e5841e5d..b8ef56fa2f061 100644 --- a/plugins/system/cache/cache.php +++ b/plugins/system/cache/cache.php @@ -157,7 +157,7 @@ protected function isExcluded() foreach ($exclusions as $exclusion) { // Make sure the exclusion has some content - if (strlen($exclusion)) + if ($exclusion !== '') { if (preg_match('/' . $exclusion . '/is', $path, $match)) { From 9a1a4b6b8b9225ea1e62935e8bf5a423af220898 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:36:17 +0300 Subject: [PATCH 12/37] Replace strstr() with strpos() --- plugins/system/debug/debug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 2499f4938c6b2..41d4148f371c2 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -233,7 +233,7 @@ public function onAfterRespond() } // No debug for Safari and Chrome redirection. - if (strstr(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''), 'webkit') !== false + if (strpos(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''), 'webkit') !== false && substr($contents, 0, 50) == '' . $value . ''; } From a158cae4c0cde617947e5f805639eeec3cbc148e Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:39:55 +0300 Subject: [PATCH 14/37] Merge unset() --- plugins/system/languagefilter/languagefilter.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index 009b5fefefa81..523d6402349cd 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -107,8 +107,7 @@ public function __construct(&$subject, $config) if (($language->access && !in_array($language->access, $levels)) || (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteLangs()))) { - unset($this->lang_codes[$language->lang_code]); - unset($this->sefs[$language->sef]); + unset($this->lang_codes[$language->lang_code], $this->sefs[$language->sef]); } } } From b3da6e903bed86417cae545378cfa4a376f0ad4a Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:41:03 +0300 Subject: [PATCH 15/37] Inline one-time use variables --- plugins/captcha/recaptcha/recaptchalib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index e22758b09cf13..df3461eebdf98 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -94,9 +94,8 @@ private function _submitHTTPGet($path, $data) { $req = $this->_encodeQS($data); $http = JHttpFactory::getHttp(); - $response = $http->get($path . '?' . $req)->body; - return $response; + return $http->get($path . '?' . $req)->body; } /** From 58b8fbbef16af5f222423b877a870a9fb2100fc9 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:50:09 +0300 Subject: [PATCH 16/37] Type safe string comparison --- plugins/authentication/cookie/cookie.php | 2 +- plugins/authentication/joomla/joomla.php | 4 ++-- plugins/captcha/recaptcha/recaptcha.php | 4 ++-- plugins/content/emailcloak/emailcloak.php | 2 +- plugins/content/joomla/joomla.php | 4 ++-- plugins/content/loadmodule/loadmodule.php | 2 +- plugins/content/pagebreak/pagebreak.php | 6 +++--- .../content/pagenavigation/pagenavigation.php | 4 ++-- plugins/content/vote/vote.php | 4 ++-- plugins/editors/tinymce/tinymce.php | 18 +++++++++--------- plugins/finder/categories/categories.php | 12 ++++++------ plugins/finder/contacts/contacts.php | 18 +++++++++--------- plugins/finder/content/content.php | 18 +++++++++--------- plugins/finder/newsfeeds/newsfeeds.php | 18 +++++++++--------- plugins/finder/tags/tags.php | 12 ++++++------ plugins/search/content/content.php | 2 +- plugins/search/newsfeeds/newsfeeds.php | 2 +- plugins/system/cache/cache.php | 2 +- plugins/system/debug/debug.php | 12 ++++++------ plugins/system/languagecode/languagecode.php | 2 +- .../system/languagefilter/languagefilter.php | 8 ++++---- plugins/system/stats/stats.php | 2 +- .../updatenotification/updatenotification.php | 2 +- plugins/twofactorauth/totp/totp.php | 2 +- plugins/twofactorauth/yubikey/yubikey.php | 2 +- plugins/user/profile/field/dob.php | 2 +- plugins/user/profile/profile.php | 12 ++++++------ 27 files changed, 89 insertions(+), 89 deletions(-) diff --git a/plugins/authentication/cookie/cookie.php b/plugins/authentication/cookie/cookie.php index 675aab57712ef..3d18083ef9f7a 100644 --- a/plugins/authentication/cookie/cookie.php +++ b/plugins/authentication/cookie/cookie.php @@ -224,7 +224,7 @@ public function onUserAfterLogin($options) return false; } - if (isset($options['responseType']) && $options['responseType'] == 'Cookie') + if (isset($options['responseType']) && $options['responseType'] === 'Cookie') { // Logged in using a cookie $cookieName = 'joomla_remember_me_' . JUserHelper::getShortHashedUserAgent(); diff --git a/plugins/authentication/joomla/joomla.php b/plugins/authentication/joomla/joomla.php index 8e234fae67b58..04a9365c13048 100644 --- a/plugins/authentication/joomla/joomla.php +++ b/plugins/authentication/joomla/joomla.php @@ -115,7 +115,7 @@ public function onUserAuthenticate($credentials, $options, &$response) } // Check if the user has enabled two factor authentication - if (empty($otpConfig->method) || ($otpConfig->method == 'none')) + if (empty($otpConfig->method) || ($otpConfig->method === 'none')) { // Warn the user if they are using a secret code but they have not // enabed two factor auth in their account. @@ -166,7 +166,7 @@ public function onUserAuthenticate($credentials, $options, &$response) // Did the user use an OTEP instead? if (empty($otpConfig->otep)) { - if (empty($otpConfig->method) || ($otpConfig->method == 'none')) + if (empty($otpConfig->method) || ($otpConfig->method === 'none')) { // Two factor authentication is not enabled on this account. // Any string is assumed to be a valid OTEP. diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index c5b148346fe2c..0ce368849c0da 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -45,7 +45,7 @@ public function onInit($id = 'dynamic_recaptcha_1') throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY')); } - if ($this->params->get('version', '1.0') == '1.0') + if ($this->params->get('version', '1.0') === '1.0') { JHtml::_('jquery.framework'); @@ -82,7 +82,7 @@ public function onInit($id = 'dynamic_recaptcha_1') */ public function onDisplay($name = null, $id = 'dynamic_recaptcha_1', $class = '') { - if ($this->params->get('version', '1.0') == '1.0') + if ($this->params->get('version', '1.0') === '1.0') { return '
    '; } diff --git a/plugins/content/emailcloak/emailcloak.php b/plugins/content/emailcloak/emailcloak.php index 95f41057ab93f..2c0c7ec5088ce 100644 --- a/plugins/content/emailcloak/emailcloak.php +++ b/plugins/content/emailcloak/emailcloak.php @@ -29,7 +29,7 @@ class PlgContentEmailcloak extends JPlugin public function onContentPrepare($context, &$row, &$params, $page = 0) { // Don't run this plugin when the content is being indexed - if ($context == 'com_finder.indexer') + if ($context === 'com_finder.indexer') { return true; } diff --git a/plugins/content/joomla/joomla.php b/plugins/content/joomla/joomla.php index 240193fd07758..741258af3093c 100644 --- a/plugins/content/joomla/joomla.php +++ b/plugins/content/joomla/joomla.php @@ -33,7 +33,7 @@ class PlgContentJoomla extends JPlugin public function onContentAfterSave($context, $article, $isNew) { // Check we are handling the frontend edit form. - if ($context != 'com_content.form') + if ($context !== 'com_content.form') { return true; } @@ -108,7 +108,7 @@ public function onContentAfterSave($context, $article, $isNew) public function onContentBeforeDelete($context, $data) { // Skip plugin if we are deleting something other than categories - if ($context != 'com_categories.category') + if ($context !== 'com_categories.category') { return true; } diff --git a/plugins/content/loadmodule/loadmodule.php b/plugins/content/loadmodule/loadmodule.php index 4aa7ae0bd5c3d..0814c8d0c7d3a 100644 --- a/plugins/content/loadmodule/loadmodule.php +++ b/plugins/content/loadmodule/loadmodule.php @@ -36,7 +36,7 @@ class PlgContentLoadmodule extends JPlugin public function onContentPrepare($context, &$article, &$params, $page = 0) { // Don't run this plugin when the content is being indexed - if ($context == 'com_finder.indexer') + if ($context === 'com_finder.indexer') { return true; } diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 8eb3730e81342..306a843343e47 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -42,7 +42,7 @@ class PlgContentPagebreak extends JPlugin */ public function onContentPrepare($context, &$row, &$params, $page = 0) { - $canProceed = $context == 'com_content.article'; + $canProceed = $context === 'com_content.article'; if (!$canProceed) { @@ -85,7 +85,7 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $page = 0; } - if ($params->get('intro_only') || $params->get('popup') || $full || $view != 'article') + if ($params->get('intro_only') || $params->get('popup') || $full || $view !== 'article') { $row->text = preg_replace($regex, '', $row->text); @@ -156,7 +156,7 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) // Reset the text, we already hold it in the $text array. $row->text = ''; - if ($style == 'pages') + if ($style === 'pages') { // Display TOC. if ($hasToc) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index f468b19d662e0..e4e6bd50164d3 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -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')) { $db = JFactory::getDbo(); $user = JFactory::getUser(); @@ -70,7 +70,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) } // Additional check for invalid sort ordering. - if ($order_method == 'front') + if ($order_method === 'front') { $order_method = ''; } diff --git a/plugins/content/vote/vote.php b/plugins/content/vote/vote.php index af91143eac7a2..fb9e7b628becc 100644 --- a/plugins/content/vote/vote.php +++ b/plugins/content/vote/vote.php @@ -32,7 +32,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page=0) { $parts = explode('.', $context); - if ($parts[0] != 'com_content') + if ($parts[0] !== 'com_content') { return false; } @@ -72,7 +72,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page=0) $html .= $img; $html .= ''; - if ($view == 'article' && $row->state == 1) + if ($view === 'article' && $row->state == 1) { $uri = clone JUri::getInstance(); $uri->setVar('hitcount', '0'); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 3f946df454e61..efd6962767aac 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -332,9 +332,9 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $resizing = $this->params->get('resizing', '1'); $resize_horizontal = $this->params->get('resize_horizontal', '1'); - if ($resizing || $resizing == 'true') + if ($resizing || $resizing === 'true') { - if ($resize_horizontal || $resize_horizontal == 'true') + if ($resize_horizontal || $resize_horizontal === 'true') { $resizing = 'resize: "both",'; } @@ -742,7 +742,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons } // Is Joomla installed in subdirectory - if (JUri::root(true) != '/') + if (JUri::root(true) !== '/') { $isSubDir = JUri::root(true); } @@ -1013,7 +1013,7 @@ private function tinyButtons($name, $excluded) $options = $button->get('options'); $icon = $button->get('name'); - if ($button->get('link') != '#') + if ($button->get('link') !== '#') { $href = JUri::base() . $button->get('link'); } @@ -1147,11 +1147,11 @@ protected static function getGlobalFilters() $filterData = $filters->$groupId; $filterType = strtoupper($filterData->filter_type); - if ($filterType == 'NH') + if ($filterType === 'NH') { // Maximum HTML filtering. } - elseif ($filterType == 'NONE') + elseif ($filterType === 'NONE') { // No HTML filtering. $unfiltered = true; @@ -1187,13 +1187,13 @@ protected static function getGlobalFilters() // Collect the blacklist or whitelist tags and attributes. // Each list is cummulative. - if ($filterType == 'BL') + if ($filterType === 'BL') { $blackList = true; $blackListTags = array_merge($blackListTags, $tempTags); $blackListAttributes = array_merge($blackListAttributes, $tempAttributes); } - elseif ($filterType == 'CBL') + elseif ($filterType === 'CBL') { // Only set to true if Tags or Attributes were added if ($tempTags || $tempAttributes) @@ -1203,7 +1203,7 @@ protected static function getGlobalFilters() $customListAttributes = array_merge($customListAttributes, $tempAttributes); } } - elseif ($filterType == 'WL') + elseif ($filterType === 'WL') { $whiteList = true; $whiteListTags = array_merge($whiteListTags, $tempTags); diff --git a/plugins/finder/categories/categories.php b/plugins/finder/categories/categories.php index fb15f487ebf65..ac4d157441d26 100644 --- a/plugins/finder/categories/categories.php +++ b/plugins/finder/categories/categories.php @@ -89,11 +89,11 @@ class PlgFinderCategories extends FinderIndexerAdapter */ public function onFinderDelete($context, $table) { - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { $id = $table->id; } - elseif ($context == 'com_finder.index') + elseif ($context === 'com_finder.index') { $id = $table->link_id; } @@ -123,7 +123,7 @@ public function onFinderDelete($context, $table) public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle categories here. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Check if the access levels are different. if (!$isNew && $this->old_access != $row->access) @@ -161,7 +161,7 @@ public function onFinderAfterSave($context, $row, $isNew) public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle categories here. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Query the database for the old access level and the parent if the item isn't new. if (!$isNew) @@ -190,7 +190,7 @@ public function onFinderBeforeSave($context, $row, $isNew) public function onFinderChangeState($context, $pks, $value) { // We only want to handle categories here. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { /* * The category published state is tied to the parent category @@ -224,7 +224,7 @@ public function onFinderChangeState($context, $pks, $value) } // Handle when the plugin is disabled. - if ($context == 'com_plugins.plugin' && $value === 0) + if ($context === 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index 804631830e58f..bd547881047c3 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -92,7 +92,7 @@ class PlgFinderContacts extends FinderIndexerAdapter public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_contact categories - if ($extension == 'com_contact') + if ($extension === 'com_contact') { $this->categoryStateChange($pks, $value); } @@ -113,11 +113,11 @@ public function onFinderCategoryChangeState($extension, $pks, $value) */ public function onFinderAfterDelete($context, $table) { - if ($context == 'com_contact.contact') + if ($context === 'com_contact.contact') { $id = $table->id; } - elseif ($context == 'com_finder.index') + elseif ($context === 'com_finder.index') { $id = $table->link_id; } @@ -144,7 +144,7 @@ public function onFinderAfterDelete($context, $table) public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle contacts here - if ($context == 'com_contact.contact') + if ($context === 'com_contact.contact') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) @@ -158,7 +158,7 @@ public function onFinderAfterSave($context, $row, $isNew) } // Check for access changes in the category - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) @@ -187,7 +187,7 @@ public function onFinderAfterSave($context, $row, $isNew) public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle contacts here - if ($context == 'com_contact.contact') + if ($context === 'com_contact.contact') { // Query the database for the old access level if the item isn't new if (!$isNew) @@ -197,7 +197,7 @@ public function onFinderBeforeSave($context, $row, $isNew) } // Check for access levels from the category - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) @@ -225,13 +225,13 @@ public function onFinderBeforeSave($context, $row, $isNew) public function onFinderChangeState($context, $pks, $value) { // We only want to handle contacts here - if ($context == 'com_contact.contact') + if ($context === 'com_contact.contact') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) + if ($context === 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index 6687543e69526..3bc314bd74e6d 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -84,7 +84,7 @@ class PlgFinderContent extends FinderIndexerAdapter public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_content categories. - if ($extension == 'com_content') + if ($extension === 'com_content') { $this->categoryStateChange($pks, $value); } @@ -103,11 +103,11 @@ public function onFinderCategoryChangeState($extension, $pks, $value) */ public function onFinderAfterDelete($context, $table) { - if ($context == 'com_content.article') + if ($context === 'com_content.article') { $id = $table->id; } - elseif ($context == 'com_finder.index') + elseif ($context === 'com_finder.index') { $id = $table->link_id; } @@ -138,7 +138,7 @@ public function onFinderAfterDelete($context, $table) public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle articles here. - if ($context == 'com_content.article' || $context == 'com_content.form') + if ($context === 'com_content.article' || $context === 'com_content.form') { // Check if the access levels are different. if (!$isNew && $this->old_access != $row->access) @@ -152,7 +152,7 @@ public function onFinderAfterSave($context, $row, $isNew) } // Check for access changes in the category. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Check if the access levels are different. if (!$isNew && $this->old_cataccess != $row->access) @@ -180,7 +180,7 @@ public function onFinderAfterSave($context, $row, $isNew) public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle articles here. - if ($context == 'com_content.article' || $context == 'com_content.form') + if ($context === 'com_content.article' || $context === 'com_content.form') { // Query the database for the old access level if the item isn't new. if (!$isNew) @@ -190,7 +190,7 @@ public function onFinderBeforeSave($context, $row, $isNew) } // Check for access levels from the category. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Query the database for the old access level if the item isn't new. if (!$isNew) @@ -218,13 +218,13 @@ public function onFinderBeforeSave($context, $row, $isNew) public function onFinderChangeState($context, $pks, $value) { // We only want to handle articles here. - if ($context == 'com_content.article' || $context == 'com_content.form') + if ($context === 'com_content.article' || $context === 'com_content.form') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled. - if ($context == 'com_plugins.plugin' && $value === 0) + if ($context === 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } diff --git a/plugins/finder/newsfeeds/newsfeeds.php b/plugins/finder/newsfeeds/newsfeeds.php index 34cafb5290e07..60e3d293d8026 100644 --- a/plugins/finder/newsfeeds/newsfeeds.php +++ b/plugins/finder/newsfeeds/newsfeeds.php @@ -92,7 +92,7 @@ class PlgFinderNewsfeeds extends FinderIndexerAdapter public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_newsfeeds categories. - if ($extension == 'com_newsfeeds') + if ($extension === 'com_newsfeeds') { $this->categoryStateChange($pks, $value); } @@ -111,11 +111,11 @@ public function onFinderCategoryChangeState($extension, $pks, $value) */ public function onFinderAfterDelete($context, $table) { - if ($context == 'com_newsfeeds.newsfeed') + if ($context === 'com_newsfeeds.newsfeed') { $id = $table->id; } - elseif ($context == 'com_finder.index') + elseif ($context === 'com_finder.index') { $id = $table->link_id; } @@ -146,7 +146,7 @@ public function onFinderAfterDelete($context, $table) public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle newsfeeds here. - if ($context == 'com_newsfeeds.newsfeed') + if ($context === 'com_newsfeeds.newsfeed') { // Check if the access levels are different. if (!$isNew && $this->old_access != $row->access) @@ -160,7 +160,7 @@ public function onFinderAfterSave($context, $row, $isNew) } // Check for access changes in the category. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Check if the access levels are different. if (!$isNew && $this->old_cataccess != $row->access) @@ -188,7 +188,7 @@ public function onFinderAfterSave($context, $row, $isNew) public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle newsfeeds here. - if ($context == 'com_newsfeeds.newsfeed') + if ($context === 'com_newsfeeds.newsfeed') { // Query the database for the old access level if the item isn't new. if (!$isNew) @@ -198,7 +198,7 @@ public function onFinderBeforeSave($context, $row, $isNew) } // Check for access levels from the category. - if ($context == 'com_categories.category') + if ($context === 'com_categories.category') { // Query the database for the old access level if the item isn't new. if (!$isNew) @@ -226,13 +226,13 @@ public function onFinderBeforeSave($context, $row, $isNew) public function onFinderChangeState($context, $pks, $value) { // We only want to handle newsfeeds here. - if ($context == 'com_newsfeeds.newsfeed') + if ($context === 'com_newsfeeds.newsfeed') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled. - if ($context == 'com_plugins.plugin' && $value === 0) + if ($context === 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } diff --git a/plugins/finder/tags/tags.php b/plugins/finder/tags/tags.php index 8f6e8abd0e074..7d048a4f0845b 100644 --- a/plugins/finder/tags/tags.php +++ b/plugins/finder/tags/tags.php @@ -89,11 +89,11 @@ class PlgFinderTags extends FinderIndexerAdapter */ public function onFinderAfterDelete($context, $table) { - if ($context == 'com_tags.tag') + if ($context === 'com_tags.tag') { $id = $table->id; } - elseif ($context == 'com_finder.index') + elseif ($context === 'com_finder.index') { $id = $table->link_id; } @@ -120,7 +120,7 @@ public function onFinderAfterDelete($context, $table) public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle tags here. - if ($context == 'com_tags.tag') + if ($context === 'com_tags.tag') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) @@ -153,7 +153,7 @@ public function onFinderAfterSave($context, $row, $isNew) public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle news feeds here - if ($context == 'com_tags.tag') + if ($context === 'com_tags.tag') { // Query the database for the old access level if the item isn't new if (!$isNew) @@ -181,12 +181,12 @@ public function onFinderBeforeSave($context, $row, $isNew) public function onFinderChangeState($context, $pks, $value) { // We only want to handle tags here - if ($context == 'com_tags.tag') + if ($context === 'com_tags.tag') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) + if ($context === 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } diff --git a/plugins/search/content/content.php b/plugins/search/content/content.php index 9c94e4feb8b55..68124c5e0dcbc 100644 --- a/plugins/search/content/content.php +++ b/plugins/search/content/content.php @@ -113,7 +113,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $wheres[] = implode(' OR ', $wheres2); } - $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; + $where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } diff --git a/plugins/search/newsfeeds/newsfeeds.php b/plugins/search/newsfeeds/newsfeeds.php index dbaa2327591bf..e3608263dbd9c 100644 --- a/plugins/search/newsfeeds/newsfeeds.php +++ b/plugins/search/newsfeeds/newsfeeds.php @@ -122,7 +122,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $wheres[] = implode(' OR ', $wheres2); } - $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; + $where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } diff --git a/plugins/system/cache/cache.php b/plugins/system/cache/cache.php index b8ef56fa2f061..70dbca8d10973 100644 --- a/plugins/system/cache/cache.php +++ b/plugins/system/cache/cache.php @@ -65,7 +65,7 @@ public function onAfterInitialise() return; } - if ($user->get('guest') && $app->input->getMethod() == 'GET') + if ($user->get('guest') && $app->input->getMethod() === 'GET') { $this->_cache->setCaching(true); } diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index fb76ee57033e0..a94b9e17fa5f2 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -1281,7 +1281,7 @@ protected function tableToHtml($table, &$hasWarnings) } // Treat special columns. - if ($k == 'Duration') + if ($k === 'Duration') { if ($td >= 0.001 && ($td == $durations[0] || (isset($durations[1]) && $td == $durations[1]))) { @@ -1297,13 +1297,13 @@ protected function tableToHtml($table, &$hasWarnings) // Display duration in milliseconds with the unit instead of seconds. $html[] = sprintf('%.2f ms', $td * 1000); } - elseif ($k == 'Error') + elseif ($k === 'Error') { // An error in the EXPLAIN query occurred, display it instead of the result (means original query had syntax error most probably). $html[] = '' . htmlspecialchars($td); $hasWarnings = true; } - elseif ($k == 'key') + elseif ($k === 'key') { if ($td === 'NULL') { @@ -1318,7 +1318,7 @@ protected function tableToHtml($table, &$hasWarnings) $html[] = '' . htmlspecialchars($td) . ''; } } - elseif ($k == 'Extra') + elseif ($k === 'Extra') { $htmlTd = htmlspecialchars($td); @@ -1772,7 +1772,7 @@ protected function displayLogs() array_filter( $this->logEntries, function($logEntry) { - return $logEntry->category == 'databasequery'; + return $logEntry->category === 'databasequery'; } ) ); @@ -1784,7 +1784,7 @@ protected function displayLogs() array_filter( $this->logEntries, function($logEntry) { - return $logEntry->category == 'deprecated'; + return $logEntry->category === 'deprecated'; } ) ); diff --git a/plugins/system/languagecode/languagecode.php b/plugins/system/languagecode/languagecode.php index 16f640259e961..042db1a306991 100644 --- a/plugins/system/languagecode/languagecode.php +++ b/plugins/system/languagecode/languagecode.php @@ -124,7 +124,7 @@ public function onContentPrepareForm($form, $data) } // Check we are manipulating the languagecode plugin. - if ($form->getName() != 'com_plugins.plugin' || !$form->getField('languagecodeplugin', 'params')) + if ($form->getName() !== 'com_plugins.plugin' || !$form->getField('languagecodeplugin', 'params')) { return true; } diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index 523d6402349cd..10bf5c73d6a5e 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -367,7 +367,7 @@ public function parseRule(&$router, &$uri) // We are called via POST. We don't care about the language // and simply set the default language as our current language. - if ($this->app->input->getMethod() == 'POST' + if ($this->app->input->getMethod() === 'POST' || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) { @@ -649,7 +649,7 @@ public function onUserLogin($user, $options = array()) // We are on a Home page, we redirect to the user site language home page $item = $menu->getDefault($lang_code); - if ($item && $item->language != $active->language && $item->language != '*') + if ($item && $item->language != $active->language && $item->language !== '*') { $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id); $foundAssociation = true; @@ -690,7 +690,7 @@ public function onAfterDispatch() { $doc = JFactory::getDocument(); - if ($this->app->isSite() && $this->params->get('alternate_meta', 1) && $doc->getType() == 'html') + if ($this->app->isSite() && $this->params->get('alternate_meta', 1) && $doc->getType() === 'html') { $languages = $this->lang_codes; $homes = JLanguageMultilang::getSiteHomePages(); @@ -787,7 +787,7 @@ public function onAfterDispatch() if ($this->params->get('xdefault', 1)) { $xdefault_language = $this->params->get('xdefault_language', $this->default_lang); - $xdefault_language = ( $xdefault_language == 'default' ) ? $this->default_lang : $xdefault_language; + $xdefault_language = ( $xdefault_language === 'default' ) ? $this->default_lang : $xdefault_language; if (isset($languages[$xdefault_language])) { diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php index 423572f3d31e0..a65b134a9af25 100644 --- a/plugins/system/stats/stats.php +++ b/plugins/system/stats/stats.php @@ -402,7 +402,7 @@ private function isUpdateRequired() */ private function isAjaxRequest() { - return strtolower($this->app->input->server->get('HTTP_X_REQUESTED_WITH', '')) == 'xmlhttprequest'; + return strtolower($this->app->input->server->get('HTTP_X_REQUESTED_WITH', '')) === 'xmlhttprequest'; } /** diff --git a/plugins/system/updatenotification/updatenotification.php b/plugins/system/updatenotification/updatenotification.php index e26540163bd2b..d7f9018259857 100644 --- a/plugins/system/updatenotification/updatenotification.php +++ b/plugins/system/updatenotification/updatenotification.php @@ -154,7 +154,7 @@ public function onAfterRender() // If we're here, we have updates. First, get a link to the Joomla! Update component. $baseURL = JUri::base(); $baseURL = rtrim($baseURL, '/'); - $baseURL .= (substr($baseURL, -13) != 'administrator') ? '/administrator/' : '/'; + $baseURL .= (substr($baseURL, -13) !== 'administrator') ? '/administrator/' : '/'; $baseURL .= 'index.php?option=com_joomlaupdate'; $uri = new JUri($baseURL); diff --git a/plugins/twofactorauth/totp/totp.php b/plugins/twofactorauth/totp/totp.php index b476c42dde103..f90fcfe276e95 100644 --- a/plugins/twofactorauth/totp/totp.php +++ b/plugins/twofactorauth/totp/totp.php @@ -110,7 +110,7 @@ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) $url = $totp->getUrl($username, $hostname, $secret); // Is this a new TOTP setup? If so, we'll have to show the code validation field. - $new_totp = $otpConfig->method != 'totp'; + $new_totp = $otpConfig->method !== 'totp'; // Start output buffering @ob_start(); diff --git a/plugins/twofactorauth/yubikey/yubikey.php b/plugins/twofactorauth/yubikey/yubikey.php index 3f23b016d8d3e..d78a60e39ac19 100644 --- a/plugins/twofactorauth/yubikey/yubikey.php +++ b/plugins/twofactorauth/yubikey/yubikey.php @@ -343,7 +343,7 @@ public function validateYubikeyOtp($otp) } // Validate the response - We need an OK message reply - if ($data['status'] != 'OK') + if ($data['status'] !== 'OK') { return false; } diff --git a/plugins/user/profile/field/dob.php b/plugins/user/profile/field/dob.php index 4761a52d7beda..e3e0d8e4a0c8f 100644 --- a/plugins/user/profile/field/dob.php +++ b/plugins/user/profile/field/dob.php @@ -50,7 +50,7 @@ protected function getLabel() $view = $app->input->getString('view', ''); // Only display the tip when editing profile - if ($app->isAdmin() || $view == 'profile' || $view == 'registration') + if ($app->isAdmin() || $view === 'profile' || $view === 'registration') { $layout = new JLayoutFile('plugins.user.profile.fields.dob'); $info = $layout->render(array('text' => $text)); diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index de9536ac7d9ed..e6b1b7c3fd7dd 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -263,7 +263,7 @@ public function onContentPrepareForm($form, $data) // Change fields description when displayed in frontend or backend profile editing $app = JFactory::getApplication(); - if ($app->isSite() || $name == 'com_users.user' || $name == 'com_admin.profile') + if ($app->isSite() || $name === 'com_users.user' || $name === 'com_admin.profile') { $form->setFieldAttribute('address1', 'description', 'PLG_USER_PROFILE_FILL_FIELD_DESC_SITE', 'profile'); $form->setFieldAttribute('address2', 'description', 'PLG_USER_PROFILE_FILL_FIELD_DESC_SITE', 'profile'); @@ -283,7 +283,7 @@ public function onContentPrepareForm($form, $data) $tosenabled = $this->params->get('register-require_tos', 0); // We need to be in the registration form, field needs to be enabled and we need an article ID - if ($name != 'com_users.registration' || !$tosenabled || !$tosarticle) + if ($name !== 'com_users.registration' || !$tosenabled || !$tosarticle) { // We only want the TOS in the registration form $form->removeField('tos', 'profile'); @@ -297,7 +297,7 @@ public function onContentPrepareForm($form, $data) foreach ($fields as $field) { // Case using the users manager in admin - if ($name == 'com_users.user') + if ($name === 'com_users.user') { // Remove the field if it is disabled in registration and profile if ($this->params->get('register-require_' . $field, 1) == 0 @@ -307,7 +307,7 @@ public function onContentPrepareForm($form, $data) } } // Case registration - elseif ($name == 'com_users.registration') + elseif ($name === 'com_users.registration') { // Toggle whether the field is required. if ($this->params->get('register-require_' . $field, 1) > 0) @@ -320,7 +320,7 @@ public function onContentPrepareForm($form, $data) } } // Case profile in site or admin - elseif ($name == 'com_users.profile' || $name == 'com_admin.profile') + elseif ($name === 'com_users.profile' || $name === 'com_admin.profile') { // Toggle whether the field is required. if ($this->params->get('profile-require_' . $field, 1) > 0) @@ -376,7 +376,7 @@ 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')) + if (($task === 'register') && $tosenabled && $tosarticle && ($option === 'com_users')) { // Check that the tos is checked. if (!$data['profile']['tos']) From 8f28982f22d06f8dfcd3dac83f04d579da4c1f3a Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:53:00 +0300 Subject: [PATCH 17/37] Remove unused variable --- plugins/editors/codemirror/codemirror.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/codemirror/codemirror.php b/plugins/editors/codemirror/codemirror.php index d3c6baa5c41b5..f198eb0235aba 100644 --- a/plugins/editors/codemirror/codemirror.php +++ b/plugins/editors/codemirror/codemirror.php @@ -57,7 +57,7 @@ public function onInit() $doc = JFactory::getDocument(); // Codemirror shall have its own group of plugins to modify and extend its behavior - $result = JPluginHelper::importPlugin('editors_codemirror'); + JPluginHelper::importPlugin('editors_codemirror'); $dispatcher = JEventDispatcher::getInstance(); // At this point, params can be modified by a plugin before going to the layout renderer. From 776666bf2e2cb0660dc83464ca4a42794f3e8293 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 14:59:58 +0300 Subject: [PATCH 18/37] Merge if statements into parents --- plugins/content/pagebreak/pagebreak.php | 16 +++++----------- plugins/search/categories/categories.php | 7 ++----- plugins/search/contacts/contacts.php | 7 ++----- plugins/search/content/content.php | 7 ++----- plugins/search/newsfeeds/newsfeeds.php | 7 ++----- plugins/search/tags/tags.php | 7 ++----- plugins/system/debug/debug.php | 9 +++------ plugins/user/profile/profile.php | 9 +++------ 8 files changed, 21 insertions(+), 48 deletions(-) diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 306a843343e47..c82ed50147554 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -137,19 +137,13 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $hasToc = $this->params->get('multipage_toc', 1); // Adds heading or title to Title. - if ($title) + if ($title && $page && @$matches[$page - 1][2]) { - if ($page) - { - if ($page && @$matches[$page - 1][2]) - { - $attrs = JUtility::parseAttributes($matches[$page - 1][1]); + $attrs = JUtility::parseAttributes($matches[$page - 1][1]); - if (@$attrs['title']) - { - $row->page_title = $attrs['title']; - } - } + if (@$attrs['title']) + { + $row->page_title = $attrs['title']; } } diff --git a/plugins/search/categories/categories.php b/plugins/search/categories/categories.php index 5613a49c43f96..1513a17c00d58 100644 --- a/plugins/search/categories/categories.php +++ b/plugins/search/categories/categories.php @@ -65,12 +65,9 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; - if (is_array($areas)) + if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } + return array(); } $sContent = $this->params->get('search_content', 1); diff --git a/plugins/search/contacts/contacts.php b/plugins/search/contacts/contacts.php index 46e800b3f099b..dd6c526592ec7 100644 --- a/plugins/search/contacts/contacts.php +++ b/plugins/search/contacts/contacts.php @@ -64,12 +64,9 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); - if (is_array($areas)) + if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } + return array(); } $sContent = $this->params->get('search_content', 1); diff --git a/plugins/search/content/content.php b/plugins/search/content/content.php index 68124c5e0dcbc..c5171021c3d28 100644 --- a/plugins/search/content/content.php +++ b/plugins/search/content/content.php @@ -59,12 +59,9 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $searchText = $text; - if (is_array($areas)) + if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } + return array(); } $sContent = $this->params->get('search_content', 1); diff --git a/plugins/search/newsfeeds/newsfeeds.php b/plugins/search/newsfeeds/newsfeeds.php index e3608263dbd9c..791a59d0c647a 100644 --- a/plugins/search/newsfeeds/newsfeeds.php +++ b/plugins/search/newsfeeds/newsfeeds.php @@ -62,12 +62,9 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); - if (is_array($areas)) + if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } + return array(); } $sContent = $this->params->get('search_content', 1); diff --git a/plugins/search/tags/tags.php b/plugins/search/tags/tags.php index d9098f09ccecd..bf592aa505a3b 100644 --- a/plugins/search/tags/tags.php +++ b/plugins/search/tags/tags.php @@ -66,12 +66,9 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $section = JText::_('PLG_SEARCH_TAGS_TAGS'); $limit = $this->params->def('search_limit', 50); - if (is_array($areas)) + if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas()))) { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } + return array(); } $text = trim($text); diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index a94b9e17fa5f2..c55babb704ecf 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -785,13 +785,10 @@ protected function displayQueries() // Run a SHOW PROFILE query. $profile = ''; - if (in_array($db->name, array('mysqli', 'mysql', 'pdomysql'))) + if (in_array($db->name, array('mysqli', 'mysql', 'pdomysql')) && isset($this->sqlShowProfileEach[$id])) { - if (isset($this->sqlShowProfileEach[$id])) - { - $profileTable = $this->sqlShowProfileEach[$id]; - $profile = $this->tableToHtml($profileTable, $hasWarningsInProfile); - } + $profileTable = $this->sqlShowProfileEach[$id]; + $profile = $this->tableToHtml($profileTable, $hasWarningsInProfile); } // How heavy should the string length count: 0 - 1. diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index e6b1b7c3fd7dd..53edb46adfb0e 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -376,13 +376,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']) { - // Check that the tos is checked. - if (!$data['profile']['tos']) - { - throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); - } + throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); } return true; From 7b70c0646a40b3ad72b2d05b9fa8488c38071a75 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 15:16:58 +0300 Subject: [PATCH 19/37] Optimize non-optimal if conditions. --- plugins/authentication/gmail/gmail.php | 2 +- plugins/authentication/ldap/ldap.php | 2 +- plugins/content/pagebreak/pagebreak.php | 2 +- plugins/editors/tinymce/tinymce.php | 2 +- plugins/system/debug/debug.php | 9 ++++---- plugins/system/highlight/highlight.php | 2 +- .../system/languagefilter/languagefilter.php | 22 ++++++++++--------- plugins/system/logout/logout.php | 2 +- plugins/system/redirect/redirect.php | 2 +- plugins/user/profile/field/dob.php | 2 +- plugins/user/profile/profile.php | 4 ++-- 11 files changed, 27 insertions(+), 24 deletions(-) diff --git a/plugins/authentication/gmail/gmail.php b/plugins/authentication/gmail/gmail.php index 017c9035f5385..7733529796a35 100644 --- a/plugins/authentication/gmail/gmail.php +++ b/plugins/authentication/gmail/gmail.php @@ -35,7 +35,7 @@ public function onUserAuthenticate($credentials, $options, &$response) $this->loadLanguage(); // No backend authentication - if (JFactory::getApplication()->isAdmin() && !$this->params->get('backendLogin', 0)) + if (!$this->params->get('backendLogin', 0) && JFactory::getApplication()->isAdmin()) { return; } diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index a42371d22e6ce..5860f348d6cfc 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -84,7 +84,7 @@ public function onUserAuthenticate($credentials, $options, &$response) // Search for users DN $binddata = $ldap->simple_search(str_replace('[search]', $credentials['username'], $this->params->get('search_string'))); - if (isset($binddata[0]) && isset($binddata[0]['dn'])) + if (isset($binddata[0], $binddata[0]['dn'])) { // Verify Users Credentials $success = $ldap->bind($binddata[0]['dn'], $credentials['password'], 1); diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index c82ed50147554..d2213d21ac4ba 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -85,7 +85,7 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $page = 0; } - if ($params->get('intro_only') || $params->get('popup') || $full || $view !== 'article') + if ($view !== 'article' || $full || $params->get('intro_only') || $params->get('popup')) { $row->text = preg_replace($regex, '', $row->text); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index efd6962767aac..8cc756715e0b4 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -1051,7 +1051,7 @@ private function tinyButtons($name, $excluded) icon: \"" . $icon . "\", onclick: function () {"; - if ($button->get('modal') || $href) + if ($href || $button->get('modal')) { $tempConstructor .= " var modalOptions = { diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index c55babb704ecf..77db977045faa 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -233,8 +233,9 @@ public function onAfterRespond() } // No debug for Safari and Chrome redirection. - if (strpos(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''), 'webkit') !== false - && strpos($contents, 'default_lang]) && $remove_default_prefix) + if ($remove_default_prefix && isset($languages[$this->default_lang])) { $languages[$this->default_lang]->link = preg_replace('|/' . $languages[$this->default_lang]->sef . '/|', '/', $languages[$this->default_lang]->link, 1); diff --git a/plugins/system/logout/logout.php b/plugins/system/logout/logout.php index 0852c2f873e00..84f86497b0bc3 100644 --- a/plugins/system/logout/logout.php +++ b/plugins/system/logout/logout.php @@ -31,7 +31,7 @@ public function __construct(&$subject, $config) $input = JFactory::getApplication()->input; $hash = JApplicationHelper::getHash('PlgSystemLogout'); - if (JFactory::getApplication()->isSite() && $input->cookie->getString($hash)) + if ($input->cookie->getString($hash) && JFactory::getApplication()->isSite()) { // Destroy the cookie. $conf = JFactory::getConfig(); diff --git a/plugins/system/redirect/redirect.php b/plugins/system/redirect/redirect.php index e13f34a579443..931b1b6cd516f 100644 --- a/plugins/system/redirect/redirect.php +++ b/plugins/system/redirect/redirect.php @@ -192,7 +192,7 @@ private static function doErrorHandling($error) $oldUrlParts = parse_url($redirect->old_url); - if (empty($oldUrlParts['query']) && $urlQuery !== '') + if ($urlQuery !== '' && empty($oldUrlParts['query'])) { $redirect->new_url .= '?' . $urlQuery; } diff --git a/plugins/user/profile/field/dob.php b/plugins/user/profile/field/dob.php index e3e0d8e4a0c8f..396343eb4a944 100644 --- a/plugins/user/profile/field/dob.php +++ b/plugins/user/profile/field/dob.php @@ -50,7 +50,7 @@ protected function getLabel() $view = $app->input->getString('view', ''); // Only display the tip when editing profile - if ($app->isAdmin() || $view === 'profile' || $view === 'registration') + if ($view === 'registration' || $view === 'profile' || $app->isAdmin()) { $layout = new JLayoutFile('plugins.user.profile.fields.dob'); $info = $layout->render(array('text' => $text)); diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index 53edb46adfb0e..dd92eea1e8f7f 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -70,7 +70,7 @@ public function onContentPrepareData($context, $data) { $userId = isset($data->id) ? $data->id : 0; - if (!isset($data->profile) and $userId > 0) + if (!isset($data->profile) && $userId > 0) { // Load the profile data from the database. $db = JFactory::getDbo(); @@ -263,7 +263,7 @@ public function onContentPrepareForm($form, $data) // Change fields description when displayed in frontend or backend profile editing $app = JFactory::getApplication(); - if ($app->isSite() || $name === 'com_users.user' || $name === 'com_admin.profile') + if ($name === 'com_users.user' || $name === 'com_admin.profile' || $app->isSite()) { $form->setFieldAttribute('address1', 'description', 'PLG_USER_PROFILE_FILL_FIELD_DESC_SITE', 'profile'); $form->setFieldAttribute('address2', 'description', 'PLG_USER_PROFILE_FILL_FIELD_DESC_SITE', 'profile'); From af3e78bfabf0801c1432f187a9ba8ee273c3bf12 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Sep 2016 15:39:40 +0300 Subject: [PATCH 20/37] More type-safe comparisons --- plugins/authentication/cookie/cookie.php | 4 +-- plugins/authentication/gmail/gmail.php | 2 +- plugins/authentication/joomla/joomla.php | 2 +- plugins/captcha/recaptcha/recaptcha.php | 8 +++--- plugins/captcha/recaptcha/recaptchalib.php | 6 ++--- plugins/content/contact/contact.php | 2 +- plugins/content/pagebreak/pagebreak.php | 10 +++---- plugins/editors-xtd/image/image.php | 2 +- plugins/editors/tinymce/tinymce.php | 8 +++--- plugins/finder/categories/categories.php | 2 +- plugins/finder/contacts/contacts.php | 2 +- plugins/finder/content/content.php | 2 +- plugins/finder/newsfeeds/newsfeeds.php | 2 +- plugins/finder/tags/tags.php | 2 +- .../extensionupdate/extensionupdate.php | 2 +- .../quickicon/joomlaupdate/joomlaupdate.php | 2 +- plugins/search/categories/categories.php | 2 +- plugins/search/contacts/contacts.php | 2 +- plugins/search/content/content.php | 2 +- plugins/search/newsfeeds/newsfeeds.php | 2 +- plugins/search/tags/tags.php | 4 +-- plugins/system/debug/debug.php | 2 +- .../system/languagefilter/languagefilter.php | 26 +++++++++---------- .../postinstall/updatecachetime.php | 2 +- .../totp/postinstall/actions.php | 2 +- plugins/twofactorauth/totp/totp.php | 18 ++++++------- plugins/twofactorauth/yubikey/yubikey.php | 14 +++++----- .../user/contactcreator/contactcreator.php | 2 +- plugins/user/joomla/joomla.php | 4 +-- plugins/user/profile/field/tos.php | 2 +- 30 files changed, 71 insertions(+), 71 deletions(-) diff --git a/plugins/authentication/cookie/cookie.php b/plugins/authentication/cookie/cookie.php index 3d18083ef9f7a..c2629f2c1a68e 100644 --- a/plugins/authentication/cookie/cookie.php +++ b/plugins/authentication/cookie/cookie.php @@ -72,7 +72,7 @@ public function onUserAuthenticate($credentials, $options, &$response) $cookieArray = explode('.', $cookieValue); // Check for valid cookie value - if (count($cookieArray) != 2) + if (count($cookieArray) !== 2) { // Destroy the cookie in the browser. $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain')); @@ -279,7 +279,7 @@ public function onUserAfterLogin($options) $errorCount++; // We'll let this query fail up to 5 times before giving up, there's probably a bigger issue at this point - if ($errorCount == 5) + if ($errorCount === 5) { return false; } diff --git a/plugins/authentication/gmail/gmail.php b/plugins/authentication/gmail/gmail.php index 7733529796a35..f085decd8621d 100644 --- a/plugins/authentication/gmail/gmail.php +++ b/plugins/authentication/gmail/gmail.php @@ -191,7 +191,7 @@ public function onUserAuthenticate($credentials, $options, &$response) foreach ($localUsers as $localUser) { // Local user exists with same username but different email address - if ($email != $localUser->email) + if ($email !== $localUser->email) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::sprintf('JGLOBAL_AUTH_FAILED', JText::_('PLG_GMAIL_ERROR_LOCAL_USERNAME_CONFLICT')); diff --git a/plugins/authentication/joomla/joomla.php b/plugins/authentication/joomla/joomla.php index 04a9365c13048..f93ee7f04c4ce 100644 --- a/plugins/authentication/joomla/joomla.php +++ b/plugins/authentication/joomla/joomla.php @@ -88,7 +88,7 @@ public function onUserAuthenticate($credentials, $options, &$response) } // Check the two factor authentication - if ($response->status == JAuthentication::STATUS_SUCCESS) + if ($response->status === JAuthentication::STATUS_SUCCESS) { $methods = JAuthenticationHelper::getTwoFactorMethods(); diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index 0ce368849c0da..6d9135300e6d6 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -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 === '') { throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY')); } @@ -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 || $challenge === '' || $response == null || $response === ''); + $spam = ($challenge === null || $challenge === '' || $response === null || $response === ''); 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 || $response === ''); + $spam = ($response === null || $response === ''); break; } @@ -265,7 +265,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 ) { die('Could not open socket'); } diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index df3461eebdf98..9c22fed1a7478 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -53,7 +53,7 @@ class JReCaptcha */ public function __construct($secret) { - if ($secret == null || $secret == '') + if ($secret === null || $secret === '') { die("To use reCAPTCHA you must get an API key from " . self::$_signupUrl . ''); @@ -110,7 +110,7 @@ private function _submitHTTPGet($path, $data) public function verifyResponse($remoteIp, $response) { // Discard empty solution submissions - if ($response == null || $response === '') + if ($response === null || $response === '') { $recaptchaResponse = new JReCaptchaResponse(); $recaptchaResponse->success = false; @@ -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']) === true) { $recaptchaResponse->success = true; } diff --git a/plugins/content/contact/contact.php b/plugins/content/contact/contact.php index ce3d8bec9da55..b388a56d35091 100644 --- a/plugins/content/contact/contact.php +++ b/plugins/content/contact/contact.php @@ -98,7 +98,7 @@ protected function getContactId($created_by) $query->where('contact.published = 1'); $query->where('contact.user_id = ' . (int) $created_by); - if (JLanguageMultilang::isEnabled() == 1) + if (JLanguageMultilang::isEnabled() === 1) { $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index d2213d21ac4ba..55fbd9975ac8b 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -303,8 +303,8 @@ protected function _createToc(&$row, &$matches, &$page) $title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i); } - $liClass = ($limitstart == $i - 1) ? ' class="active"' : ''; - $class = ($limitstart == $i - 1) ? 'toclink active' : 'toclink'; + $liClass = ($limitstart === $i - 1) ? ' class="active"' : ''; + $class = ($limitstart === $i - 1) ? 'toclink active' : 'toclink'; $row->toc .= '' . $title . '
  • '; $i++; } @@ -312,8 +312,8 @@ protected function _createToc(&$row, &$matches, &$page) if ($this->params->get('showall')) { $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=1&limitstart='); - $liClass = ($limitstart == $i - 1) ? ' class="active"' : ''; - $class = ($limitstart == $i - 1) ? 'toclink active' : 'toclink'; + $liClass = ($limitstart === $i - 1) ? ' class="active"' : ''; + $class = ($limitstart === $i - 1) ? 'toclink active' : 'toclink'; $row->toc .= '' . JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') . ''; } @@ -357,7 +357,7 @@ protected function _createNavigation(&$row, $page, $n) if ($page > 0) { - $page_prev = $page - 1 == 0 ? '' : $page - 1; + $page_prev = $page - 1 === 0 ? '' : $page - 1; $link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid, $row->language) . '&showall=&limitstart=' . $page_prev); diff --git a/plugins/editors-xtd/image/image.php b/plugins/editors-xtd/image/image.php index 80fc0e5c0aaff..d3b4ce167bfdc 100644 --- a/plugins/editors-xtd/image/image.php +++ b/plugins/editors-xtd/image/image.php @@ -39,7 +39,7 @@ public function onDisplay($name, $asset, $author) $user = JFactory::getUser(); $extension = $app->input->get('option'); - if ($asset == '') + if ($asset === '') { $asset = $extension; } diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 8cc756715e0b4..98ce2ed35cf4c 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -517,7 +517,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $toolbar3_add[] = 'ltr rtl'; } - if ($extended_elements != '') + if ($extended_elements !== '') { $elements = explode(',', $extended_elements); } @@ -703,14 +703,14 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $custom_plugin = $this->params->get('custom_plugin', ''); - if ($custom_plugin != '') + if ($custom_plugin !== '') { $plugins[] = $custom_plugin; } $custom_button = $this->params->get('custom_button', ''); - if ($custom_button != '') + if ($custom_button !== '') { $toolbar4_add[] = $custom_button; } @@ -794,7 +794,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons { $smallButtons = 'toolbar_items_size: "small",'; } - elseif ($mobileVersion == false) + elseif ($mobileVersion === false) { $smallButtons = ''; } diff --git a/plugins/finder/categories/categories.php b/plugins/finder/categories/categories.php index ac4d157441d26..816ceaa600223 100644 --- a/plugins/finder/categories/categories.php +++ b/plugins/finder/categories/categories.php @@ -244,7 +244,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) === false) { return; } diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index bd547881047c3..8471b8937210b 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -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) === false) { return; } diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index 3bc314bd74e6d..22277d8f89a8d 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -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) === false) { return; } diff --git a/plugins/finder/newsfeeds/newsfeeds.php b/plugins/finder/newsfeeds/newsfeeds.php index 60e3d293d8026..f3fd49a8a46c9 100644 --- a/plugins/finder/newsfeeds/newsfeeds.php +++ b/plugins/finder/newsfeeds/newsfeeds.php @@ -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) === false) { return; } diff --git a/plugins/finder/tags/tags.php b/plugins/finder/tags/tags.php index 7d048a4f0845b..2f32eec29d7ff 100644 --- a/plugins/finder/tags/tags.php +++ b/plugins/finder/tags/tags.php @@ -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) === false) { return; } diff --git a/plugins/quickicon/extensionupdate/extensionupdate.php b/plugins/quickicon/extensionupdate/extensionupdate.php index e77dd664d68de..15ef81f88857b 100644 --- a/plugins/quickicon/extensionupdate/extensionupdate.php +++ b/plugins/quickicon/extensionupdate/extensionupdate.php @@ -37,7 +37,7 @@ class PlgQuickiconExtensionupdate extends JPlugin */ public function onGetIcons($context) { - if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) + if ($context !== $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) { return; } diff --git a/plugins/quickicon/joomlaupdate/joomlaupdate.php b/plugins/quickicon/joomlaupdate/joomlaupdate.php index f9bfe9f6a8725..036f1d304ddd4 100644 --- a/plugins/quickicon/joomlaupdate/joomlaupdate.php +++ b/plugins/quickicon/joomlaupdate/joomlaupdate.php @@ -38,7 +38,7 @@ class PlgQuickiconJoomlaupdate extends JPlugin */ public function onGetIcons($context) { - if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) + if ($context !== $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) { return; } diff --git a/plugins/search/categories/categories.php b/plugins/search/categories/categories.php index 1513a17c00d58..3294a95e88202 100644 --- a/plugins/search/categories/categories.php +++ b/plugins/search/categories/categories.php @@ -92,7 +92,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $text = trim($text); - if ($text == '') + if ($text === '') { return array(); } diff --git a/plugins/search/contacts/contacts.php b/plugins/search/contacts/contacts.php index dd6c526592ec7..bd8bd25f2155f 100644 --- a/plugins/search/contacts/contacts.php +++ b/plugins/search/contacts/contacts.php @@ -91,7 +91,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $text = trim($text); - if ($text == '') + if ($text === '') { return array(); } diff --git a/plugins/search/content/content.php b/plugins/search/content/content.php index c5171021c3d28..d6af21a016b6a 100644 --- a/plugins/search/content/content.php +++ b/plugins/search/content/content.php @@ -74,7 +74,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $text = trim($text); - if ($text == '') + if ($text === '') { return array(); } diff --git a/plugins/search/newsfeeds/newsfeeds.php b/plugins/search/newsfeeds/newsfeeds.php index 791a59d0c647a..d929288a803ac 100644 --- a/plugins/search/newsfeeds/newsfeeds.php +++ b/plugins/search/newsfeeds/newsfeeds.php @@ -89,7 +89,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $text = trim($text); - if ($text == '') + if ($text === '') { return array(); } diff --git a/plugins/search/tags/tags.php b/plugins/search/tags/tags.php index bf592aa505a3b..fc3c34b9c8212 100644 --- a/plugins/search/tags/tags.php +++ b/plugins/search/tags/tags.php @@ -73,7 +73,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu $text = trim($text); - if ($text == '') + if ($text === '') { return array(); } @@ -153,7 +153,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu foreach ($rows as $key => $row) { $rows[$key]->href = TagsHelperRoute::getTagRoute($row->id); - $rows[$key]->text = ($row->description != '' ? $row->description : $row->title); + $rows[$key]->text = ($row->description !== '' ? $row->description : $row->title); $rows[$key]->text .= $row->note; $rows[$key]->section = $section; $rows[$key]->created = $row->created; diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 77db977045faa..71f1cdf6e9d32 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -1099,7 +1099,7 @@ protected function displayQueries() $labelClass = 'label-warning'; } - if ($this->totalQueries == 0) + if ($this->totalQueries === 0) { $this->totalQueries = $db->getCount(); } diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index 7b5223485bb19..60f94cd18374a 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -209,8 +209,8 @@ public function buildRule(&$router, &$uri) if ($this->mode_sef && (!$this->params->get('remove_default_prefix', 0) - || $lang != $this->default_lang - || $lang != $this->current_lang)) + || $lang !== $this->default_lang + || $lang !== $this->current_lang)) { $uri->setPath($uri->getPath() . '/' . $sef . '/'); } @@ -308,7 +308,7 @@ public function parseRule(&$router, &$uri) $lang_code = $this->default_lang; } - if ($lang_code == $this->default_lang && $this->params->get('remove_default_prefix', 0)) + if ($lang_code === $this->default_lang && $this->params->get('remove_default_prefix', 0)) { $found = true; } @@ -321,7 +321,7 @@ public function parseRule(&$router, &$uri) // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL. // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language. - if ($lang_code == $this->default_lang + if ($lang_code === $this->default_lang && $this->params->get('remove_default_prefix', 0) ) { @@ -417,7 +417,7 @@ public function parseRule(&$router, &$uri) if ($this->mode_sef) { // Use the current language sef or the default one. - if ($lang_code != $this->default_lang + if ($lang_code !== $this->default_lang || !$this->params->get('remove_default_prefix', 0) ) { @@ -468,7 +468,7 @@ public function parseRule(&$router, &$uri) $this->app->set('language', $lang_code); $language = JFactory::getLanguage(); - if ($language->getTag() != $lang_code) + if ($language->getTag() !== $lang_code) { $newLang = JLanguage::getInstance($lang_code); @@ -482,7 +482,7 @@ public function parseRule(&$router, &$uri) } // Create a cookie. - if ($this->getLanguageCookie() != $lang_code) + if ($this->getLanguageCookie() !== $lang_code) { $this->setLanguageCookie($lang_code); } @@ -545,7 +545,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg) $lang_code = $this->current_lang; } - if ($lang_code == $this->user_lang_code || !isset($this->lang_codes[$lang_code])) + if ($lang_code === $this->user_lang_code || !isset($this->lang_codes[$lang_code])) { if ($this->app->isSite()) { @@ -651,7 +651,7 @@ public function onUserLogin($user, $options = array()) // We are on a Home page, we redirect to the user site language home page $item = $menu->getDefault($lang_code); - if ($item && $item->language != $active->language && $item->language !== '*') + if ($item && $item->language !== $active->language && $item->language !== '*') { $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id); $foundAssociation = true; @@ -659,7 +659,7 @@ public function onUserLogin($user, $options = array()) } } - if ($foundAssociation && $lang_code != $this->current_lang) + if ($foundAssociation && $lang_code !== $this->current_lang) { // Change language. $this->current_lang = $lang_code; @@ -710,14 +710,14 @@ public function onAfterDispatch() $current_link = JRoute::_($currentInternalUrl); // Load menu associations - if ($active_link == $current_link) + if ($active_link === $current_link) { $associations = MenusHelper::getAssociations($active->id); } // Check if we are on the home page $is_home = ($active->home - && ($active_link == $current_link || $active_link == $current_link . 'index.php' || $active_link . '/' == $current_link)); + && ($active_link === $current_link || $active_link === $current_link . 'index.php' || $active_link . '/' === $current_link)); } // Load component associations. @@ -748,7 +748,7 @@ public function onAfterDispatch() break; // Current language link - case ($i == $this->current_lang): + case ($i === $this->current_lang): $language->link = JRoute::_($currentInternalUrl); break; diff --git a/plugins/system/updatenotification/postinstall/updatecachetime.php b/plugins/system/updatenotification/postinstall/updatecachetime.php index 70f17a3811b97..343b4e47026ed 100644 --- a/plugins/system/updatenotification/postinstall/updatecachetime.php +++ b/plugins/system/updatenotification/postinstall/updatecachetime.php @@ -19,7 +19,7 @@ function updatecachetime_postinstall_condition() $cacheTimeout = (int) JComponentHelper::getComponent('com_installer')->params->get('cachetimeout', 6); // Check if cachetimeout is eq zero - if ($cacheTimeout == 0 && JPluginHelper::isEnabled('system', 'updatenotification')) + if ($cacheTimeout === 0 && JPluginHelper::isEnabled('system', 'updatenotification')) { return true; } diff --git a/plugins/twofactorauth/totp/postinstall/actions.php b/plugins/twofactorauth/totp/postinstall/actions.php index 0633931044a3b..f5505c1d36741 100644 --- a/plugins/twofactorauth/totp/postinstall/actions.php +++ b/plugins/twofactorauth/totp/postinstall/actions.php @@ -32,7 +32,7 @@ function twofactorauth_postinstall_condition() $db->setQuery($query); $enabled_plugins = $db->loadObjectList(); - return count($enabled_plugins) == 0; + return count($enabled_plugins) === 0; } /** diff --git a/plugins/twofactorauth/totp/totp.php b/plugins/twofactorauth/totp/totp.php index f90fcfe276e95..5e9862345225e 100644 --- a/plugins/twofactorauth/totp/totp.php +++ b/plugins/twofactorauth/totp/totp.php @@ -91,7 +91,7 @@ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) // Create a new TOTP class with Google Authenticator compatible settings $totp = new FOFEncryptTotp(30, 6, 10); - if ($otpConfig->method == $this->methodName) + if ($otpConfig->method === $this->methodName) { // This method is already activated. Reuse the same secret key. $secret = $otpConfig->config['code']; @@ -152,7 +152,7 @@ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) */ public function onUserTwofactorApplyConfiguration($method) { - if ($method != $this->methodName) + if ($method !== $this->methodName) { return false; } @@ -192,7 +192,7 @@ public function onUserTwofactorApplyConfiguration($method) // Check the security code entered by the user (exact time slot match) $code = $totp->getCode($data['key']); - $check = $code == $data['securitycode']; + $check = $code === $data['securitycode']; /* * If the check fails, test the previous 30 second slot. This allow the @@ -203,7 +203,7 @@ public function onUserTwofactorApplyConfiguration($method) { $time = time() - 30; $code = $totp->getCode($data['key'], $time); - $check = $code == $data['securitycode']; + $check = $code === $data['securitycode']; } /* @@ -214,7 +214,7 @@ public function onUserTwofactorApplyConfiguration($method) { $time = time() + 30; $code = $totp->getCode($data['key'], $time); - $check = $code == $data['securitycode']; + $check = $code === $data['securitycode']; } if (!$check) @@ -258,7 +258,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) } // Check if we have the correct method - if ($otpConfig->method != $this->methodName) + if ($otpConfig->method !== $this->methodName) { return false; } @@ -274,7 +274,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) // Check the code $code = $totp->getCode($otpConfig->config['code']); - $check = $code == $credentials['secretkey']; + $check = $code === $credentials['secretkey']; /* * If the check fails, test the previous 30 second slot. This allow the @@ -285,7 +285,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) { $time = time() - 30; $code = $totp->getCode($otpConfig->config['code'], $time); - $check = $code == $credentials['secretkey']; + $check = $code === $credentials['secretkey']; } /* @@ -296,7 +296,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) { $time = time() + 30; $code = $totp->getCode($otpConfig->config['code'], $time); - $check = $code == $credentials['secretkey']; + $check = $code === $credentials['secretkey']; } return $check; diff --git a/plugins/twofactorauth/yubikey/yubikey.php b/plugins/twofactorauth/yubikey/yubikey.php index d78a60e39ac19..5ce8e76ace45f 100644 --- a/plugins/twofactorauth/yubikey/yubikey.php +++ b/plugins/twofactorauth/yubikey/yubikey.php @@ -87,7 +87,7 @@ public function onUserTwofactorIdentify() */ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) { - if ($otpConfig->method == $this->methodName) + if ($otpConfig->method === $this->methodName) { // This method is already activated. Reuse the same Yubikey ID. $yubikey = $otpConfig->config['yubikey']; @@ -99,7 +99,7 @@ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) } // Is this a new TOTP setup? If so, we'll have to show the code validation field. - $new_totp = $otpConfig->method != $this->methodName; + $new_totp = $otpConfig->method !== $this->methodName; // Start output buffering @ob_start(); @@ -141,7 +141,7 @@ public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null) */ public function onUserTwofactorApplyConfiguration($method) { - if ($method != $this->methodName) + if ($method !== $this->methodName) { return false; } @@ -224,7 +224,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) } // Check if we have the correct method - if ($otpConfig->method != $this->methodName) + if ($otpConfig->method !== $this->methodName) { return false; } @@ -239,7 +239,7 @@ public function onUserTwofactorAuthenticate($credentials, $options) $yubikey_valid = $otpConfig->config['yubikey']; $yubikey = substr($credentials['secretkey'], 0, -32); - $check = $yubikey == $yubikey_valid; + $check = $yubikey === $yubikey_valid; if ($check) { @@ -355,13 +355,13 @@ public function validateYubikeyOtp($otp) } // Validate the response - The OTP must match - if ($data['otp'] != $otp) + if ($data['otp'] !== $otp) { return false; } // Validate the response - The token must match - if ($data['nonce'] != $nonce) + if ($data['nonce'] !== $nonce) { return false; } diff --git a/plugins/user/contactcreator/contactcreator.php b/plugins/user/contactcreator/contactcreator.php index 8fbe7c2f04e2e..13eb0508846ca 100644 --- a/plugins/user/contactcreator/contactcreator.php +++ b/plugins/user/contactcreator/contactcreator.php @@ -142,7 +142,7 @@ protected function generateAliasAndName($alias, $name, $categoryId) while ($table->load(array('alias' => $alias, 'catid' => $categoryId))) { - if ($name == $table->name) + if ($name === $table->name) { $name = JString::increment($name); } diff --git a/plugins/user/joomla/joomla.php b/plugins/user/joomla/joomla.php index f383fc5983c28..87f14a6bc62fd 100644 --- a/plugins/user/joomla/joomla.php +++ b/plugins/user/joomla/joomla.php @@ -106,7 +106,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg) $userParams = new Registry($user['params']); $userLocale = $userParams->get('language', $userParams->get('admin_language', $defaultLocale)); - if ($userLocale != $defaultLocale) + if ($userLocale !== $defaultLocale) { $lang->setLanguage($userLocale); } @@ -143,7 +143,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg) ->setBody($emailBody); // Set application language back to default if we changed it - if ($userLocale != $defaultLocale) + if ($userLocale !== $defaultLocale) { $lang->setLanguage($defaultLocale); } diff --git a/plugins/user/profile/field/tos.php b/plugins/user/profile/field/tos.php index d7012f733a255..dc8af3f17217b 100644 --- a/plugins/user/profile/field/tos.php +++ b/plugins/user/profile/field/tos.php @@ -101,7 +101,7 @@ protected function getLabel() $current_lang = JFactory::getLanguage()->getTag(); - if (isset($tosassociated) && $current_lang != $article->language && array_key_exists($current_lang, $tosassociated)) + if (isset($tosassociated) && $current_lang !== $article->language && array_key_exists($current_lang, $tosassociated)) { $url = ContentHelperRoute::getArticleRoute($tosassociated[$current_lang]->id, $tosassociated[$current_lang]->catid); $link = JHtml::_('link', JRoute::_($url . '&tmpl=component&lang=' . $tosassociated[$current_lang]->language), $text, $attribs); From f5fc398394e1116c244fcaeb091e8c5b031ee40a Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 15:08:00 +0300 Subject: [PATCH 21/37] Fix another non-optimal if condition --- plugins/editors-xtd/image/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors-xtd/image/image.php b/plugins/editors-xtd/image/image.php index d3b4ce167bfdc..428058c021f58 100644 --- a/plugins/editors-xtd/image/image.php +++ b/plugins/editors-xtd/image/image.php @@ -46,8 +46,8 @@ public function onDisplay($name, $asset, $author) if ( $user->authorise('core.edit', $asset) || $user->authorise('core.create', $asset) - || (count($user->getAuthorisedCategories($asset, 'core.create')) > 0) || ($user->authorise('core.edit.own', $asset) && $author == $user->id) + || (count($user->getAuthorisedCategories($asset, 'core.create')) > 0) || (count($user->getAuthorisedCategories($extension, 'core.edit')) > 0) || (count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == $user->id)) { From ac4921a3af6aca1b7a5ef7d20f4a5619d2ca6bc3 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 15:18:46 +0300 Subject: [PATCH 22/37] Merged another str_replace() case --- plugins/system/debug/debug.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 71f1cdf6e9d32..007945a7eec17 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -899,8 +899,7 @@ protected function displayQueries() } $fromString = substr($query, 0, $whereStart); - $fromString = str_replace("\t", ' ', $fromString); - $fromString = str_replace("\n", ' ', $fromString); + $fromString = str_replace(array("\t","\n"), ' ', $fromString); $fromString = trim($fromString); // Initialise the select/other query type counts the first time. @@ -1997,10 +1996,9 @@ protected function writeToFile() { if (isset($timings[$id * 2 + 1])) { - $temp = str_replace('`', '', $log[$id]); - $temp = str_replace("\t", ' ', $temp); - $temp = str_replace("\n", ' ', $temp); - $current .= str_replace("\r\n", ' ', $temp) . ";\n"; + $temp = str_replace('`', '', $log[$id]); + $temp = str_replace(array("\t", "\n", "\r\n"), ' ', $temp); + $current .= $temp . ";\n"; } } From 6f79ff1d05e83eacdb352c0514486471fc8429c8 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 15:52:59 +0300 Subject: [PATCH 23/37] Fix own typo --- plugins/authentication/ldap/ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index 5860f348d6cfc..c6845cad40645 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -70,7 +70,7 @@ public function onUserAuthenticate($credentials, $options, &$response) { // Bind using Connect Username/password // Force anon bind to mitigate misconfiguration like [#7119] - if ($this->params->get('username' !== '')) + if ($this->params->get('username') !== '') { $bindtest = $ldap->bind(); } From 943f500451f6354c3ed072656e08c828790f824c Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 15:53:40 +0300 Subject: [PATCH 24/37] Fix formatting --- plugins/editors/codemirror/codemirror.php | 6 ++---- plugins/system/languagefilter/languagefilter.php | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/editors/codemirror/codemirror.php b/plugins/editors/codemirror/codemirror.php index f198eb0235aba..f97f351f6a13a 100644 --- a/plugins/editors/codemirror/codemirror.php +++ b/plugins/editors/codemirror/codemirror.php @@ -148,11 +148,9 @@ public function onGetInsertMethod() $done = true; - JFactory::getDocument()->addScriptDeclaration( - ' + JFactory::getDocument()->addScriptDeclaration(' ;function jInsertEditorText(text, editor) { Joomla.editors.instances[editor].replaceSelection(text); } - ' - ); + '); return true; } diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index 60f94cd18374a..da1082d6389ee 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -321,9 +321,7 @@ public function parseRule(&$router, &$uri) // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL. // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language. - if ($lang_code === $this->default_lang - && $this->params->get('remove_default_prefix', 0) - ) + if ($lang_code === $this->default_lang && $this->params->get('remove_default_prefix', 0)) { // Create a cookie. $this->setLanguageCookie($lang_code); From ac0ebb434772246fa3dec382a8566a38213015f5 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 15:54:16 +0300 Subject: [PATCH 25/37] Further optimize an if condition --- plugins/content/pagebreak/pagebreak.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 55fbd9975ac8b..95621a38b978d 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -85,7 +85,7 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $page = 0; } - if ($view !== 'article' || $full || $params->get('intro_only') || $params->get('popup')) + if ($full || $view !== 'article' || $params->get('intro_only') || $params->get('popup')) { $row->text = preg_replace($regex, '', $row->text); From b9adbc53c0d7f571912a850b9f0338d7eb74c376 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Sep 2016 16:04:47 +0300 Subject: [PATCH 26/37] Fix codesniffer --- plugins/system/debug/debug.php | 3 +-- plugins/system/languagefilter/languagefilter.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 007945a7eec17..2de5e03d09a3a 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -234,8 +234,7 @@ public function onAfterRespond() // No debug for Safari and Chrome redirection. if (strpos($contents, '" . self::$_signupUrl . ''); + . self::$_signupUrl . "'>" . self::$_signupUrl . ""); } $this->_secret = $secret; } diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index e4e6bd50164d3..b961dfc3a16d0 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -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')) { $db = JFactory::getDbo(); $user = JFactory::getUser(); diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index dd92eea1e8f7f..8cbddd92f0908 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -377,7 +377,7 @@ public function onUserBeforeSave($user, $isnew, $data) $tosenabled = ($this->params->get('register-require_tos', 0) == 2); // Check that the tos is checked. - if (($task === 'register') && $tosenabled && $tosarticle && ($option === 'com_users') && !$data['profile']['tos']) + if (($task === 'register') && $tosenabled && $tosarticle && $option === 'com_users' && !$data['profile']['tos']) { throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); } From 9e8063e60d0696ca22074c4b058fa0069097b751 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 01:09:58 +0200 Subject: [PATCH 28/37] Changes, based on discussions with @csthomas --- plugins/content/contact/contact.php | 2 +- plugins/finder/contacts/contacts.php | 2 +- plugins/finder/content/content.php | 2 +- plugins/finder/newsfeeds/newsfeeds.php | 2 +- plugins/finder/tags/tags.php | 2 +- plugins/system/debug/debug.php | 4 ++-- plugins/system/redirect/redirect.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/content/contact/contact.php b/plugins/content/contact/contact.php index b388a56d35091..b1878b73e8a81 100644 --- a/plugins/content/contact/contact.php +++ b/plugins/content/contact/contact.php @@ -98,7 +98,7 @@ protected function getContactId($created_by) $query->where('contact.published = 1'); $query->where('contact.user_id = ' . (int) $created_by); - if (JLanguageMultilang::isEnabled() === 1) + if (JLanguageMultilang::isEnabled()) { $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index 8471b8937210b..8b49efd17e036 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -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)) { return; } diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index 22277d8f89a8d..b0f3513ecfb2a 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -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)) { return; } diff --git a/plugins/finder/newsfeeds/newsfeeds.php b/plugins/finder/newsfeeds/newsfeeds.php index f3fd49a8a46c9..6870f6628ea73 100644 --- a/plugins/finder/newsfeeds/newsfeeds.php +++ b/plugins/finder/newsfeeds/newsfeeds.php @@ -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)) { return; } diff --git a/plugins/finder/tags/tags.php b/plugins/finder/tags/tags.php index 2f32eec29d7ff..a392034be604d 100644 --- a/plugins/finder/tags/tags.php +++ b/plugins/finder/tags/tags.php @@ -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)) { return; } diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index 2de5e03d09a3a..4f51baf245d3f 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -915,12 +915,12 @@ protected function displayQueries() // Increment the count. if (stripos($query, 'select') === 0) { - ++$selectQueryTypeTicker[$fromString]; + $selectQueryTypeTicker[$fromString]++; unset($otherQueryTypeTicker[$fromString]); } else { - ++$otherQueryTypeTicker[$fromString]; + $otherQueryTypeTicker[$fromString]++; unset($selectQueryTypeTicker[$fromString]); } diff --git a/plugins/system/redirect/redirect.php b/plugins/system/redirect/redirect.php index 931b1b6cd516f..f0aaa2fa48eed 100644 --- a/plugins/system/redirect/redirect.php +++ b/plugins/system/redirect/redirect.php @@ -233,7 +233,7 @@ private static function doErrorHandling($error) // We have an unpublished redirect object, increment the hit counter else { - ++$redirect->hits; + $redirect->hits++; try { From 492fb9e4a85eff23595c161f5315364af224e434 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 14:34:15 +0200 Subject: [PATCH 29/37] One more change, based on previous discussion. --- plugins/finder/categories/categories.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/finder/categories/categories.php b/plugins/finder/categories/categories.php index 816ceaa600223..b239becea5663 100644 --- a/plugins/finder/categories/categories.php +++ b/plugins/finder/categories/categories.php @@ -244,7 +244,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)) { return; } From 7edf38694a4ee7d644df0d699b8e47a8c16125df Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 15:25:16 +0200 Subject: [PATCH 30/37] A few more minor fixes --- plugins/captcha/recaptcha/recaptchalib.php | 2 +- plugins/editors/codemirror/codemirror.php | 2 +- plugins/editors/tinymce/tinymce.php | 4 ++-- plugins/system/fields/fields.php | 2 -- plugins/system/stats/stats.php | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index 4e2e5aa198fc1..ba08dfb238f52 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -119,7 +119,7 @@ public function verifyResponse($remoteIp, $response) return $recaptchaResponse; } - $getResponse = $this->_submitHttpGet( + $getResponse = $this->_submitHTTPGet( self::$_siteVerifyUrl, array( 'secret' => $this->_secret, diff --git a/plugins/editors/codemirror/codemirror.php b/plugins/editors/codemirror/codemirror.php index a4e0431e97239..5b1df0a2d3d31 100644 --- a/plugins/editors/codemirror/codemirror.php +++ b/plugins/editors/codemirror/codemirror.php @@ -77,7 +77,7 @@ public function onInit() { if (isset($fontInfo->url)) { - $doc->addStylesheet($fontInfo->url); + $doc->addStyleSheet($fontInfo->url); } if (isset($fontInfo->css)) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 00a31a3dbdff9..6f9eafb068745 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -507,7 +507,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons // We shall put the XTD button inside tinymce $btns = $this->tinyButtons($id, $buttons); $btnsNames = $btns['names']; - $tinyBtns = implode("; ", $btns['script']); + $tinyBtns = implode('; ', $btns['script']); if (!empty($btnsNames)) { @@ -656,7 +656,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $options['tinyMCE']['default'] = $scriptOptions; - $doc->addStyleDeclaration(".mce-in { padding: 5px 10px !important;}"); + $doc->addStyleDeclaration('.mce-in { padding: 5px 10px !important;}'); $doc->addScriptOptions('plg_editor_tinymce', $options); return $editor; diff --git a/plugins/system/fields/fields.php b/plugins/system/fields/fields.php index 700d965462dda..3f96ec36964c8 100644 --- a/plugins/system/fields/fields.php +++ b/plugins/system/fields/fields.php @@ -472,8 +472,6 @@ public function onContentPrepare($context, $item) { $item->fields[$field->id] = $field; } - - return; } /** diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php index 2a15a4fd59dae..0c4fdf61137ba 100644 --- a/plugins/system/stats/stats.php +++ b/plugins/system/stats/stats.php @@ -545,7 +545,7 @@ private function clearCacheGroups(array $clearGroups, array $cacheClients = arra { $options = array( 'defaultgroup' => $group, - 'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $this->app->get('cache_path', JPATH_SITE . '/cache') + 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $this->app->get('cache_path', JPATH_SITE . '/cache') ); $cache = JCache::getInstance('callback', $options); From 5e7202bcde2bc74788ae193dcf681f9ca50313d4 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 15:38:31 +0200 Subject: [PATCH 31/37] Fix slipped through merge conflict --- plugins/editors/tinymce/tinymce.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 6f9eafb068745..6bfd655b5208d 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -167,7 +167,6 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $app = JFactory::getApplication(); $user = JFactory::getUser(); $language = JFactory::getLanguage(); - $mode = (int) $this->params->get('mode', 1); $theme = 'modern'; $access = array_flip($user->getAuthorisedViewLevels()); @@ -212,7 +211,6 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $skin = basename($skindirs[(int) $this->params->get($side, 0)]); } - $entity_encoding = $this->params->get('entity_encoding', 'raw'); $langMode = $this->params->get('lang_mode', 0); $langPrefix = $this->params->get('lang_code', 'en'); From 9581e65cf3568abcdd6dc193175736eb0edd7012 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 19:09:18 +0200 Subject: [PATCH 32/37] Correction in comparison --- plugins/authentication/ldap/ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index c6845cad40645..743aa526132f5 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -70,7 +70,7 @@ public function onUserAuthenticate($credentials, $options, &$response) { // Bind using Connect Username/password // Force anon bind to mitigate misconfiguration like [#7119] - if ($this->params->get('username') !== '') + if ($this->params->get('username')) { $bindtest = $ldap->bind(); } From d0d9261f9bbd60644b5b62d3628149b16f43280a Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Sat, 10 Dec 2016 19:37:24 +0200 Subject: [PATCH 33/37] Correction in comparison with trim result --- plugins/captcha/recaptcha/recaptchalib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index ba08dfb238f52..ef3ddcc0d4bef 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -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'])) { $recaptchaResponse->success = true; } From b7636dc9b7197a3c295831a8bd8315c3446f0a21 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Dec 2016 11:52:23 +0200 Subject: [PATCH 34/37] Reverted this one to not clash with @laoneo's refactoring efforts --- plugins/system/fields/fields.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/system/fields/fields.php b/plugins/system/fields/fields.php index 7802c3b64caba..700d965462dda 100644 --- a/plugins/system/fields/fields.php +++ b/plugins/system/fields/fields.php @@ -472,6 +472,8 @@ public function onContentPrepare($context, $item) { $item->fields[$field->id] = $field; } + + return; } /** @@ -501,7 +503,7 @@ public function onPrepareFinderContent($item) } // Transofrm com_article to com_content - if ($component === 'com_article') + if ($component == 'com_article') { $component = 'com_content'; } @@ -565,7 +567,7 @@ private function getParts($context) return null; } - if ($parts[1] === 'form') + if ($parts[1] == 'form') { // The context is not from a known one, we need to do a lookup // @todo use the api here. From 5f011db422c2ddc001ebd645d02bf0c1367d68d8 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 1 Jun 2017 03:57:42 +0300 Subject: [PATCH 35/37] Some changes according to reviewer's comments --- plugins/captcha/recaptcha/recaptcha.php | 2 +- plugins/content/pagenavigation/pagenavigation.php | 2 +- plugins/system/debug/debug.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index b758c421c9aae..09236b697006a 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -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) { die('Could not open socket'); } diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 31ce40bc053d6..cdc18723fd875 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -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')) { $db = JFactory::getDbo(); $user = JFactory::getUser(); diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php index d675370c480fb..003679fa664f0 100644 --- a/plugins/system/debug/debug.php +++ b/plugins/system/debug/debug.php @@ -1106,7 +1106,7 @@ protected function displayQueries() $title = '' . $title . ''; } - $htmlProfile = ($info[$id]->profile ?: JText::_('PLG_DEBUG_NO_PROFILE')); + $htmlProfile = $info[$id]->profile ?: JText::_('PLG_DEBUG_NO_PROFILE'); $htmlAccordions = JHtml::_( 'bootstrap.startAccordion', 'dbg_query_' . $id, array( From 76fe7a9d2bcfb9a5bd7e55b4c2a09469ae393076 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 1 Jun 2017 05:16:20 +0300 Subject: [PATCH 36/37] Some changes according to reviewer's comments --- plugins/user/profile/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/user/profile/profile.php b/plugins/user/profile/profile.php index 1c9e617a49db5..fcbeb602f920b 100644 --- a/plugins/user/profile/profile.php +++ b/plugins/user/profile/profile.php @@ -385,7 +385,7 @@ public function onUserBeforeSave($user, $isnew, $data) $tosenabled = ($this->params->get('register-require_tos', 0) == 2); // Check that the tos is checked. - if (($task === 'register') && $tosenabled && $tosarticle && $option === 'com_users' && !$data['profile']['tos']) + if ($task === 'register' && $tosenabled && $tosarticle && $option === 'com_users' && !$data['profile']['tos']) { throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE')); } From 33d7bd2ca0a101fc0fb6650260afa96c8208d046 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 2 Jun 2017 16:27:30 +0300 Subject: [PATCH 37/37] Additional changes according to reviewer's comments --- plugins/authentication/ldap/ldap.php | 2 +- plugins/captcha/recaptcha/recaptcha.php | 6 +++--- plugins/captcha/recaptcha/recaptchalib.php | 2 +- plugins/content/contact/contact.php | 2 +- plugins/content/pagebreak/pagebreak.php | 4 ++-- plugins/editors/tinymce/tinymce.php | 2 +- plugins/finder/categories/categories.php | 4 ++-- plugins/finder/contacts/contacts.php | 2 +- plugins/finder/content/content.php | 2 +- plugins/finder/newsfeeds/newsfeeds.php | 2 +- plugins/finder/tags/tags.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/authentication/ldap/ldap.php b/plugins/authentication/ldap/ldap.php index d521c4cefb48e..2e8549e0151a9 100644 --- a/plugins/authentication/ldap/ldap.php +++ b/plugins/authentication/ldap/ldap.php @@ -72,7 +72,7 @@ public function onUserAuthenticate($credentials, $options, &$response) { // Bind using Connect Username/password // Force anon bind to mitigate misconfiguration like [#7119] - if ($this->params->get('username')) + if ($this->params->get('username', '') !== '') { $bindtest = $ldap->bind(); } diff --git a/plugins/captcha/recaptcha/recaptcha.php b/plugins/captcha/recaptcha/recaptcha.php index 09236b697006a..7caba5dd4aa04 100644 --- a/plugins/captcha/recaptcha/recaptcha.php +++ b/plugins/captcha/recaptcha/recaptcha.php @@ -40,7 +40,7 @@ public function onInit($id = 'dynamic_recaptcha_1') { $pubkey = $this->params->get('public_key', ''); - if ($pubkey === null || $pubkey === '') + if ($pubkey === '') { throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY')); } @@ -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 || $challenge === '' || $response === null || $response === ''); + $spam = ($challenge === '' || $response === ''); 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 || $response === ''); + $spam = ($response === ''); break; } diff --git a/plugins/captcha/recaptcha/recaptchalib.php b/plugins/captcha/recaptcha/recaptchalib.php index 18f4cdda1090f..0f029ab46ce8b 100644 --- a/plugins/captcha/recaptcha/recaptchalib.php +++ b/plugins/captcha/recaptcha/recaptchalib.php @@ -131,7 +131,7 @@ public function verifyResponse($remoteIp, $response) $answers = json_decode($getResponse, true); $recaptchaResponse = new JReCaptchaResponse(); - if (trim($answers['success'])) + if (trim($answers['success']) !== '') { $recaptchaResponse->success = true; } diff --git a/plugins/content/contact/contact.php b/plugins/content/contact/contact.php index b25d94db0e3c5..cabad322a2cbc 100644 --- a/plugins/content/contact/contact.php +++ b/plugins/content/contact/contact.php @@ -96,7 +96,7 @@ protected function getContactId($created_by) $query->where('contact.published = 1'); $query->where('contact.user_id = ' . (int) $created_by); - if (JLanguageMultilang::isEnabled()) + if (JLanguageMultilang::isEnabled() === true) { $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 822a5cdee6da4..3aa0c7094145a 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -144,11 +144,11 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) $hasToc = $this->params->get('multipage_toc', 1); // Adds heading or title to Title. - if ($title && $page && @$matches[$page - 1][2]) + if ($title && $page && isset($matches[$page - 1], $matches[$page - 1][2])) { $attrs = JUtility::parseAttributes($matches[$page - 1][1]); - if (@$attrs['title']) + if (isset($attrs['title'])) { $row->page_title = $attrs['title']; } diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index f20fed160333d..3bb057d4c4c6b 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -267,6 +267,7 @@ public function onDisplay( // Set the selected skin $skin = 'lightgray'; $side = $app->isClient('administrator') ? 'skin_admin' : 'skin'; + if ((int) $levelParams->get($side, 0) < count($skindirs)) { $skin = basename($skindirs[(int) $levelParams->get($side, 0)]); @@ -489,7 +490,6 @@ public function onDisplay( } } - // Template $templates = array(); diff --git a/plugins/finder/categories/categories.php b/plugins/finder/categories/categories.php index 18d7a4723234f..4654c599e407d 100644 --- a/plugins/finder/categories/categories.php +++ b/plugins/finder/categories/categories.php @@ -244,13 +244,13 @@ public function onFinderChangeState($context, $pks, $value) protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled. - if (!JComponentHelper::isEnabled($this->extension)) + if (JComponentHelper::isEnabled($this->extension) === false) { return; } // Check if the extension that owns the category is also enabled. - if (!JComponentHelper::isEnabled($item->extension)) + if (JComponentHelper::isEnabled($item->extension) === false) { return; } diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index a603d9f47ee90..db2d64f43377f 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -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)) + if (JComponentHelper::isEnabled($this->extension) === false) { return; } diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index e38cfd7a8db71..74633c98d823b 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -246,7 +246,7 @@ protected function index(FinderIndexerResult $item, $format = 'html') $item->setLanguage(); // Check if the extension is enabled. - if (!JComponentHelper::isEnabled($this->extension)) + if (JComponentHelper::isEnabled($this->extension) === false) { return; } diff --git a/plugins/finder/newsfeeds/newsfeeds.php b/plugins/finder/newsfeeds/newsfeeds.php index 5518a20c1caa8..851e2e690a8b8 100644 --- a/plugins/finder/newsfeeds/newsfeeds.php +++ b/plugins/finder/newsfeeds/newsfeeds.php @@ -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)) + if (JComponentHelper::isEnabled($this->extension) === false) { return; } diff --git a/plugins/finder/tags/tags.php b/plugins/finder/tags/tags.php index acf38f129a341..20b855e19e418 100644 --- a/plugins/finder/tags/tags.php +++ b/plugins/finder/tags/tags.php @@ -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)) + if (JComponentHelper::isEnabled($this->extension) === false) { return; }