diff --git a/administrator/components/com_associations/src/Helper/AssociationsHelper.php b/administrator/components/com_associations/src/Helper/AssociationsHelper.php index c5042cb8bb432..6ffe26d80aa48 100644 --- a/administrator/components/com_associations/src/Helper/AssociationsHelper.php +++ b/administrator/components/com_associations/src/Helper/AssociationsHelper.php @@ -106,7 +106,7 @@ public static function getItem($extensionName, $typeName, $itemId) { if (!self::hasSupport($extensionName)) { - return array(); + return null; } // Get the extension specific helper method @@ -176,7 +176,7 @@ private static function loadHelper($extensionName) * * @param string $extensionName The extension name with com_ * - * @return boolean + * @return string * * @since 3.7.0 */ diff --git a/administrator/components/com_categories/src/Model/CategoryModel.php b/administrator/components/com_categories/src/Model/CategoryModel.php index cdff9e7b88b5b..1d01605d19817 100644 --- a/administrator/components/com_categories/src/Model/CategoryModel.php +++ b/administrator/components/com_categories/src/Model/CategoryModel.php @@ -345,7 +345,7 @@ protected function loadFormData() if (!$data->id) { // Check for which extension the Category Manager is used and get selected fields - $extension = substr($app->getUserState('com_categories.categories.filter.extension'), 4); + $extension = substr($app->getUserState('com_categories.categories.filter.extension', ''), 4); $filters = (array) $app->getUserState('com_categories.categories.' . $extension . '.filter'); $data->set( diff --git a/administrator/components/com_config/src/View/Component/HtmlView.php b/administrator/components/com_config/src/View/Component/HtmlView.php index 7cab257502611..2da29fe74f0de 100644 --- a/administrator/components/com_config/src/View/Component/HtmlView.php +++ b/administrator/components/com_config/src/View/Component/HtmlView.php @@ -66,7 +66,7 @@ public function display($tpl = null) if (!$component->enabled) { - return false; + return; } $form = $this->get('form'); @@ -76,7 +76,7 @@ public function display($tpl = null) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - return false; + return; } $this->fieldsets = $form ? $form->getFieldsets() : null; diff --git a/administrator/components/com_contact/src/Service/HTML/AdministratorService.php b/administrator/components/com_contact/src/Service/HTML/AdministratorService.php index 9bb656da8064c..7255f69339d97 100644 --- a/administrator/components/com_contact/src/Service/HTML/AdministratorService.php +++ b/administrator/components/com_contact/src/Service/HTML/AdministratorService.php @@ -34,7 +34,7 @@ class AdministratorService * * @return string The language HTML * - * @throws Exception + * @throws \Exception */ public function association($contactid) { diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index 60a1273f26c36..8163148b54d78 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -11,6 +11,7 @@ \defined('_JEXEC') or die; +use Joomla\CMS\Date\Date; use Joomla\CMS\Event\AbstractEvent; use Joomla\CMS\Factory; use Joomla\CMS\Filter\InputFilter; diff --git a/administrator/components/com_content/src/Model/ArticlesModel.php b/administrator/components/com_content/src/Model/ArticlesModel.php index 963f489807665..a8f20368bebb6 100644 --- a/administrator/components/com_content/src/Model/ArticlesModel.php +++ b/administrator/components/com_content/src/Model/ArticlesModel.php @@ -88,7 +88,7 @@ public function __construct($config = array()) * @param array $data data * @param boolean $loadData load current data * - * @return Form|null The \JForm object or null if the form can't be found + * @return \Joomla\CMS\Form\Form|null The Form object or null if the form can't be found * * @since 3.2 */ diff --git a/administrator/components/com_fields/src/Plugin/FieldsPlugin.php b/administrator/components/com_fields/src/Plugin/FieldsPlugin.php index a77e45fda7172..5d2554d0f171e 100644 --- a/administrator/components/com_fields/src/Plugin/FieldsPlugin.php +++ b/administrator/components/com_fields/src/Plugin/FieldsPlugin.php @@ -148,11 +148,6 @@ public function onCustomFieldsPrepareField($context, $item, $field) // Get the path for the layout file $path = PluginHelper::getLayoutPath('fields', $this->_name, $field->type); - if (!file_exists($path)) - { - $path = PluginHelper::getLayoutPath('fields', $this->_name, $field->type); - } - // Render the layout ob_start(); include $path; @@ -269,8 +264,8 @@ public function onContentPrepareForm(Form $form, $data) /** * Returns the path of the XML definition file for the field parameters * - * @param Form $form The form - * @param stdClass $data The data + * @param Form $form The form + * @param \stdClass $data The data * * @return string * diff --git a/administrator/components/com_finder/src/Field/ContentmapField.php b/administrator/components/com_finder/src/Field/ContentmapField.php index 44dcc933c9b26..2f72812f33b11 100644 --- a/administrator/components/com_finder/src/Field/ContentmapField.php +++ b/administrator/components/com_finder/src/Field/ContentmapField.php @@ -79,7 +79,7 @@ protected function getGroups() } catch (\RuntimeException $e) { - return; + return []; } // Build the grouped list array. diff --git a/administrator/components/com_finder/src/Indexer/Query.php b/administrator/components/com_finder/src/Indexer/Query.php index 0f867f2043e48..005f795b73aa5 100644 --- a/administrator/components/com_finder/src/Indexer/Query.php +++ b/administrator/components/com_finder/src/Indexer/Query.php @@ -1054,7 +1054,6 @@ protected function processString($input, $lang, $mode) // Adjust the loop. $i += 2; - continue; } // Handle the OR operator. elseif ($op === 'OR' && isset($terms[$i + 2])) @@ -1124,7 +1123,6 @@ protected function processString($input, $lang, $mode) // Adjust the loop. $i += 2; - continue; } } // Handle an orphaned OR operator. @@ -1172,7 +1170,6 @@ protected function processString($input, $lang, $mode) // Adjust the loop. $i++; - continue; } // Handle the NOT operator. elseif (isset($terms[$i + 1]) && array_search($terms[$i], $operators, true) === 'NOT') diff --git a/administrator/components/com_installer/src/Controller/UpdateController.php b/administrator/components/com_installer/src/Controller/UpdateController.php index a8e9d4d98803d..c13ddad972e44 100644 --- a/administrator/components/com_installer/src/Controller/UpdateController.php +++ b/administrator/components/com_installer/src/Controller/UpdateController.php @@ -108,14 +108,14 @@ public function find() if ($disabledUpdateSites) { $updateSitesUrl = Route::_('index.php?option=com_installer&view=updatesites'); - $this->setMessage(Text::sprintf('COM_INSTALLER_MSG_UPDATE_SITES_COUNT_CHECK', $updateSitesUrl), 'warning'); + $this->app->enqueueMessage(Text::sprintf('COM_INSTALLER_MSG_UPDATE_SITES_COUNT_CHECK', $updateSitesUrl), 'warning'); } $model->findUpdates(0, $cache_timeout, $minimum_stability); if (0 === $model->getTotal()) { - $this->setMessage(Text::_('COM_INSTALLER_MSG_UPDATE_NOUPDATES'), 'info'); + $this->app->enqueueMessage(Text::_('COM_INSTALLER_MSG_UPDATE_NOUPDATES'), 'info'); } $this->setRedirect(Route::_('index.php?option=com_installer&view=update', false)); diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 5f33eaed2141d..1053188f2fb4f 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -1073,7 +1073,7 @@ public function removePackageFiles() foreach ($files as $file) { - if (File::exists($file)) + if ($file !== null && File::exists($file)) { File::delete($file); } diff --git a/administrator/components/com_languages/src/Model/InstalledModel.php b/administrator/components/com_languages/src/Model/InstalledModel.php index 0b2eb497dc942..0660c31dba961 100644 --- a/administrator/components/com_languages/src/Model/InstalledModel.php +++ b/administrator/components/com_languages/src/Model/InstalledModel.php @@ -239,7 +239,6 @@ public function getData() && stripos($installedLanguage->language, $search) === false) { unset($installedLanguages[$key]); - continue; } } } diff --git a/administrator/components/com_mails/forms/template.xml b/administrator/components/com_mails/forms/template.xml index bcc515cfbe1f3..b8676c8f77513 100644 --- a/administrator/components/com_mails/forms/template.xml +++ b/administrator/components/com_mails/forms/template.xml @@ -28,7 +28,8 @@ name="htmlbody" type="editor" label="COM_MAILS_FIELD_HTMLBODY_LABEL" - buttons="false" + buttons="true" + hide="fields,pagebreak,readmore,module" class="inputbox" filter="JComponentHelper::filterText" /> diff --git a/administrator/components/com_media/resources/scripts/components/browser/items/image.vue b/administrator/components/com_media/resources/scripts/components/browser/items/image.vue index ad117dc1ade50..1ec2fd16a6a04 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/items/image.vue +++ b/administrator/components/com_media/resources/scripts/components/browser/items/image.vue @@ -4,7 +4,8 @@ @dblclick="openPreview()" @mouseleave="hideActions()" > -
+
-
+
{{ item.name }} {{ item.filetype }}

- +

diff --git a/administrator/components/com_templates/src/Model/TemplateModel.php b/administrator/components/com_templates/src/Model/TemplateModel.php index 36afddbf29757..bd5f3fd1c3544 100644 --- a/administrator/components/com_templates/src/Model/TemplateModel.php +++ b/administrator/components/com_templates/src/Model/TemplateModel.php @@ -273,9 +273,9 @@ function ($a, $b) /** * Prepare core files. * - * @param string $dir The path of the directory to scan. - * @param string $element The path of the template element. - * @param stdClass $template The stdClass object of template. + * @param string $dir The path of the directory to scan. + * @param string $element The path of the template element. + * @param \stdClass $template The stdClass object of template. * * @return array * diff --git a/administrator/modules/mod_sampledata/tmpl/default.php b/administrator/modules/mod_sampledata/tmpl/default.php index b7a9123b807b0..6effa8da33976 100644 --- a/administrator/modules/mod_sampledata/tmpl/default.php +++ b/administrator/modules/mod_sampledata/tmpl/default.php @@ -32,7 +32,7 @@ $item) : ?>
  • -
    +
    title, ENT_QUOTES, 'UTF-8'); ?>
    diff --git a/components/com_content/src/View/Category/HtmlView.php b/components/com_content/src/View/Category/HtmlView.php index cf1129a7dba96..90e31bf226918 100644 --- a/components/com_content/src/View/Category/HtmlView.php +++ b/components/com_content/src/View/Category/HtmlView.php @@ -140,10 +140,6 @@ public function display($tpl = null) { $this->link_items[] = $item; } - else - { - continue; - } } } diff --git a/components/com_users/src/Controller/DisplayController.php b/components/com_users/src/Controller/DisplayController.php index a86ce49d3c295..0d29349d28cde 100644 --- a/components/com_users/src/Controller/DisplayController.php +++ b/components/com_users/src/Controller/DisplayController.php @@ -29,7 +29,7 @@ class DisplayController extends BaseController * @param array|boolean $urlparams An array of safe URL parameters and their variable types, * for valid values see {@link \Joomla\CMS\Filter\InputFilter::clean()}. * - * @return static This object to support chaining. + * @return void * * @since 1.5 * @throws \Exception diff --git a/components/com_users/src/Controller/ProfileController.php b/components/com_users/src/Controller/ProfileController.php index 6c67fbc33f0e1..e53fd9ef1d5c8 100644 --- a/components/com_users/src/Controller/ProfileController.php +++ b/components/com_users/src/Controller/ProfileController.php @@ -72,7 +72,7 @@ public function edit() /** * Method to save a user's profile data. * - * @return void + * @return void|boolean * * @since 1.6 * @throws \Exception diff --git a/layouts/plugins/system/privacyconsent/label.php b/layouts/plugins/system/privacyconsent/label.php index 7a0acc2323595..655f11905ca5f 100644 --- a/layouts/plugins/system/privacyconsent/label.php +++ b/layouts/plugins/system/privacyconsent/label.php @@ -91,6 +91,6 @@ } // Add the label text and star. -$label = $link . ' *'; +$label = $link . ''; echo $label; diff --git a/layouts/plugins/user/terms/label.php b/layouts/plugins/user/terms/label.php index 1fea2c1cd5746..1b4d3278a5b58 100644 --- a/layouts/plugins/user/terms/label.php +++ b/layouts/plugins/user/terms/label.php @@ -90,6 +90,6 @@ } // Add the label text and star. -$label = $link . ' *'; +$label = $link . ''; echo $label; diff --git a/libraries/src/Access/Access.php b/libraries/src/Access/Access.php index cb3cfb3d20ae0..c0d63b579988a 100644 --- a/libraries/src/Access/Access.php +++ b/libraries/src/Access/Access.php @@ -1045,7 +1045,7 @@ public static function getAuthorisedViewLevels($userId) } } - return $authorised; + return array_unique($authorised); } // Get all groups that the user is mapped to recursively. @@ -1070,7 +1070,7 @@ public static function getAuthorisedViewLevels($userId) } } - return $authorised; + return array_unique($authorised); } /** diff --git a/libraries/src/Adapter/Adapter.php b/libraries/src/Adapter/Adapter.php index b315888544cdf..738777623b824 100644 --- a/libraries/src/Adapter/Adapter.php +++ b/libraries/src/Adapter/Adapter.php @@ -75,8 +75,8 @@ class Adapter extends CMSObject public function __construct($basepath, $classprefix = null, $adapterfolder = null) { $this->_basepath = $basepath; - $this->_classprefix = $classprefix ? $classprefix : 'J'; - $this->_adapterfolder = $adapterfolder ? $adapterfolder : 'adapters'; + $this->_classprefix = $classprefix ?: 'J'; + $this->_adapterfolder = $adapterfolder ?: 'adapters'; $this->_db = Factory::getDbo(); } diff --git a/libraries/src/Application/ApplicationHelper.php b/libraries/src/Application/ApplicationHelper.php index b244388d5f325..454e5978659d7 100644 --- a/libraries/src/Application/ApplicationHelper.php +++ b/libraries/src/Application/ApplicationHelper.php @@ -182,8 +182,6 @@ public static function getClientInfo($id = null, $byName = false) } } } - - return; } /** diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 4b70a394fd06c..93a741f8c272a 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -1137,8 +1137,6 @@ public function setUserState($key, $value) { return $registry->set($key, $value); } - - return; } /** diff --git a/libraries/src/Document/FeedDocument.php b/libraries/src/Document/FeedDocument.php index 1c580a0a4f370..e90261af9cd72 100644 --- a/libraries/src/Document/FeedDocument.php +++ b/libraries/src/Document/FeedDocument.php @@ -203,7 +203,7 @@ public function render($cache = false, $params = array()) $type = CmsFactory::getApplication()->input->get('type', 'rss'); // Instantiate feed renderer and set the mime encoding - $renderer = $this->loadRenderer(($type) ? $type : 'rss'); + $renderer = $this->loadRenderer($type ?: 'rss'); if (!($renderer instanceof DocumentRenderer)) { diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index 1e07878b7e4b1..b097b459c3277 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -326,7 +326,7 @@ public function setHeadData($data) * * @param array $data The document head data in array form * - * @return HtmlDocument|null instance of $this to allow chaining or null for empty input data + * @return HtmlDocument|void instance of $this to allow chaining or void for empty input data * * @since 1.7.0 */ diff --git a/libraries/src/Document/Renderer/Html/MetasRenderer.php b/libraries/src/Document/Renderer/Html/MetasRenderer.php index 063028fb1d6f3..371437c0cde93 100644 --- a/libraries/src/Document/Renderer/Html/MetasRenderer.php +++ b/libraries/src/Document/Renderer/Html/MetasRenderer.php @@ -67,7 +67,7 @@ public function render($head, $params = array(), $content = null) { $prettyPrint = (JDEBUG && \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false); $jsonOptions = json_encode($scriptOptions, $prettyPrint); - $jsonOptions = $jsonOptions ? $jsonOptions : '{}'; + $jsonOptions = $jsonOptions ?: '{}'; $wa->addInlineScript( $jsonOptions, diff --git a/libraries/src/Environment/Browser.php b/libraries/src/Environment/Browser.php index b9164d05d90bc..0a3acdd115b61 100644 --- a/libraries/src/Environment/Browser.php +++ b/libraries/src/Environment/Browser.php @@ -902,8 +902,6 @@ public function getHTTPProtocol() return substr($_SERVER['SERVER_PROTOCOL'], $pos + 1); } } - - return; } /** diff --git a/libraries/src/Feed/FeedParser.php b/libraries/src/Feed/FeedParser.php index 19a41df4a9027..9e727ddbf8441 100644 --- a/libraries/src/Feed/FeedParser.php +++ b/libraries/src/Feed/FeedParser.php @@ -63,7 +63,7 @@ abstract class FeedParser public function __construct(\XMLReader $stream, InputFilter $inputFilter = null) { $this->stream = $stream; - $this->inputFilter = $inputFilter ? $inputFilter : InputFilter::getInstance(array(), array(), 1, 1); + $this->inputFilter = $inputFilter ?: InputFilter::getInstance([], [], 1, 1); } /** diff --git a/libraries/src/Filesystem/Folder.php b/libraries/src/Filesystem/Folder.php index 3b2c4766e6bbf..f2ccf1340d6a1 100644 --- a/libraries/src/Filesystem/Folder.php +++ b/libraries/src/Filesystem/Folder.php @@ -489,7 +489,7 @@ public static function exists($path) * @param array $excludeFilter Array of filter to exclude * @param boolean $naturalSort False for asort, true for natsort * - * @return array Files in the given folder. + * @return array|boolean Files in the given folder. * * @since 1.7.0 */ diff --git a/libraries/src/Filesystem/Stream.php b/libraries/src/Filesystem/Stream.php index ac459fa1c8548..7c4629a8b81cd 100644 --- a/libraries/src/Filesystem/Stream.php +++ b/libraries/src/Filesystem/Stream.php @@ -894,7 +894,7 @@ public function chmod($filename = '', $mode = 0) /** * Get the stream metadata * - * @return array header/metadata + * @return array|boolean header/metadata * * @link https://www.php.net/manual/en/function.stream-get-meta-data.php * @since 1.7.0 diff --git a/libraries/src/Form/Field/UserField.php b/libraries/src/Form/Field/UserField.php index 0bf7e5a9ae2e6..e7574a08e77de 100644 --- a/libraries/src/Form/Field/UserField.php +++ b/libraries/src/Form/Field/UserField.php @@ -160,8 +160,6 @@ protected function getGroups() { return explode(',', $this->element['groups']); } - - return; } /** @@ -177,7 +175,5 @@ protected function getExcluded() { return explode(',', $this->element['exclude']); } - - return; } } diff --git a/libraries/src/Form/Form.php b/libraries/src/Form/Form.php index e2959094070de..3a1cac1210f54 100644 --- a/libraries/src/Form/Form.php +++ b/libraries/src/Form/Form.php @@ -44,7 +44,7 @@ class Form * @var array * @since 1.7.0 */ - protected $errors = array(); + protected $errors = []; /** * The name of the form instance. @@ -60,7 +60,7 @@ class Form * @var array * @since 1.7.0 */ - protected $options = array(); + protected $options = []; /** * The form XML definition. @@ -76,7 +76,7 @@ class Form * @var Form[] * @since 1.7.0 */ - protected static $forms = array(); + protected static $forms = []; /** * Allows extensions to implement repeating elements @@ -94,7 +94,7 @@ class Form * * @since 1.7.0 */ - public function __construct($name, array $options = array()) + public function __construct($name, array $options = []) { // Set the name for the form. $this->name = $name; @@ -277,7 +277,7 @@ public function getFieldAttribute($name, $attribute, $default = null, $group = n */ public function getFieldset($set = null) { - $fields = array(); + $fields = []; // Get all of the field elements in the fieldset. if ($set) @@ -302,7 +302,7 @@ public function getFieldset($set = null) { // Get the field groups for the element. $attrs = $element->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); $group = implode('.', $groups); // If the field is successfully loaded add it to the result array. @@ -326,8 +326,8 @@ public function getFieldset($set = null) */ public function getFieldsets($group = null) { - $fieldsets = array(); - $sets = array(); + $fieldsets = []; + $sets = []; // Make sure there is a valid Form XML document. if (!($this->xml instanceof \SimpleXMLElement)) @@ -452,7 +452,7 @@ public function getFormControl() */ public function getGroup($group, $nested = false) { - $fields = array(); + $fields = []; // Get all of the field elements in the field group. $elements = $this->findFieldsByGroup($group, $nested); @@ -468,7 +468,7 @@ public function getGroup($group, $nested = false) { // Get the field groups for the element. $attrs = $element->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); $group = implode('.', $groups); // If the field is successfully loaded add it to the result array. @@ -574,7 +574,7 @@ public function getValue($name, $group = null, $default = null) * * @since 3.2.3 */ - public function renderField($name, $group = null, $default = null, $options = array()) + public function renderField($name, $group = null, $default = null, $options = []) { $field = $this->getField($name, $group, $default); @@ -596,10 +596,10 @@ public function renderField($name, $group = null, $default = null, $options = ar * * @since 3.2.3 */ - public function renderFieldset($name, $options = array()) + public function renderFieldset($name, $options = []) { $fields = $this->getFieldset($name); - $html = array(); + $html = []; foreach ($fields as $field) { @@ -670,7 +670,7 @@ public function load($data, $replace = true, $xpath = null) } // Get the XML elements to load. - $elements = array(); + $elements = []; if ($xpath) { @@ -697,7 +697,7 @@ public function load($data, $replace = true, $xpath = null) { // Get the group names as strings for ancestor fields elements. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); // Check to see if the field exists in the current form. if ($current = $this->findField((string) $field['name'], implode('.', $groups))) @@ -1133,7 +1133,7 @@ public function filter($data, $group = null) // Get the field groups for the element. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); $attrGroup = implode('.', $groups); $key = $attrGroup ? $attrGroup . '.' . $name : $name; @@ -1225,7 +1225,7 @@ public function validate($data, $group = null) // Get the field groups for the element. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); $attrGroup = implode('.', $groups); $key = $attrGroup ? $attrGroup . '.' . $name : $name; @@ -1292,7 +1292,7 @@ public function postProcess($data, $group = null) // Get the field groups for the element. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $groups = array_map('strval', $attrs ? $attrs : array()); + $groups = array_map('strval', $attrs ?: []); $attrGroup = implode('.', $groups); $key = $attrGroup ? $attrGroup . '.' . $name : $name; @@ -1321,7 +1321,7 @@ public function postProcess($data, $group = null) protected function findField($name, $group = null) { $element = false; - $fields = array(); + $fields = []; // Make sure there is a valid Form XML document. if (!($this->xml instanceof \SimpleXMLElement)) @@ -1358,7 +1358,7 @@ protected function findField($name, $group = null) { // Get the group names as strings for ancestor fields elements. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $names = array_map('strval', $attrs ? $attrs : array()); + $names = array_map('strval', $attrs ?: []); // If the field is in the exact group use it and break out of the loop. if ($names == (array) $groupNames) @@ -1445,7 +1445,7 @@ protected function &findFieldsByFieldset($name) protected function &findFieldsByGroup($group = null, $nested = false) { $false = false; - $fields = array(); + $fields = []; // Make sure there is a valid Form XML document. if (!($this->xml instanceof \SimpleXMLElement)) @@ -1480,7 +1480,7 @@ protected function &findFieldsByGroup($group = null, $nested = false) { // Get the names of the groups that the field is in. $attrs = $field->xpath('ancestor::fields[@name]/@name'); - $names = array_map('strval', $attrs ? $attrs : array()); + $names = array_map('strval', $attrs ?: []); // If the field is in the specific group then add it to the return list. if ($names == (array) $groupNames) @@ -1518,8 +1518,8 @@ protected function &findFieldsByGroup($group = null, $nested = false) protected function &findGroup($group) { $false = false; - $groups = array(); - $tmp = array(); + $groups = []; + $tmp = []; // Make sure there is a valid Form XML document. if (!($this->xml instanceof \SimpleXMLElement)) @@ -1550,7 +1550,7 @@ protected function &findGroup($group) // Initialise some loop variables. $validNames = \array_slice($group, 0, $i + 1); $current = $tmp; - $tmp = array(); + $tmp = []; // Check to make sure that there are no parent groups for each element. foreach ($current as $element) @@ -1563,7 +1563,7 @@ protected function &findGroup($group) { // Get the group names as strings for ancestor fields elements. $attrs = $fields->xpath('ancestor-or-self::fields[@name]/@name'); - $names = array_map('strval', $attrs ? $attrs : array()); + $names = array_map('strval', $attrs ?: []); // If the group names for the fields element match the valid names at this // level add the fields element. @@ -1679,7 +1679,7 @@ protected function syncPaths() // Get any addfieldpath attributes from the form definition. $paths = $this->xml->xpath('//*[@addfieldpath]/@addfieldpath'); - $paths = array_map('strval', $paths ? $paths : array()); + $paths = array_map('strval', $paths ?: []); // Add the field paths. foreach ($paths as $path) @@ -1690,7 +1690,7 @@ protected function syncPaths() // Get any addformpath attributes from the form definition. $paths = $this->xml->xpath('//*[@addformpath]/@addformpath'); - $paths = array_map('strval', $paths ? $paths : array()); + $paths = array_map('strval', $paths ?: []); // Add the form paths. foreach ($paths as $path) @@ -1701,7 +1701,7 @@ protected function syncPaths() // Get any addrulepath attributes from the form definition. $paths = $this->xml->xpath('//*[@addrulepath]/@addrulepath'); - $paths = array_map('strval', $paths ? $paths : array()); + $paths = array_map('strval', $paths ?: []); // Add the rule paths. foreach ($paths as $path) @@ -1712,7 +1712,7 @@ protected function syncPaths() // Get any addrulepath attributes from the form definition. $paths = $this->xml->xpath('//*[@addfilterpath]/@addfilterpath'); - $paths = array_map('strval', $paths ? $paths : array()); + $paths = array_map('strval', $paths ?: []); // Add the rule paths. foreach ($paths as $path) @@ -1723,7 +1723,7 @@ protected function syncPaths() // Get any addfieldprefix attributes from the form definition. $prefixes = $this->xml->xpath('//*[@addfieldprefix]/@addfieldprefix'); - $prefixes = array_map('strval', $prefixes ? $prefixes : array()); + $prefixes = array_map('strval', $prefixes ?: []); // Add the field prefixes. foreach ($prefixes as $prefix) @@ -1733,7 +1733,7 @@ protected function syncPaths() // Get any addformprefix attributes from the form definition. $prefixes = $this->xml->xpath('//*[@addformprefix]/@addformprefix'); - $prefixes = array_map('strval', $prefixes ? $prefixes : array()); + $prefixes = array_map('strval', $prefixes ?: []); // Add the field prefixes. foreach ($prefixes as $prefix) @@ -1743,7 +1743,7 @@ protected function syncPaths() // Get any addruleprefix attributes from the form definition. $prefixes = $this->xml->xpath('//*[@addruleprefix]/@addruleprefix'); - $prefixes = array_map('strval', $prefixes ? $prefixes : array()); + $prefixes = array_map('strval', $prefixes ?: []); // Add the field prefixes. foreach ($prefixes as $prefix) @@ -1753,7 +1753,7 @@ protected function syncPaths() // Get any addruleprefix attributes from the form definition. $prefixes = $this->xml->xpath('//*[@addfilterprefix]/@addfilterprefix'); - $prefixes = array_map('strval', $prefixes ? $prefixes : array()); + $prefixes = array_map('strval', $prefixes ?: []); // Add the field prefixes. foreach ($prefixes as $prefix) @@ -1840,7 +1840,7 @@ public static function addFilterPath($new = null) * @throws \InvalidArgumentException if no data provided. * @throws \RuntimeException if the form could not be loaded. */ - public static function getInstance($name, $data = null, $options = array(), $replace = true, $xpath = false) + public static function getInstance($name, $data = null, $options = [], $replace = true, $xpath = false) { // Reference to array with form instances $forms = &self::$forms; diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 456bf6c5dee90..d328421e3bf69 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -489,8 +489,6 @@ public function __get($name) return $this->dataAttributes[$name]; } } - - return; } /** @@ -749,11 +747,11 @@ protected function getId($fieldId, $fieldName) // If we already have an id segment add the field id/name as another level. if ($id) { - $id .= '_' . ($fieldId ? $fieldId : $fieldName); + $id .= '_' . ($fieldId ?: $fieldName); } else { - $id .= ($fieldId ? $fieldId : $fieldName); + $id .= ($fieldId ?: $fieldName); } // Clean up any invalid characters. diff --git a/libraries/src/Helper/LibraryHelper.php b/libraries/src/Helper/LibraryHelper.php index cc584f4d7c4b9..639e6a4958e6e 100644 --- a/libraries/src/Helper/LibraryHelper.php +++ b/libraries/src/Helper/LibraryHelper.php @@ -102,7 +102,7 @@ public static function getParams($element, $strict = false) * @param string $element Element of the library in the extensions table. * @param Registry $params Params to save * - * @return Registry A Registry object. + * @return Registry|boolean A Registry object. * * @see Registry * @since 3.2 diff --git a/libraries/src/Installer/Adapter/LibraryAdapter.php b/libraries/src/Installer/Adapter/LibraryAdapter.php index 498e9b393f014..8600e7d3e50c5 100644 --- a/libraries/src/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/Installer/Adapter/LibraryAdapter.php @@ -372,8 +372,8 @@ protected function setupUninstall() // Set the library root path $this->parent->setPath('extension_root', JPATH_PLATFORM . '/' . $manifest->libraryname); - // Set the source path to the manifests directory so the manifest script may be found - $this->parent->setPath('source', JPATH_MANIFESTS . '/libraries/' . $manifest->libraryname); + // Set the source path to the library root, the manifest script may be found + $this->parent->setPath('source', $this->parent->getPath('extension_root')); $xml = simplexml_load_file($manifestFile); diff --git a/libraries/src/Language/Language.php b/libraries/src/Language/Language.php index abf4ba635bcc6..e44a4c859f80c 100644 --- a/libraries/src/Language/Language.php +++ b/libraries/src/Language/Language.php @@ -1022,12 +1022,10 @@ public function getPaths($extension = null) return $this->paths[$extension]; } - return; - } - else - { - return $this->paths; + return []; } + + return $this->paths; } /** diff --git a/libraries/src/Log/LogEntry.php b/libraries/src/Log/LogEntry.php index dc15a627b700e..ae08cc215e085 100644 --- a/libraries/src/Log/LogEntry.php +++ b/libraries/src/Log/LogEntry.php @@ -121,6 +121,6 @@ public function __construct($message, $priority = Log::INFO, $category = '', $da $this->callStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); // Get the date as a Date object. - $this->date = new Date($date ? $date : 'now'); + $this->date = new Date($date ?: 'now'); } } diff --git a/libraries/src/MVC/Controller/BaseController.php b/libraries/src/MVC/Controller/BaseController.php index 6b0a2a715f353..b7766baabad6c 100644 --- a/libraries/src/MVC/Controller/BaseController.php +++ b/libraries/src/MVC/Controller/BaseController.php @@ -380,8 +380,8 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu $this->redirect = null; $this->taskMap = array(); - $this->app = $app ? $app : Factory::getApplication(); - $this->input = $input ? $input : $this->app->input; + $this->app = $app ?: Factory::getApplication(); + $this->input = $input ?: $this->app->input; if (\defined('JDEBUG') && JDEBUG) { diff --git a/libraries/src/MVC/Model/AdminModel.php b/libraries/src/MVC/Model/AdminModel.php index 73373178010bd..23c5d049ecd94 100644 --- a/libraries/src/MVC/Model/AdminModel.php +++ b/libraries/src/MVC/Model/AdminModel.php @@ -1214,8 +1214,6 @@ public function publish(&$pks, $value = 1) if (property_exists($table, $publishedColumnName) && $table->get($publishedColumnName, $value) == $value) { unset($pks[$i]); - - continue; } } } diff --git a/libraries/src/MVC/Model/ListModel.php b/libraries/src/MVC/Model/ListModel.php index 11017826aa5b0..5d62f206ebd5b 100644 --- a/libraries/src/MVC/Model/ListModel.php +++ b/libraries/src/MVC/Model/ListModel.php @@ -14,6 +14,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormFactoryAwareInterface; use Joomla\CMS\Form\FormFactoryAwareTrait; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Pagination\Pagination; @@ -24,7 +25,7 @@ * * @since 1.6 */ -class ListModel extends BaseDatabaseModel implements ListModelInterface +class ListModel extends BaseDatabaseModel implements FormFactoryAwareInterface, ListModelInterface { use FormBehaviorTrait; use FormFactoryAwareTrait; diff --git a/libraries/src/Mail/MailHelper.php b/libraries/src/Mail/MailHelper.php index a830380a5a2af..dc6b824b927a2 100644 --- a/libraries/src/Mail/MailHelper.php +++ b/libraries/src/Mail/MailHelper.php @@ -10,7 +10,9 @@ \defined('JPATH_PLATFORM') or die; +use Joomla\CMS\Router\Route; use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Uri\Uri; /** * Email helper class, provides static methods to perform various tasks relevant @@ -192,4 +194,88 @@ public static function isEmailAddress($email) return true; } + + /** + * Convert relative (links, images sources) to absolute urls so that content is accessible in email + * + * @param string $content The content need to convert + * + * @return string The converted content which the relative urls are converted to absolute urls + * + * @since __DEPLOY_VERSION__ + */ + public static function convertRelativeToAbsoluteUrls($content) + { + $siteUrl = Uri::root(); + + // Replace none SEF URLs by absolute SEF URLs + if (strpos($content, 'href="index.php?') !== false) + { + preg_match_all('#href="index.php\?([^"]+)"#m', $content, $matches); + + foreach ($matches[1] as $urlQueryString) + { + $content = str_replace( + 'href="index.php?' . $urlQueryString . '"', + 'href="' . Route::link('site', 'index.php?' . $urlQueryString, Route::TLS_IGNORE, true) . '"', + $content + ); + } + + self::checkContent($content); + } + + // Replace relative links, image sources with absolute Urls + $protocols = '[a-zA-Z0-9\-]+:'; + $attributes = array('href=', 'src=', 'poster='); + + foreach ($attributes as $attribute) + { + if (strpos($content, $attribute) !== false) + { + $regex = '#\s' . $attribute . '"(?!/|' . $protocols . '|\#|\')([^"]*)"#m'; + + $content = preg_replace($regex, ' ' . $attribute . '"' . $siteUrl . '$1"', $content); + + self::checkContent($content); + } + } + + return $content; + } + + /** + * Check the content after regular expression function call. + * + * @param string $content Content to be checked. + * + * @return void + * + * @throws \RuntimeException If there is an error in previous regular expression function call. + * @since __DEPLOY_VERSION__ + */ + private static function checkContent($content) + { + if ($content !== null) + { + return; + } + + switch (preg_last_error()) + { + case PREG_BACKTRACK_LIMIT_ERROR: + $message = 'PHP regular expression limit reached (pcre.backtrack_limit)'; + break; + case PREG_RECURSION_LIMIT_ERROR: + $message = 'PHP regular expression limit reached (pcre.recursion_limit)'; + break; + case PREG_BAD_UTF8_ERROR: + $message = 'Bad UTF8 passed to PCRE function'; + break; + default: + $message = 'Unknown PCRE error calling PCRE function'; + } + + throw new \RuntimeException($message); + } } diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index 994fc90f1adb8..59d314d0c8b5a 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -263,6 +263,8 @@ public function send() $htmlBody = nl2br($plainBody, false); } + $htmlBody = MailHelper::convertRelativeToAbsoluteUrls($htmlBody); + $this->mailer->setBody($htmlBody); } diff --git a/libraries/src/Table/User.php b/libraries/src/Table/User.php index 42b97eea88319..8847c34e19ea7 100644 --- a/libraries/src/Table/User.php +++ b/libraries/src/Table/User.php @@ -542,7 +542,7 @@ public function setLastVisit($timeStamp = null, $userId = null) } } - // If no timestamp value is passed to function, than current time is used. + // If no timestamp value is passed to function, then current time is used. if ($timeStamp === null) { $timeStamp = 'now'; diff --git a/libraries/src/WebAsset/WebAssetManager.php b/libraries/src/WebAsset/WebAssetManager.php index aced4c4e7ce38..b50e24c89784d 100644 --- a/libraries/src/WebAsset/WebAssetManager.php +++ b/libraries/src/WebAsset/WebAssetManager.php @@ -363,7 +363,7 @@ protected function usePresetItems($name): WebAssetManagerInterface $depName = substr($dependency, 0, $pos); } - $depType = $depType ? $depType : 'preset'; + $depType = $depType ?: 'preset'; // Make sure dependency exists if (!$this->registry->exists($depType, $depName)) @@ -409,7 +409,7 @@ protected function disablePresetItems($name): WebAssetManagerInterface $depName = substr($dependency, 0, $pos); } - $depType = $depType ? $depType : 'preset'; + $depType = $depType ?: 'preset'; // Make sure dependency exists if (!$this->registry->exists($depType, $depName)) diff --git a/libraries/src/Workflow/Workflow.php b/libraries/src/Workflow/Workflow.php index c4583f84a9fb4..488f7d8ce5f09 100644 --- a/libraries/src/Workflow/Workflow.php +++ b/libraries/src/Workflow/Workflow.php @@ -179,8 +179,6 @@ public function getDefaultStageByCategory($catId = 0) if ($workflow_id == 'inherit') { $workflow_id = 0; - - continue; } elseif ($workflow_id == 'use_default') { diff --git a/modules/mod_tags_popular/mod_tags_popular.xml b/modules/mod_tags_popular/mod_tags_popular.xml index f0fe555d4f120..3e0d17d1cda89 100644 --- a/modules/mod_tags_popular/mod_tags_popular.xml +++ b/modules/mod_tags_popular/mod_tags_popular.xml @@ -35,13 +35,12 @@ getAuthorisedViewLevels(); $timeframe = $params->get('timeframe', 'alltime'); - $maximum = $params->get('maximum', 5); + $maximum = (int) $params->get('maximum', 5); $order_value = $params->get('order_value', 'title'); $nowDate = Factory::getDate()->toSql(); $nullDate = $db->getNullDate(); @@ -127,7 +127,11 @@ public static function getList(&$params) // Backup bound parameters array of the original query $bounded = $query->getBounded(); - $query->setLimit($maximum); + if ($maximum > 0) + { + $query->setLimit($maximum); + } + $query->order($db->quoteName('count') . ' DESC'); $equery = $db->getQuery(true) ->select( @@ -158,7 +162,11 @@ public static function getList(&$params) } } - $query->setLimit($maximum, 0); + if ($maximum > 0) + { + $query->setLimit($maximum); + } + $db->setQuery($query); try diff --git a/modules/mod_tags_similar/mod_tags_similar.xml b/modules/mod_tags_similar/mod_tags_similar.xml index 3551db24ece7b..119a6c49cea39 100644 --- a/modules/mod_tags_similar/mod_tags_similar.xml +++ b/modules/mod_tags_similar/mod_tags_similar.xml @@ -25,13 +25,12 @@
    order($query->rand()); } - $query->setLimit((int) $params->get('maximum', 5)); + $maximum = (int) $params->get('maximum', 5); + + if ($maximum > 0) + { + $query->setLimit($maximum); + } + $db->setQuery($query); try diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml index 0fb4089e45789..173057a45c543 100644 --- a/plugins/editors/tinymce/forms/setoptions.xml +++ b/plugins/editors/tinymce/forms/setoptions.xml @@ -113,6 +113,7 @@ default="en" hide_default="1" fileFilter="\.js$" + exclude="\.min\.js$" showon="lang_mode:0" validate="options" /> diff --git a/plugins/editors/tinymce/src/Field/TinymcebuilderField.php b/plugins/editors/tinymce/src/Field/TinymcebuilderField.php index 3ba3433caabac..e2dd9b9e48053 100644 --- a/plugins/editors/tinymce/src/Field/TinymcebuilderField.php +++ b/plugins/editors/tinymce/src/Field/TinymcebuilderField.php @@ -166,8 +166,8 @@ protected function getLayoutData() // Check for TinyMCE language file $language = Factory::getLanguage(); - $languageFile1 = 'media/vendor/tinymce/langs/' . $language->getTag() . '.js'; - $languageFile2 = 'media/vendor/tinymce/langs/' . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . '.js'; + $languageFile1 = 'media/vendor/tinymce/langs/' . $language->getTag() . (JDEBUG ? '.js' : '.min.js'); + $languageFile2 = 'media/vendor/tinymce/langs/' . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . (JDEBUG ? '.js' : '.min.js'); $data['languageFile'] = ''; diff --git a/plugins/filesystem/local/src/Adapter/LocalAdapter.php b/plugins/filesystem/local/src/Adapter/LocalAdapter.php index 495a89a24d832..a47c16a4d8e1a 100644 --- a/plugins/filesystem/local/src/Adapter/LocalAdapter.php +++ b/plugins/filesystem/local/src/Adapter/LocalAdapter.php @@ -215,7 +215,7 @@ public function createFolder(string $name, string $path): string * * @param string $name The name * @param string $path The folder - * @param binary $data The data + * @param string $data The data * * @return string * @@ -240,7 +240,7 @@ public function createFile(string $name, string $path, $data): string * * @param string $name The name * @param string $path The folder - * @param binary $data The data + * @param string $data The data * * @return void * diff --git a/plugins/sampledata/multilang/multilang.php b/plugins/sampledata/multilang/multilang.php index c05112eb9841b..e432adcbb2126 100644 --- a/plugins/sampledata/multilang/multilang.php +++ b/plugins/sampledata/multilang/multilang.php @@ -1183,8 +1183,6 @@ private function publishContentLanguages() if ($tableLanguage->load(array('lang_code' => $siteLang->language, 'published' => 0)) && !$tableLanguage->publish()) { $this->app->enqueueMessage(Text::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_CREATE_CONTENT_LANGUAGE', $siteLang->name), 'warning'); - - continue; } } diff --git a/plugins/system/debug/src/DataFormatter.php b/plugins/system/debug/src/DataFormatter.php index 3ba543fd79c87..878c10cce0a10 100644 --- a/plugins/system/debug/src/DataFormatter.php +++ b/plugins/system/debug/src/DataFormatter.php @@ -51,7 +51,7 @@ public function formatCallerInfo(array $call): string // If entry has Class/Method print it. $string .= htmlspecialchars($call['class'] . $call['type'] . $call['function']) . '()'; } - elseif (isset($call['args']) && \is_array($call['args'][0])) + elseif (isset($call['args'][0]) && \is_array($call['args'][0])) { $string .= htmlspecialchars($call['function']) . ' ('; @@ -74,7 +74,7 @@ public function formatCallerInfo(array $call): string $string = rtrim($string, ', ') . ')'; } - elseif (isset($call['args'])) + elseif (isset($call['args'][0])) { $string .= htmlspecialchars($call['function']) . ' ' . $call['args'][0]; } diff --git a/plugins/user/profile/src/Field/TosField.php b/plugins/user/profile/src/Field/TosField.php index aa01a286ec0b0..c9decbbcdb1ad 100644 --- a/plugins/user/profile/src/Field/TosField.php +++ b/plugins/user/profile/src/Field/TosField.php @@ -144,7 +144,7 @@ protected function getLabel() } // Add the label text and closing tag. - $label .= '>' . $link . ' *'; + $label .= '>' . $link . ''; return $label; }