Bug #38184

PersistenceManager chokes on empty uploads

Added by Bastian Waidelich about 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Must have
Category:
Property
Start date:
2012-06-19
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

Given following setup:

Domain/Model/SomeObject.php
/**
 * @FLOW3\Entity
 */
class SomeObject {

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection<\TYPO3\FLOW3\Resource\Resource>
     * @ORM\ManyToMany
     */
    protected $resources;

    // ...

}


Template.html
<f:form method="post" action="create" object="{newObject}" objectName="newObject" enctype="multipart/form-data">
    <f:form.upload property="resources.0" />
    <f:form.upload property="resources.1" />
    <f:form.submit value="Create"/>
</f:form>

If you submit the form, following exception is thrown:

#1337934455: Could not add object of type "MyPackage\Domain\Model\SomeObject" (in PersistenceManager:264)
Warning: spl_object_hash() expects parameter 1 to be object, null given in Packages/Framework/Doctrine.ORM/Classes/UnitOfWork.php line 1509

A similar problem occurs when adding an intermediate object like "File" as OneToMany relation which contains a relation to one resource:

Domain/Model/SomeObject.php
/**
 * @FLOW3\Entity
 */
class SomeObject {

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection<\TYPO3\FLOW3\Resource\Resource>
     * @ORM\OneToMany(mappedBy="someObject",cascade={"all"})
     */
    protected $files;

    // ...

}


Template.html
<f:form method="post" action="create" object="{newObject}" objectName="newObject" enctype="multipart/form-data">
    <f:form.upload property="files.0.originalResource" />
    <f:form.upload property="files.1.originalResource" />
    <f:form.submit value="Create"/>
</f:form>

In that case the exception is thrown while property mapping already:

#1297759968: Exception while property mapping for target type "MyPackage\Domain\Model\SomeObject", at property path "files.0": Catchable Fatal Error: Argument 1 passed to MyPackage\Domain\Model\File::setOriginalResource() must be an instance of TYPO3\FLOW3\Resource\Resource, null given, called in Packages/Framework/TYPO3.FLOW3/Classes/Reflection\ObjectAccess.php on line 182

So, I'm not sure if that's a problem of the property mapper or the persistence actually. But this was not present before and is a blocker IMO

#1

Updated by Bastian Waidelich about 9 years ago

Update: This is most probably a regression introduced with https://review.typo3.org/#/c/11709/1

#2

Updated by Bastian Waidelich about 9 years ago

  • Category changed from Persistence to Property
#3

Updated by Karsten Dambekalns about 9 years ago

  • Assignee set to Bastian Waidelich
#4

Updated by Karsten Dambekalns about 9 years ago

  • Status changed from New to Accepted
#5

Updated by Gerrit Code Review about 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12216

#6

Updated by Gerrit Code Review about 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12216

#7

Updated by Bastian Waidelich about 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#8

Updated by Gerrit Code Review about 9 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/12228

#9

Updated by Bastian Waidelich about 9 years ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF