Bug #82499

displayCond - Problem with multiple conditions

Added by Stephan Bauer almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-09-17
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

This displayCond does not work in 8.7.6 but it works in 7.6:

            'displayCond' => [
                'AND' => [
                    'OR' => [
                        'FIELD:protocol:=:0',
                        'FIELD:protocol:=:2'
                    ],
                    'OR' => [
                        'FIELD:type:=:0',
                        'FIELD:type:=:1'
                    ]
                ]
            ],

History

#1 Updated by Christian Kuhn almost 2 years ago

Do you receive an exception that the syntax is not correct? Could you have a look at the EvaluateDisplayCondition.php file and see what happens? Also, EvaluateDisplayConditionsTest.php, especially method matchConditionStrings() with its data providers in conditionStringDataProvider() does various AND / OR checks. Would you like to have a look at what exactly is going on in this case?

#2 Updated by Christian Kuhn almost 2 years ago

Note: The display condition parser has been rewritten with v8. It is more strict and throws exceptions on syntax errors.

#3 Updated by Stephan Bauer almost 2 years ago

Sorry I forgot this:

#1481464101: With multiple conditions combined by "AND", there must be at least two sub conditions (More information)

RuntimeException thrown in file
/xxx/typo3_src-8.7.6/typo3/sysext/backend/Classes/Form/FormDataProvider/EvaluateDisplayConditions.php in line 213.

This example from the documentation works (https://docs.typo3.org/typo3cms/TCAReference/Columns/ColumnsDisplayCond.html)

'displayCond' => [
    'AND' => [
        'FIELD:sys_language_uid:<=:0',
        'OR' => [
            'FIELD:CType:=:text',
            'FIELD:spaceBefore:>:0'
        ]
    ]
];

#4 Updated by Stephan Bauer almost 2 years ago

Hello Chrisitan,
unfortunatelly there is no test in EvaluateDisplayConditionsTest.php for my case.

#5 Updated by Morton Jonuschat almost 2 years ago

I am amazed if this actually worked (and did what you expected) in TYPO3 7.6 given that PHP is the one to screw you. You can't have two identical text keys in an array, the latter one will replace the former one. The difference now is that the evaluation detects that there's a problem while it was silently "failing" (or doing unexpected things) in previous versions:

$condTest = [
    'displayCond' => [
        'AND' => [
            'OR' => [
                'FIELD:protocol:=:0',
                'FIELD:protocol:=:2'
            ],
            'OR' => [
                'FIELD:type:=:0',
                'FIELD:type:=:1'
            ]
        ]
    ]
];
var_dump($condTest);
array(1) {
  ["displayCond"]=>
  array(1) {
    ["AND"]=>
    array(1) {
      ["OR"]=>
      array(2) {
        [0]=>
        string(14) "FIELD:type:=:0" 
        [1]=>
        string(14) "FIELD:type:=:1" 
      }
    }
  }
}

#6 Updated by Mona Muzaffar almost 2 years ago

  • Status changed from New to Needs Feedback

#7 Updated by Riccardo De Contardi over 1 year ago

  • Status changed from Needs Feedback to Closed

Considering the latest comment from Morton Jonuschat, I think that it should be safe to close this one; if it worked before, it was because the code silently failed or was behaving in a wrong way (so it worked fortuitously).

Moreover, there has been no activity on this issue since a while (>90 days).

If you think that this is the wrong decision , please reopen it or open a new issue with a reference to this one with an explanation of your point of view. Thank you and sorry for the late answer.

Also available in: Atom PDF