Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Fix $language default parameter #44575

Open
wants to merge 1 commit into
base: 5.3-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions components/com_contact/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ abstract class RouteHelper
*
* @param integer $id The id of the contact
* @param integer $catid The id of the contact's category
* @param mixed $language The id of the language being used.
* @param string $language The language code.
*
* @return string The link to the contact
*
* @since 1.5
*/
public static function getContactRoute($id, $catid, $language = 0)
public static function getContactRoute($id, $catid, $language = null)
{
// Create the link
$link = 'index.php?option=com_contact&view=contact&id=' . $id;
Expand All @@ -47,7 +47,7 @@ public static function getContactRoute($id, $catid, $language = 0)
$link .= '&catid=' . $catid;
}

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand All @@ -57,14 +57,14 @@ public static function getContactRoute($id, $catid, $language = 0)
/**
* Get the URL route for a contact category from a contact category ID and language
*
* @param mixed $catid The id of the contact's category either an integer id or an instance of CategoryNode
* @param mixed $language The id of the language being used.
* @param mixed $catid The id of the contact's category either an integer id or an instance of CategoryNode
* @param string $language The language code.
*
* @return string The link to the contact
*
* @since 1.5
*/
public static function getCategoryRoute($catid, $language = 0)
public static function getCategoryRoute($catid, $language = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -78,7 +78,7 @@ public static function getCategoryRoute($catid, $language = 0)
// Create the link
$link = 'index.php?option=com_contact&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static function getArticleRoute($id, $catid = 0, $language = null, $layou
* Get the category route.
*
* @param integer $catid The category ID.
* @param integer $language The language code.
* @param string $language The language code.
* @param string $layout The layout value.
*
* @return string The article route.
*
* @since 1.5
*/
public static function getCategoryRoute($catid, $language = 0, $layout = null)
public static function getCategoryRoute($catid, $language = null, $layout = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -81,7 +81,7 @@ public static function getCategoryRoute($catid, $language = 0, $layout = null)

$link = 'index.php?option=com_content&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand Down
18 changes: 9 additions & 9 deletions components/com_newsfeeds/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ abstract class RouteHelper
/**
* getNewsfeedRoute
*
* @param int $id menu itemid
* @param int $catid category id
* @param int $language language
* @param int $id menu itemid
* @param int $catid category id
* @param string $language language
*
* @return string
*/
public static function getNewsfeedRoute($id, $catid, $language = 0)
public static function getNewsfeedRoute($id, $catid, $language = null)
{
// Create the link
$link = 'index.php?option=com_newsfeeds&view=newsfeed&id=' . $id;
Expand All @@ -42,7 +42,7 @@ public static function getNewsfeedRoute($id, $catid, $language = 0)
$link .= '&catid=' . $catid;
}

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand All @@ -52,12 +52,12 @@ public static function getNewsfeedRoute($id, $catid, $language = 0)
/**
* getCategoryRoute
*
* @param int $catid category id
* @param int $language language
* @param int $catid category id
* @param string $language language
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0)
public static function getCategoryRoute($catid, $language = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -71,7 +71,7 @@ public static function getCategoryRoute($catid, $language = 0)
// Create the link
$link = 'index.php?option=com_newsfeeds&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected function findItem($needles = [])
* Fetches the category route
*
* @param mixed $catid Category ID or CategoryNode instance
* @param mixed $language Language code
* @param string $language Language code
* @param string $extension Extension to lookup
*
* @return string
Expand All @@ -217,7 +217,7 @@ protected function findItem($needles = [])
*
* @throws \InvalidArgumentException
*/
public static function getCategoryRoute($catid, $language = 0, $extension = '')
public static function getCategoryRoute($catid, $language = null, $extension = '')
{
// Note: $extension is required but has to be an optional argument in the function call due to argument order
if (empty($extension)) {
Expand All @@ -242,7 +242,7 @@ public static function getCategoryRoute($catid, $language = 0, $extension = '')
'category' => [$id],
];

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
$needles['language'] = $language;
}
Expand Down