Closed r-sede closed 3 years ago
The issue is that getPathname()
is called on
/**
* @return mixed
*/
public function getBinaryContent();
A check
if ($binaryContent instanceof File) {
seems needed.
got same error on sf 4.4
The issue is that
getPathname()
is called on/** * @return mixed */ public function getBinaryContent();
A check
if ($binaryContent instanceof File) {
seems needed.
I gave the solution
You need to change
try {
$image = $this->imagineAdapter->open($value->getBinaryContent()->getPathname());
} catch (\RuntimeException $e) {
// Do nothing. The parent validator will throw a violation error.
return;
}
to something like
try {
$binaryContent = $value->getBinaryContent();
if (!$binaryContent instanceof File) {
return;
}
$image = $this->imagineAdapter->open($binaryContent->getPathname());
} catch (\RuntimeException $e) {
// Do nothing. The parent validator will throw a violation error.
return;
}
If you want to make a PR @ibasaw
@VincentLanglet you 're absolutely right, this is working perfectly with your proposal. thank you for your quick answer.
I can't do a PR because i already fork this project, and i need to keep my old fork which is used in prod on many websites i manage.
Thank you for the confirmation.
I can't do a PR because i already fork this project, and i need to keep my old fork which is used in prod on many websites i manage.
Regardless your fork is being used in other projects, I think you could create a new branch from this remote without any impact:
git remote add upstream git@github.com:sonata-project/SonataMediaBundle.git
git fetch upstream
git checkout -b issue_1804 upstream/3.x
# apply and commit your changes
git push origin issue_1804
Run into the same issue this morning on Symfony 4.4 and Media Bundle 3.27
I still have exact this issue with Symfony 4.4.26 and Media Bundle 3.13 which were updated month ago. Was it really fixed ? It looks as not...
Media Bundle 3.13
You're so 2018
Environment
Sonata packages
Symfony packages
PHP version
Subject
I have one media context like:
when a try to choose a youtube media for my post it throw me a Exception
Call to a member function getPathname() on string
in vendor/sonata-project/media-bundle/src/Validator/Constraints/ImageUploadDimensionValidator.php line 72 if i replace:
by:
it works
Expected results
a youtube media
Actual results
an Exception on create