?
avatar Quy
Quy
21 Oct 2019

Steps to reproduce the issue

Install nightly build.
Log in back end.
Go to Global Configuration.

Actual result

switcher

System information (as much as possible)

Nightly build

avatar Quy Quy - open - 21 Oct 2019
avatar joomla-cms-bot joomla-cms-bot - change - 21 Oct 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Oct 2019
avatar infograf768
infograf768 - comment - 1 Nov 2019

I confirm the issue. One has to first use the switch on and off to get the No or Hide label.

avatar infograf768
infograf768 - comment - 1 Nov 2019

@Quy
Could you test modifying
https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/field/radio/switcher.php#L72-L73

by changing string to int, from

		$checked	= ((string) $option->value == $value) ? 'checked="checked"' : '';
		$active		= ((string) $option->value == $value) ? 'class="active"' : '';

to

		$checked	= ((int) $option->value == $value) ? 'checked="checked"' : '';
		$active		= ((int) $option->value == $value) ? 'class="active"' : '';
avatar infograf768
infograf768 - comment - 1 Nov 2019

If judged necessary we could check if the $option->value is numeric and use

		// Initialize some option attributes.
		if (is_numeric($option->value))
		{
			$checked = ((int) $option->value == $value) ? 'checked="checked"' : '';
			$active  = ((int) $option->value == $value) ? 'class="active"' : '';
		}
		else
		{
			$checked = ((string) $option->value == $value) ? 'checked="checked"' : '';
			$active  = ((string) $option->value == $value) ? 'class="active"' : '';
		}
avatar alikon
alikon - comment - 1 Nov 2019

tested your #26749 (comment) and works, not sure we need the IF but i let guru's to judge ?

avatar infograf768
infograf768 - comment - 1 Nov 2019

?

avatar Quy
Quy - comment - 1 Nov 2019

Only in Global Configuration, 0 and 1 are saved as false and true.
Compare configuration.php with \installation\configuration.php-dist to see that this is the case. See $offline for example.

Let's fix the source of the issue, then your fix might not be necessary.

avatar brianteeman
brianteeman - comment - 1 Nov 2019

The problem won't go away because of updates. Best to make it work with both

avatar Quy
Quy - comment - 1 Nov 2019

In J3, these values are 0 and 1. Only in J4, that they are saved as true and false.

avatar mbabker
mbabker - comment - 1 Nov 2019

4.0 uses proper types for most params, 3.x doesn’t (part of it is the Registry package was changed to dump data as proper scalars instead of always a string when dumping as a PHP file, which impacts generating configuration.php). So, for the 4.x lifetime, most param checks continue to need to not be strict or to typecast the data being read.

It would be good to have some tool that could bulk resave all params with proper types, but that might be a little too complex to pull off anytime soon (because to fix it otherwise pretty much requires a user to resave every configuration at every level).

avatar infograf768
infograf768 - comment - 1 Nov 2019

In fact the issue does not only concern Global Configuration, Third party extensions may also be concerned.
Therefore if I understood all from @mbabker above, will make the PR with the conditional.

avatar infograf768
infograf768 - comment - 2 Nov 2019

Please test #26908

Closing as we have a patch

avatar infograf768 infograf768 - close - 2 Nov 2019
avatar infograf768 infograf768 - change - 2 Nov 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-11-02 07:21:48
Closed_By infograf768

Add a Comment

Login with GitHub to post a comment