User tests: Successful: Unsuccessful:
Pull Request resolves # .
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:
joomla-cms/libraries/src/Form/Rule/UserIdRule.php
Lines 50 to 55 in 993ba67
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.
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 |
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.)
Fields that are not required get a wrong validation result.
Rule can be used with Postgres and works as expected for not required fields.
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
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
| Labels |
Added:
bug
PR-5.4-dev
|
||
I have tested this item ✅ successfully on 532bd1b
Thank you!
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. :)
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. :)
| Status | Pending | ⇒ | Ready to Commit |
RTC
RTC
| Labels |
Added:
RTC
|
||
I have tested this item 🔴 unsuccessfully on cefbbb0
First try to test before merge with JBT and starting with PostgreSQL
administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configurationI have tested this item 🔴 unsuccessfully on cefbbb0
First try to test before merge with JBT and starting with PostgreSQL
administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configurationI have tested this item 🔴 unsuccessfully on cefbbb0
First try to test before merge with JBT and starting with PostgreSQL
administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configuration| Status | Ready to Commit | ⇒ | Pending |
Set Pending due failed test
Set Pending due failed test
| Labels |
Removed:
RTC
|
||
I have tested this item ✅ successfully on d7a52f4
Tested with JBT starting with PostgreSQL DBO and using port number
administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configurationrequired="true":
I have tested this item ✅ successfully on d7a52f4
Tested with JBT starting with PostgreSQL DBO and using port number
administrator/components/com_content/forms/article.xml to add validate for 'Link A' as described22P02, 7, ERROR: invalid input syntax for type integer: "" LINE 3: WHERE "id" = '' ^ in saving a new article w/o any Images and Links configurationrequired="true":
| Title |
|
||||||
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.
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.
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.
| Labels |
Added:
PR-6.2-dev
Removed: PR-5.4-dev |
||
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.