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

[4.2] Dashboards for third party extensions break when Unicode Aliases is toggled in Global Configuration #38849

Closed
nikosdion opened this issue Sep 27, 2022 · 4 comments

Comments

@nikosdion
Copy link
Contributor

Steps to reproduce the issue

TEST 1

  • Go to System, Global Configuration, Site.
  • Set Unicode Aliases to No (that's the default).
  • Click on Save & Close.
  • Go to extension's dashboard (e.g. Components, and click the dashboard icon next to Akeeba Release System)

TEST 2

  • Go to System, Global Configuration, Site.
  • Set Unicode Aliases to Yes.
  • Click on Save & Close.
  • Go to extension's dashboard (e.g. Components, and click the dashboard icon next to Akeeba Release System)

Expected result

Test 1: The dashboard is shown
Test 2: The dashboard is shown

Actual result

Test 1: The dashboard is NOT(!!!) shown
Test 2: The dashboard is shown

System information (as much as possible)

Irrelevant.

Additional comments

This is yet another blatant bug in Joomla 4 which is trivial to spot and fix — if someone actually uses the Joomla 4 features 😢

The problem lies in

$position = ApplicationHelper::stringURLSafe($dashboard);
The com_cpanel component's HtmlView converts the component specific dashboard (which must be provided as com_example.something) to a module position by putting that dashboard string through \Joomla\CMS\Application\ApplicationHelper::stringURLSafe.

However, what stringURLSafe does depends on the “Unicode Slugs” setting in Global Configuration 🤦🏽

When that setting is No the underscore is converted to a dash, therefore the module position for this dashboard is cpanel-com-example-something.

When that setting Yes the underscore remains as is, therefore the module position for this dashboard is cpanel-com_example-something.

Since a module cannot be published in two positions at the same time the Dashboard breaks depending on the Global Configuration “Unicode Slugs” setting.

You do not see that with core dashboards because Joomla cheats when it comes to itself!. Instead of using component-specific dashboards it uses hardcoded dashboard names which do not include the com_ prefix or a dot, they just contain lowercase characters a-z without diacritics. When this happens, going through stringURLSafe returns the string verbatim, therefore Joomla's cheating dashboards always work.

Proposal

Right now, there is not one valid module position to use with component-specific dashboards. The only reasonable solution is to replace

$position = ApplicationHelper::stringURLSafe($dashboard);

with

$position = \Joomla\CMS\Filter\OutputFilter::stringUrlUnicodeSlug($dashboard);

This way we will have predictable dashboards which always use the module position format cpanel-com-example-something.

Tagging @laoneo because his bug report in my repo led me to discover the root cause of this issue (as you may have guessed, being Greek I use Unicode Slugs on my multilingual dev site…) and because he's in the leadership so he can make a decision about how to best fix this.

@laoneo
Copy link
Member

laoneo commented Sep 28, 2022

I didn't dig too deep into the code, but from what you describe it sounds like a legit change. As it affects only the admin dashboard view it looks like that nothing will break as it doesn't work correctly anyway.

@Fedik
Copy link
Member

Fedik commented Sep 28, 2022

I think it should be compatible with the Modules position field

<field
name="position"
type="ModulesPositionedit"
label="COM_MODULES_FIELD_POSITION_LABEL"
default=""
maxlength="50"
client="site"
/>

Wich have a filter string in default.

return InputFilter::getInstance()->clean($value, $filter);

public function clean($source, $type = 'string')

@nikosdion
Copy link
Contributor Author

@Fedik Check my PR #38853 It does that now.

The dashboard URL parameter first goes through Input's getCmd, then goes through OutputFilter::stringURLSafe. This means we end up with alphanumeric and dash because of

$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str);

@Fedik
Copy link
Member

Fedik commented Sep 28, 2022

Okay, then I will close here, because we have a PR

@Fedik Fedik closed this as completed Sep 28, 2022
laoneo pushed a commit that referenced this issue Sep 29, 2022
* Fix third party component dashboards

* Remove unused `use` statement

* Make the position compatible with the string filter

See #38849 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants