Skip to content

[5.3] Fix undefined array key "language" in sef plugin #45959

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

Open
wants to merge 1 commit into
base: 5.3-dev
Choose a base branch
from

Conversation

richard67
Copy link
Member

@richard67 richard67 commented Aug 21, 2025

Pull Request for Issue #45820 .

Summary of Changes

This pull request (PR) fixes the undefined array key "language" error in the SEF plugin on multilingual sites.

Testing Instructions

See issue #45820 :

Set up a multilingual site with SEF URLs enabled.

Enable the SEF plugin with its default settings.

Visit the site (frontend) and check your PHP error log.

Actual result BEFORE applying this Pull Request

PHP Warning: Undefined array key "language" in /plugins/system/sef/src/Extension/Sef.php on line 122.

Expected result AFTER applying this Pull Request

Not such PHP warning.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@mckillo
Copy link

mckillo commented Aug 21, 2025

Tested JL 5.3.3. It works.

@richard67
Copy link
Member Author

Tested JL 5.3.3. It works.

@mckillo Could you mark your test result in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/45959 by using the blue "Test this" button at the top left corner, selecting your test result and submit, so your test is properly counted?

Each PR needs 1 successful human tests to get accepted, and for this we have that counter and the issue tracker with that button.

Thanks in advance.

@mckillo
Copy link

mckillo commented Aug 21, 2025

I have tested this item ✅ successfully on 179b4df


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45959.

@mckillo
Copy link

mckillo commented Aug 21, 2025

Thank you for explaining how to properly confirm my test for this issue.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45959.

@richard67
Copy link
Member Author

Thank you for explaining how to properly confirm my test for this issue.

@mckillo Welcome. If you would like to practice that further: On Saturday we will have a PBF (Pizza, Bugs & Fun) event were people meet virtually or physically to test PRs or fix issues by creating PR or helping with documentation.

As we (Joomla) celebrate our 20th birthday we hope to see many people joining it. Would be nice to have you, too.

You can find more info and the necessary links here: https://www.pizza-bugs-fun.com/en/

@richard67 richard67 added the PBF Pizza, Bugs and Fun label Aug 21, 2025
@obuisard
Copy link
Contributor

I was not able to replicate the problem... checked the PHP.ini file to ensure I would get the warning but to no avail... Emmanuel @exlemor as well

@exlemor
Copy link

exlemor commented Aug 23, 2025

I have tested this item 🔴 unsuccessfully on 179b4df

I have tested this unsuccessfully sadly @richard67.

Under PHP 8.1, 8.2, 8.3 or 8.4 - with PHP error_reporting=E_ALL and log_errors=On and can not get the error message to show up WITHOUT the PR applied. Olivier and I both were doing it at the same time, me on my hosting and him on his local environment BearsAmp, PHP 8.3 and he also couldn't get this error message to show BEFORE the patch applied.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45959.

@mckillo
Copy link

mckillo commented Aug 24, 2025

I have tried to investigate this problem in the site.

This are the data in the breakpoint of this line when the issue occurs, the variable $parsedVars['language'] does not exist.

image

Environment: Joomla 5.3.3, PHP 8.3.24, MariaDB 10.6.10
Site with multiple languages: ES, EN, FR, GE, IT

Steps to reproduce:

Current behavior:
The following warning message is displayed:
image

This happens because the link is wrong. The user (customer) changed the end article alias, but the link of button is the old.

Joomla tries to load the article with alias 787-precios-2023-24 (link button), which no longer exists.
Since the article with ID 787 is still valid, Joomla shows the warning for about one second and then automatically redirects to the correct URL: https://domain.com/web/tablon-de-informacion/787-precios-2024-25

Expected behavior:
Joomla should directly resolve the article by its ID and redirect to the updated alias, without showing the warning.

Additional information:
The article has multilingual associations with other languages:

image

I hope this information helps to reproduce the issue.

@mckillo
Copy link

mckillo commented Aug 24, 2025

The button link is the URL for the default language of the website.

The issue is not related to $parsedVars['language'], because before route.php runs there is no 'language' key in $vars. Also, the 'language' parameter does not exist in abstractUri.php either.

A possible solution for sites with multiple languages:
Perform the routing by ID instead, and do not show the warning.
$parsedVars['language'] should be initialized with the default site language if it is not defined in the link URL.
That way it would always exist, and the patch 179b4dff1a96659dbc3c15e4eb52c3840b33fc9d would not be necessary, because this provides a better fix for the root of the problem (origin).

Could this be the right solution?

@exlemor
Copy link

exlemor commented Aug 24, 2025

I have tried to investigate this problem in the site.

Hi @mckillo - I really appreciate that you went through all of this trouble to explain, and try to find a solution - sadly, I just went through it again and still can't get it to show the error ;( on my test site with 2 languages - wonder if it you need more than 2 languages for this to appear -

Either way, I really appreciate it!

@richard67
Copy link
Member Author

@Hackwar Could you check the 2 previous comments by @mckillo , #45959 (comment) and #45959 (comment) ? I'm not sure if the expected behaviour is right as I'm not deep enough into the router.

@mckillo
Copy link

mckillo commented Aug 24, 2025

More info about the case

This website runs on Joomla 5.3.3 (migrated from previous Joomla). The article URL contains the article ID (article - options - integration - used Id in the alias). The article is set only for the default language.

The first error is in the button link: it still points to the old link of the article. The current link uses a different alias, but the article ID is the same.

All SEF plugin settings are unused, and the issue originates earlier. The URL of the button (the old link with the article ID) is detected as isTainted and enters the if condition (line 118). The router detects an error in the URL: the alias part is incorrect while the ID is correct, since the article ID belongs to an active (published) article. Because of this, the router marks the URL as isTainted and tries to build a new URL for the article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug PBF Pizza, Bugs and Fun PR-5.3-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants