No Code Attached Yet bug
avatar brianteeman
brianteeman
26 Apr 2023

Steps to reproduce the issue

PR #32342 broke the functionality of the wrapper menu item by changing it to a type url and adding url validation

There is a parameter in the optiion for this menu type called autoadd

By default, http:// will be added unless it detects http:// or https:// in the URL you provide. This allows you to switch off this functionality.

This cannot work when the field is a type url with validate and filter url

As a result it is not possible to have a wrapper to an internal url as http is always added

If it is not desired to be able to have an internal url then the following code is useless and should be cleaned up

<field
name="add_scheme"
type="radio"
label="COM_WRAPPER_FIELD_ADD_LABEL"
description="COM_WRAPPER_FIELD_ADD_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

$url = $params->def('url', '');
if ($params->def('add_scheme', 1)) {
// Adds 'http://' or 'https://' if none is set
if (strpos($url, '//') === 0) {
// URL without scheme in component. Prepend current scheme.
$wrapper->url = Uri::getInstance()->toString(['scheme']) . substr($url, 2);
} elseif (strpos($url, '/') === 0) {
// Relative URL in component. Use scheme + host + port.
$wrapper->url = Uri::getInstance()->toString(['scheme', 'host', 'port']) . $url;
} elseif (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
// URL doesn't start with either 'http://' or 'https://'. Add current scheme.
$wrapper->url = Uri::getInstance()->toString(['scheme']) . $url;
} else {
// URL starts with either 'http://' or 'https://'. Do not change it.
$wrapper->url = $url;
}
} else {
$wrapper->url = $url;
}

COM_WRAPPER_FIELD_ADD_DESC="By default, http:// will be added unless it detects http:// or https:// in the URL you provide. This allows you to switch off this functionality."
COM_WRAPPER_FIELD_ADD_LABEL="Auto Add"

If it is desired to allown internal urls then this PR #32342 needs to be reverted

avatar brianteeman brianteeman - open - 26 Apr 2023
avatar joomla-cms-bot joomla-cms-bot - change - 26 Apr 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Apr 2023
avatar brianteeman brianteeman - change - 26 Apr 2023
The description was changed
avatar brianteeman brianteeman - edited - 26 Apr 2023
avatar brianteeman brianteeman - change - 26 Apr 2023
The description was changed
avatar brianteeman brianteeman - edited - 26 Apr 2023
avatar richard67
richard67 - comment - 27 Apr 2023

Is PR #37547 related to this issue?

avatar brianteeman
brianteeman - comment - 27 Apr 2023

I guess so - although that PR doesn't completely fix the issue created by the original PR. It does make the idea of having a RLDQ a bit of a joke as it is now over 1 year since it was added.

avatar Hackwar Hackwar - change - 22 Aug 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Aug 2023
avatar brianteeman brianteeman - change - 1 Sep 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-09-01 14:00:36
Closed_By brianteeman
avatar brianteeman brianteeman - close - 1 Sep 2023
avatar brianteeman
brianteeman - comment - 1 Sep 2023

closing as a duplicate

Add a Comment

Login with GitHub to post a comment