bug PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar LadySolveig
LadySolveig
26 Aug 2026

Pull Request resolves # .

  • 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

Fix the validation logic in the ExistsRule form rule. The main change ensures that if a field is marked as required in the XML definition, empty values are not considered valid, while optional fields can accept empty values.

On Postgres this would lead to a real db error because the unpatched rule runs WHERE id = '' against an integer column.

See also reference in UserIdRule:

$required = ((string) $element['required'] === 'true' || (string) $element['required'] === 'required');
// If the value is empty, null or has the value 0 and the field is not required return true else return false
if (($value === '' || $value === null || (string) $value === '0')) {
return !$required;
}

The guard deliberately covers only '' and null as empty. ExistsRule is column-agnostic, exists_column may point at any column, and 0 could be a legitimate stored value (e. g. parent_id, access, level, featured, …).
Treating '0' as "empty" would make the rule silently skip validation for those columns.

Testing Instructions

This rule is not currently in use in the Core.

Setup
Temporarily edit administrator/components/com_content/forms/article.xml (~line 814) to point an ordinary text field at the rule:

<field
    name="urlatext"
    type="text"
    label="COM_CONTENT_FIELD_URLA_LINK_TEXT_LABEL"
    validate="exists"
    exists_table="#__content"
    exists_column="id"
 />

Go to Content → Articles, note an existing article's ID from the list, then open any article and switch to the Images and Links tab. The field is Link A Text.

# Enter in "Link A Text" Expected with patch Expected without patch
1 (leave empty) → Save Saves normally Invalid field: Link A Text ← the bug
2 An existing article ID, e.g. 1 → Save Saves normally Saves normally
3 999999 → Save Invalid field: Link A Text Invalid field: Link A Text
image

Test 1 is the fix. Ttests 2 and 3 confirm the rule still validates as before.

Test 4 - required fields still enforced
Add required="true" to the same field, enter a single space, and save.

<field
    name="urlatext"
    type="text"
    label="COM_CONTENT_FIELD_URLA_LINK_TEXT_LABEL"
    required="true"
    validate="exists"
    exists_table="#__content"
    exists_column="id"
 />

Expected: Invalid field: Link A Text in both cases. (Entering nothing at all hits Joomla's generic required check before the rule runs, so the space is what actually exercises the rule's required branch.)

Actual result BEFORE applying this Pull Request

Fields that are not required get a wrong validation result.

Expected result AFTER applying this Pull Request

Rule can be used with Postgres and works as expected for not required fields.

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

avatar LadySolveig LadySolveig - open - 26 Aug 2026
avatar LadySolveig LadySolveig - change - 26 Aug 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Aug 2026
Category Libraries
avatar LadySolveig LadySolveig - change - 26 Aug 2026
The description was changed
avatar LadySolveig LadySolveig - edited - 26 Aug 2026
avatar LadySolveig LadySolveig - change - 26 Aug 2026
Labels Added: bug PR-5.4-dev
avatar QuyTon QuyTon - test_item - 27 Aug 2026 - Tested successfully
avatar QuyTon
QuyTon - comment - 27 Aug 2026

I have tested this item ✅ successfully on 532bd1b

Thank you!


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

avatar QuyTon
QuyTon - comment - 27 Aug 2026

I have tested this item ✅ successfully on 532bd1b

Thank you!


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

Add a Comment

Login with GitHub to post a comment