bug PR-6.2-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.

avatar exlemor exlemor - test_item - 11 Sep 2026 - Tested successfully
avatar exlemor
exlemor - comment - 11 Sep 2026

I have tested this item ✅ successfully on 532bd1b

Hi @LadySolveig, thank you for the PR ! I was able to test it successfully based on your testing instructions. :)


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

avatar exlemor
exlemor - comment - 11 Sep 2026

I have tested this item ✅ successfully on 532bd1b

Hi @LadySolveig, thank you for the PR ! I was able to test it successfully based on your testing instructions. :)


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

avatar LadySolveig
LadySolveig - comment - 11 Sep 2026

Thank you both! First blocker for #48300 hopefully resolved 🚀 💚

avatar richard67 richard67 - change - 11 Sep 2026
Status Pending ⇒ Ready to Commit
avatar richard67
richard67 - comment - 11 Sep 2026

RTC


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

avatar richard67
richard67 - comment - 11 Sep 2026

RTC


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

avatar muhme muhme - change - 12 Sep 2026
Labels Added: RTC
avatar muhme muhme - test_item - 12 Sep 2026 - Tested unsuccessfully
avatar muhme
muhme - comment - 12 Sep 2026

I have tested this item 🔴 unsuccessfully on cefbbb0

First try to test before merge with JBT and starting with PostgreSQL

  • Temporarily edited administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described
  • Before PR
    • Seen error 22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration
  • Applied PR with Patch Tester, tested first with PostgreSQL and second with MariaDB
    • ✅ Saving new article w/o any Images and Links configuration is working without error
    • Saving the article with 'Link A Text' input:
      • ✅ Valid article ID is working
      • ✅ Empty field is working
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
        • ❌ in '22P02, 7, ERROR: invalid input syntax for type integer: "a" LINE 3: WHERE "id" = 'a' ^' with PostgreSQL
        • ✅ in red error 'Invalid field: Link A Text' with MariaDB
    • Test 4 with required field:
      • ✅ Valid article ID is working
      • ✅ Empty field results in red error 'Field required: Link A Text'
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
avatar muhme
muhme - comment - 12 Sep 2026

I have tested this item 🔴 unsuccessfully on cefbbb0

First try to test before merge with JBT and starting with PostgreSQL

  • Temporarily edited administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described
  • Before PR
    • Seen error 22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration
  • Applied PR with Patch Tester, tested first with PostgreSQL and second with MariaDB
    • ✅ Saving new article w/o any Images and Links configuration is working without error
    • Saving the article with 'Link A Text' input:
      • ✅ Valid article ID is working
      • ✅ Empty field is working
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
        • ❌ in '22P02, 7, ERROR: invalid input syntax for type integer: "a" LINE 3: WHERE "id" = 'a' ^' with PostgreSQL
        • ✅ in red error 'Invalid field: Link A Text' with MariaDB
    • Test 4 with required field:
      • ✅ Valid article ID is working
      • ✅ Empty field results in red error 'Field required: Link A Text'
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
avatar muhme
muhme - comment - 12 Sep 2026

I have tested this item 🔴 unsuccessfully on cefbbb0

First try to test before merge with JBT and starting with PostgreSQL

  • Temporarily edited administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described
  • Before PR
    • Seen error 22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration
  • Applied PR with Patch Tester, tested first with PostgreSQL and second with MariaDB
    • ✅ Saving new article w/o any Images and Links configuration is working without error
    • Saving the article with 'Link A Text' input:
      • ✅ Valid article ID is working
      • ✅ Empty field is working
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
        • ❌ in '22P02, 7, ERROR: invalid input syntax for type integer: "a" LINE 3: WHERE "id" = 'a' ^' with PostgreSQL
        • ✅ in red error 'Invalid field: Link A Text' with MariaDB
    • Test 4 with required field:
      • ✅ Valid article ID is working
      • ✅ Empty field results in red error 'Field required: Link A Text'
      • ✅ Invalid article ID results in red error 'Invalid field: Link A Text'
      • Using a letter 'a' results
        • ❌ in '22P02, 7, ERROR: invalid input syntax for type integer: "a" LINE 3: WHERE "id" = 'a' ^' with PostgreSQL
        • ✅ in red error 'Invalid field: Link A Text' with MariaDB

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48314.
avatar muhme muhme - change - 12 Sep 2026
Status Ready to Commit ⇒ Pending
avatar muhme
muhme - comment - 12 Sep 2026

Set Pending due failed test


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

avatar muhme
muhme - comment - 12 Sep 2026

Set Pending due failed test


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

avatar LadySolveig LadySolveig - change - 17 Sep 2026
Labels Removed: RTC
avatar LadySolveig
LadySolveig - comment - 17 Sep 2026

Thanks @muhme, added an extra check. should now also work as expected for pg.

avatar muhme muhme - test_item - 18 Sep 2026 - Tested successfully
avatar muhme
muhme - comment - 18 Sep 2026

I have tested this item ✅ successfully on d7a52f4


Tested with JBT starting with PostgreSQL DBO and using port number

  • Temporarily edited administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described
  • Before PR
    • Seen error 22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration
  • Applied PR with Patch Tester, tested first with PostgreSQL
    • Saving new article w/o any Images and Links configuration is working without error
    • Saving the article with 'Link A Text' input:
      • Existing article ID is working
      • Empty field is working
      • Invalid article ID (0, non-existing article ID or letter) results in red error 'Invalid field: Link A Text'
    • Test 4 in setting required="true":
      • Existing article ID is working
      • Empty field results in red error 'Field required: Link A Text'
      • Invalid article ID (0, non-existing article ID or letter) results in red error 'Invalid field: Link A Text'
    • Repeated all the tests with MySQL DBO using Unix socket successfully
    • No unusual Joomla or PHP log messges

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

I have tested this item ✅ successfully on d7a52f4


Tested with JBT starting with PostgreSQL DBO and using port number

  • Temporarily edited administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described
  • Before PR
    • Seen error 22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration
  • Applied PR with Patch Tester, tested first with PostgreSQL
    • Saving new article w/o any Images and Links configuration is working without error
    • Saving the article with 'Link A Text' input:
      • Existing article ID is working
      • Empty field is working
      • Invalid article ID (0, non-existing article ID or letter) results in red error 'Invalid field: Link A Text'
    • Test 4 in setting required="true":
      • Existing article ID is working
      • Empty field results in red error 'Field required: Link A Text'
      • Invalid article ID (0, non-existing article ID or letter) results in red error 'Invalid field: Link A Text'
    • Repeated all the tests with MySQL DBO using Unix socket successfully
    • No unusual Joomla or PHP log messges

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48314.
avatar richard67 richard67 - change - 31 Oct 2026
Title
…
[5.4] Fix ExistsRule validation if field is not required
[6.2] Fix ExistsRule validation if field is not required
avatar richard67 richard67 - edited - 31 Oct 2026
avatar richard67
richard67 - comment - 31 Oct 2026

As 5.4 has reached end of bugfix support and is now in security only support mode, I've allowed myself to rebase this PR here to 6.2-dev, where bug fixes should be made now. This worked cleanly, so the previous human test is still valid, but also the unresolved review comment.

avatar LadySolveig
LadySolveig - comment - 31 Oct 2026

I'd be happy to make a change as soon as I know what's preferred. If the maintainers are okay with the alternative suggestion and want it implemented that way, just let me know.

avatar LadySolveig
LadySolveig - comment - 31 Oct 2026

Since it's a matter of personal preference and both work. I'd be happy to make a change as soon as I know what's preferred. If the maintainers are okay with the alternative suggestion and want it implemented that way, just let me know.

avatar richard67 richard67 - change - 31 Oct 2026
Labels Added: PR-6.2-dev
Removed: PR-5.4-dev
avatar richard67 richard67 - alter_testresult - 31 Oct 2026 - muhme: Tested successfully

Add a Comment

Login with GitHub to post a comment