Unit/System Tests bug PR-6.2-dev Pending

User tests: Successful: Unsuccessful:

avatar bhuvan-somisetty
bhuvan-somisetty
25 Sep 2026

Pull Request resolves #48500.

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

In Joomla's URL handling for forms (UrlField), form validation (UrlRule), and form filtering (UrlFilter):

  1. UrlField::getLayoutData() directly evaluated $this->element['relative'] as a SimpleXMLElement object. In PHP, any non-empty SimpleXMLElement object evaluates to true in a boolean context, causing relative="false" to render as <input type="text"> instead of <input type="url">. Additionally, UrlField lacked a relative property, property getters/setters (__get / __set), and XML attribute parsing in setup().
  2. UrlRule::test() evaluated !$element['relative'] directly as a SimpleXMLElement object, causing !$element['relative'] to evaluate to false when relative="false". This allowed scheme-less relative paths (such as /my-path) to pass validation when relative URLs were explicitly disallowed.
  3. UrlFilter::filter() evaluated !$element['relative'] and $element['relative'] directly as a SimpleXMLElement object, causing relative="false" to be treated as an internal relative URL and prepending the site root path instead of prepending the default external protocol (http://).

This PR:

  1. Adds protected $relative = false;, __get('relative'), __set('relative'), and setup() to UrlField, and uses $this->relative in getLayoutData().
  2. Properly casts and evaluates the relative attribute in UrlRule::test() and UrlFilter::filter().
  3. Adds comprehensive unit tests in UrlFieldTest.php, UrlFilterTest.php, and updates UrlRuleTest.php.

Testing Instructions

1. Automated Tests

Run PHPUnit tests:

libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Form/Field/UrlFieldTest.php
libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Form/Rule/UrlRuleTest.php
libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Form/Filter/UrlFilterTest.php

2. Manual Test via Form Field

  1. Define a form XML with type="url" and relative="false":
<field
    name="my_url"
    type="url"
    label="External URL"
    relative="false"
    validate="url"
    filter="url"
/>
  1. Render the field via $form->getInput('my_url').
  2. Validate a relative value '/test-path' via $form->validate(['my_url' => '/test-path']).
  3. Filter a scheme-less value 'example.com' via the form filter.

Actual result BEFORE applying this Pull Request

  • UrlField renders <input type="text"> (instead of <input type="url">) when relative="false".
  • UrlRule accepts '/test-path' as valid when relative="false".
  • UrlFilter prepends the site root path instead of http:// when relative="false".

Expected result AFTER applying this Pull Request

  • UrlField renders <input type="url"> when relative="false".
  • UrlRule rejects '/test-path' as invalid when relative="false".
  • UrlFilter prepends http:// when relative="false".

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

Signed-off-by: bhuvan-somisetty somisettybhuvan5@gmail.com

avatar bhuvan-somisetty bhuvan-somisetty - open - 25 Sep 2026
avatar bhuvan-somisetty bhuvan-somisetty - change - 25 Sep 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Sep 2026
Category ⇒ Libraries Unit Tests
avatar bhuvan-somisetty bhuvan-somisetty - change - 25 Sep 2026
Labels Added: Unit/System Tests PR-5.4-dev
avatar HLeithner
HLeithner - comment - 5 Nov 2026

This pull request has been automatically rebased to 6.2-dev. Joomla! 5.4 is now in security only mode.

avatar richard67 richard67 - change - 6 Nov 2026
Title
…
[5.4] Fix relative attribute boolean evaluation in UrlField, UrlRule, and UrlFilter
[6.2] Fix relative attribute boolean evaluation in UrlField, UrlRule, and UrlFilter
avatar richard67 richard67 - edited - 6 Nov 2026
avatar richard67 richard67 - change - 6 Nov 2026
Labels Added: bug PR-6.2-dev
Removed: PR-5.4-dev
avatar richard67
richard67 - comment - 6 Nov 2026

@bhuvan-somisetty Could you check and fix the code style errors reported here? https://github.com/joomla/joomla-cms/actions/runs/42210072233/job/127866653401?pr=48502

They are reported now after the rebase of this PR to the 6.2-dev branch because on that branch we have a newer version and better configuration for the code style checker that we have on the 54-dev branch which this PR was targeting before the rebase.

Thanks in advance.

avatar bhuvan-somisetty
bhuvan-somisetty - comment - 6 Nov 2026

Fixed the code style issues. Thanks!

avatar richard67
richard67 - comment - 6 Nov 2026

Fixed the code style issues. Thanks!

@bhuvan-somisetty Thanks. Now the unit tests are failing. I think it is the same reason as it was for PR #48512 : We use a newer version of phpunit in the 6.4-dev branch. You could maybe check the last commit in the mentioned PR to see how it can be fixed. I think it was the same error there as it is here.

avatar bhuvan-somisetty
bhuvan-somisetty - comment - 6 Nov 2026

Updated the test data providers for PHPUnit 12. Thanks!

Add a Comment

Login with GitHub to post a comment