J3 Issue
avatar caru80
caru80
16 Jan 2019

Steps to reproduce the issue

  1. Add a custom field of type sql in com_fields with a query that delivers an actual result.
  2. Enter a default value that you know it exists in the result list.
  3. Hit save.

Expected result

The custom field get's stored.

Actual result

Error Message „COM_FIELDS_FIELD_INVALID_DEFAULT_VALUE” caused by method checkDefaultValue in FieldsModelField of com_fields.

System information (as much as possible)

Joomla! 3.9.2

Additional comments

FieldsModelField::checkDefaultValue runs into line 275 (as it is supposed to do)...:

$result = $rule->test(simplexml_import_dom($node->firstChild), $data['default_value']);

... and \Joomla\CMS\Form\Rule\OptionsRule->test() expects that \SimpleXMLElement $element has some options where the default value can (or not) be found in, in line 89:

return in_array((string) $value, $options);

But \SimpleXMLElement $element has no options (the result of the SQL Query). Thus it will allways fail.

avatar caru80 caru80 - open - 16 Jan 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Mar 2019
Status New Information Required
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Mar 2019

@HLeithner can you please comment?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Mar 2019

@HLeithner gently Reminder.

avatar franz-wohlkoenig franz-wohlkoenig - change - 28 Mar 2019
Category com_fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Apr 2019
Labels Added: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 4 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
[3.9] SQL Custom Field: default value is broken because it can't be validated
SQL Custom Field: default value is broken because it can't be validated
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar HLeithner
HLeithner - comment - 25 Apr 2019

if @caru80 would be so kind and write a PR we could test it and merge it

avatar ReLater
ReLater - comment - 25 Apr 2019

The reason is the same like in field itemlist. It extends FieldsListPlugin.

https://github.com/joomla/joomla-cms/blob/staging/plugins/fields/sql/sql.php#L19

Thus the validation runs through OptionsRule.php while saving without options. ==> always false

See #24643 . I've opened it just because the original issue #15173 is > 2 years old or so without any clarifying statements.

But before we start to write several prs like that and maybe open new security issues it would be nice if someone of the "com_fields experts" would issue a statement if that's the correct solution or if we need new BlablaRules.php or whatever.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Apr 2019

But before we start to write several prs like that and maybe open new security issues it would be nice if someone of the "com_fields experts" would issue a statement if that's the correct solution or if we need new BlablaRules.php or whatever.

@laoneo ?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 30 Apr 2019

Closed as having Pull Request #24755

avatar franz-wohlkoenig franz-wohlkoenig - change - 30 Apr 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-04-30 07:15:18
Closed_By franz-wohlkoenig
avatar franz-wohlkoenig franz-wohlkoenig - close - 30 Apr 2019

Add a Comment

Login with GitHub to post a comment