Issue Bug Closed

#82847extbase model object validation does not care for overwritten classes

Michael Grundkötter 10/24/17, 12:20 updated 04/11/25, 13:55

Description

When adding features to an exisiting extension by overwriting e.g. model classes via

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['Mittwald\Typo3Forum\Domain\Model\Forum\Post'] = array(
    'className' => 'xyz\xyz\Domain\Model\Forum\Post'
);

the ValidatorResolver / ReflectionService does obviously not take the overwritten class as base for the reflection but the original one which is given in the original controller code as annotation and class hint like here:

    /**
     * Creates a new post.
     *
     * @param Topic $topic The topic in which the new post is to be created.
     * @param Post $post The new post.
     * @param array $attachments File attachments for the post.
     *
     * @validate $post \Mittwald\Typo3Forum\Domain\Validator\Forum\PostValidator
     * @validate $attachments \Mittwald\Typo3Forum\Domain\Validator\Forum\AttachmentPlainValidator
     */

    public function createAction(Topic $topic, Post $post, array $attachments = []) {

Thus, all the @validate annotations in the new class as well as the model class validators in Classes/Domain/Validator directory are ignored. Right now, this forces the developer to also overwrite the controller classes and change the type hints to the original model class which is unnecessary work, as extbase already “knows” about the new child classes when the ObjectManager is used to instantiate the original model class.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.