Bug #85932

Incorrect annotation for property "message" in class "Error".

Added by Krzysztof Napora about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-08-23
Due date:
% Done:

0%

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

Description

Try to create action like here :

    /**
     * @param \TYPO3\CMS\Extbase\Error\Result|null $validationErrors
     */
    public function listContactAction(\TYPO3\CMS\Extbase\Error\Result $validationErrors = null)
    {

    }

Now try to open frontend, error is :

Oops, an error occurred!
There is no @var annotation for property "message" in class "Error".

How I check problem is here web/typo3/sysext/extbase/Classes/Error/Result.php

Now we have

    /**
     * @var Error[]
     */
    protected $errors = [];

should be :

     /**
     * @var \TYPO3\CMS\Extbase\Error\Error[]
     */
    protected $errors = [];

Files

Selection_933.png (263 KB) Selection_933.png Patryk Ostrowski, 2018-08-27 10:16

Related issues

Related to TYPO3 Core - Bug #57856: @inject does not work relative to current namespaceClosed2014-04-12

Actions
Related to TYPO3.Flow - Bug #46008: Reflection should resolve relative namespacesResolvedSebastian Kurfuerst2013-03-04

Actions
#1

Updated by Krzysztof Napora about 3 years ago

  • Description updated (diff)
#2

Updated by Krzysztof Napora about 3 years ago

  • Description updated (diff)
#3

Updated by Krzysztof Napora about 3 years ago

  • Description updated (diff)
#4

Updated by Krzysztof Napora about 3 years ago

  • Description updated (diff)
#5

Updated by Gerrit Code Review about 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58043

#6

Updated by Markus Klein about 3 years ago

  • Status changed from Under Review to Needs Feedback
  • Target version deleted (8.7.19)

I don't get your example action? Why do you pass this error stuff in there?

#7

Updated by Patryk Ostrowski about 3 years ago

Error stuff is here because we don't need validation at the start of action. We validate object only in some case. In some other we save not valid object.

As example for better understanding i will show you this simple story:

  • User want to create new invoice address (address is another object with 30 fields)
  • We allow him to create it with 4 steps, 3 steps per 10 fields and on last, he get confirmation
  • OK, User enter on the step 1, he fill 3 fields after this he see field which is strange for him but this fields is required, so in this case he want to save his work. We allow him with special button.
  • after some time User return to edit his Address
  • he fill all required fields and click proceed button. Crap, he forget about one required field, he is very angry for this field and he closed browser. After some minutes he return to form and he see, his form is saved! With proceed action we always save object and after save we validate it to check if he can go to another step.

Ok, i finish this simple story in this moment, because now, you should know why we want to use

TYPO3\CMS\Extbase\Error\Result

Maybe fix solution for this problem is not correct but this should be fixed. The problem is in

typo3/cms/typo3/sysext/extbase/Classes/Reflection/ReflectionService.php::getPropertyTagsValues

ReflectionService::getPropertyTagsValues should return class Property tag valuse but in case of Error return empty array (see screenshot why empty array is returned)

Maybe fix should be for reflection service? Because error is thrown by:

$classPropertyTagsValues = $this->reflectionService->getPropertyTagsValues($targetClassName, $classPropertyName);
if (!isset($classPropertyTagsValues['var'])) {
   throw new \InvalidArgumentException(sprintf('There is no @var annotation for property "%s" in class "%s".', $classPropertyName, $targetClassName), 1363778104);
}

from class
typo3/cms/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php::276

#8

Updated by Markus Klein about 3 years ago

So you actually still want to pass in the object but you would want to add a @ignorevalidation $address flag in phpdoc to the method to disable validation, right?

#9

Updated by Krzysztof Napora about 3 years ago

Yes

#10

Updated by Patryk Ostrowski about 3 years ago

  • Related to Bug #57856: @inject does not work relative to current namespace added
#11

Updated by Patryk Ostrowski about 3 years ago

  • Related to Bug #46008: Reflection should resolve relative namespaces added
#12

Updated by Patryk Ostrowski about 3 years ago

I added some related issue. Maybe its can help with problem identification. Especially interesting is task from typo3 flow, its looks like possible solution for this problem: https://forge.typo3.org/issues/46008 and https://forge.typo3.org/issues/57034

#13

Updated by Markus Klein about 3 years ago

The problem is not the missing namespace resolvement (which is known and unfortunate, but no blocker), but obviously your wrong design of the action. An action takes models or other GET/POST parameters as method arguments, not a validation (or what so ever).

#14

Updated by Patryk Ostrowski about 3 years ago

If the problem is known and reported i think we can close this task. Solution for our problem is to not use:

* @param \TYPO3\CMS\Extbase\Error\Result|null $validationErrors

Thanks Markus for help.

#15

Updated by Markus Klein about 3 years ago

  • Status changed from Needs Feedback to Closed

Also available in: Atom PDF