New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File attributes using Vich\UploaderBundle\Entity\File embeddable no longer become persisted with upgrade of doctrine/orm v2.7.2 => v2.7.3 #1139
Comments
Can you try to update only VichUploaderBundle and see what happens? |
Yup... doing
... works like a charm. |
Hmmm... doing the
... also works like a charm. |
Even after updating api-platform with +----------------------------------+---------+---------+-------------------------------------------------------------------------------+ +------------------------+---------+---------+--------------------------------------------------------------------+ Looks like the trouble might be caused by any "subsequent" dependency updated when using |
O.k... when it comes to
|
Suspect found... doctrine/orm v2.7.3... but why? Maybe somthing for the |
Maybe this PR? doctrine/orm#8138 |
Hmmmm... worth to try out/check... thanks a lot @garak |
O.k... seems to be my fault... or an inattention. As stated in the embeddable tutorial a basic Before: <?php
namespace App\Entity;
use App\Entity\Interfaces\EmbeddedFileInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Vich\UploaderBundle\Entity\File;
/**
* Class File
*
* @package App\Entity
*
* @ORM\Embeddable
*/
class EmbeddedFile extends File implements EmbeddedFileInterface
{
/**
* The entity id
*
* @var int|string|null
*/
private $id;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $name;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $originalName;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $mimeType;
/**
* @var int
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $size;
/**
* @var array
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $dimensions;
/**
* @var string|null
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*/
protected $url;
/**
* @return int|string|null
*/
public function getId()
{
return $this->id;
}
/**
* @param int|string|null $id
*/
public function setId($id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
public function getUrl(): ?string
{
return $this->url;
}
/**
* @param string|null $url
*/
public function setUrl(?string $url): void
{
$this->url = $url;
}
} After: <?php
namespace App\Entity;
use App\Entity\Interfaces\EmbeddedFileInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Vich\UploaderBundle\Entity\File;
/**
* Class File
*
* @package App\Entity
*
* @ORM\Embeddable
*/
class EmbeddedFile extends File implements EmbeddedFileInterface
{
/**
* The entity id
*
* @var int|string|null
*/
private $id;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(name="name", nullable=true)
*/
protected $name;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(name="original_name", nullable=true)
*/
protected $originalName;
/**
* @var string
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(name="mime_type", nullable=true)
*/
protected $mimeType;
/**
* @var int
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(name="size", type="integer", nullable=true)
*/
protected $size;
/**
* @var array
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(name="dimensions", type="simple_array", nullable=true)
*/
protected $dimensions;
/**
* @var string|null
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*
* @Groups({"idd_read", "idd_write", "document_read", "document_write", "message_document_read", "message_document_write", "message_read"})
*
* @ORM\Column(type="string")
*/
protected $url;
/**
* @return int|string|null
*/
public function getId()
{
return $this->id;
}
/**
* @param int|string|null $id
*/
public function setId($id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
public function getUrl(): ?string
{
return $this->url;
}
/**
* @param string|null $url
*/
public function setUrl(?string $url): void
{
$this->url = $url;
}
} |
Bug Report
Summary
Since an upgrade of of Symfony v4.4.7 -> v4.4.10 and API-Platform v2.5.5 -> v2.5.6, file attributes using Vich\UploaderBundle\Entity\File embeddable (fileName, fileOriginalName, fileMimeType) no longer become persisted.
Current behavior
After uploading using api-platform POST endpoint (with custom controller, see https://api-platform.com/docs/core/file-upload/#handling-file-upload), the file info values are NULL:
How to reproduce
composer.json:
Package update info:
Entity:
Controller:
Expected behavior
File info fields become filled correctly after/on upload
The text was updated successfully, but these errors were encountered: