Problem/Motivation
The following error appears after updating composer packages:
PHP Fatal error: Uncaught TypeError: Argument 3 passed to FFMpeg\FFProbe::create() must be an instance of Psr\Cache\CacheItemPoolInterface or null, instance of Drupal\php_ffmpeg\PHPFFMpegCache given, called in /var/www/html/web/modules/contrib/php_ffmpeg/src/PHPFFMpegFactory.php on line 76 and defined in /var/www/html/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFProbe.php:220
Stack trace:
#0 /var/www/html/web/modules/contrib/php_ffmpeg/src/PHPFFMpegFactory.php(76): FFMpeg\FFProbe::create(Array, Object(Drupal\Core\Logger\LoggerChannel), Object(Drupal\php_ffmpeg\PHPFFMpegCache))
#1 /var/www/html/web/modules/contrib/php_ffmpeg/src/PHPFFMpegFactory.php(63): Drupal\php_ffmpeg\PHPFFMpegFactory->getFFMpegProbe()
#2 [internal function]: Drupal\php_ffmpeg\PHPFFMpegFactory->getFFMpeg()
#3 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(255): call_user_func_array(Array, Array)
#4 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(173): Drupal\Component\DependencyInjection\Container-> in /var/www/html/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFProbe.php on line 220This seems to be related to a change in the php-ffmpeg/php-ffmpeg package introduced in https://github.com/PHP-FFMpeg/PHP-FFMpeg/commit/7eace8852ac40ff2c38d90d8... which is part of the latest release.
Steps to reproduce
Update composer packages with "composer update"
Proposed resolution
Either lock the version of the dependency to v0.18.0, or alter PHPFFMpegCache to implement Psr\Cache\CacheItemPoolInterface.
Remaining tasks
- choose a resolution
- implement it
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | interdiff_9_19.txt | 1.35 KB | aporie |
| #19 | symfony-drupal-cache-adapter-3256578-19.patch | 7.71 KB | aporie |
| #18 | interdiff_9_18.txt | 1.23 KB | aporie |
| #18 | symfony-drupal-cache-adapter-3256578-18.patch | 7.7 KB | aporie |
| #9 | symfony-drupal-cache-adapter.patch | 8.2 KB | volman |
Issue fork php_ffmpeg-3256578
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #6
retiredpro commentedlocked the dependency to v0.18.0 as a quick fix.
Comment #7
hatuhay commentedComment #8
arturopanettaI started studying the problem, not having much time available, I put some notes for the modification of
PHPFFMpegCache. I hope these notes will save me time in the future or for other people who want to take an interest in the solution.The break is caused at line 76 of
getFFMpegProbe()https://git.drupalcode.org/project/php-ffmpeg/-/blob/8.x-1.x/src/PHPFFMp...
$this->cache(optional) is an instance of\Doctrine\Common\Cache\Cacheinstead php-ffmpeg v0.19 accepts the typePsr\Cache\CacheItemPoolInterface.$this->cacheis instantiated in the constructor through a dependency injection.$this->cacheis injected into thePHPFFMpegFactoryconstructor from a yml services configuration.https://git.drupalcode.org/project/php-ffmpeg/-/blob/8.x-1.x/src/PHPFFMp...
After changing the "PHPFFMpegCache" class, the cache type must be changed in the PHPFFMpegFactory constructor. The challenging thing is to implement the cache with
Psr\Cache\CacheItemPoolInterface.Docs: https://api.drupal.org/api/drupal/vendor%21psr%21cache%21src%21CacheItem... (Great documentation page!)
For now I'll stop here, continue as soon as I have some time.
Comment #9
volmanReworked
PHPFFMpegCacheand updated tests. Dropped Doctrine Cache and used Symfony Cache instead. Now we are compatible with php-ffmpeg >=0.19.Comment #10
vadim s. sabinich commented@volman
I've tried to apply your patch, but after enabling the module I've been found error:
Class "Symfony\\Component\\Cache\\Adapter\\AbstractAdapter" not found in /sites/www/modules/php_ffmpeg/src/PHPFFMpegCache.php on line 11 #0 /sites/www/vendor/composer/ClassLoader.php(571):Comment #11
volman@vadim
The class you mention is a part of Symfony Cache which is a dependency of php-ffmpeg/php-ffmpeg since v0.19.
Until #9 is ported to upstream module, you have to manually add required php-ffmpeg version to your project:
composer require php-ffmpeg/php-ffmpeg ^0.19Hope this helps.
Comment #12
vadim s. sabinich commentedI've been deployed blank test environment with composer
and after that, then I enabled a local_video_thumbnails (and php_ffmpeg by dependence) and saw error:
php 8.0.18
If you have interest for debug this issue, I'll ready grant access for you.
Comment #13
volman@vadim It seems you have current (unpatched) version of
drupal/php_ffmpeg.After installing
drupal/php_ffmpegwith composer you have to patch it with the file from #9. You can do it manually or you can use composer too.Share your complete composer.json or you can grant me access to your test environment if you still have trouble.
Comment #14
vadim s. sabinich commentedThat's really true! I forgot to apply your patch. After these I confirm: Its work!
Comment #15
schoenef commentedThx for #9, it works well :)
Comment #16
mhavelant commentedHi, everyone!
I received a mail from @volman that #9 has been tested by many people by now and could be pushed to the codebase, closing the issue.
I'm no longer a Drupal dev, and don't really have the time to apply and push the patch, so if someone would like to take over the maintainer status of the project, feel free to reach out to me. Or, if someone has time to create a MR from the patch, I could probably click it into the codebase from the UI, too.
Comment #17
mhavelant commentedI assigned @szato as a maintainer, hopefully he'll have time to take a look at this soon!
Comment #18
aporieThanks a lot Volman for the patch.
With the last version of Drupal 10 I was getting errors from functions not being compatible with Symfony\Component\Cache\Adapter\AbstractAdapter interface.
Attached is a patch to make them compatible. Some might need a few tweaks to respect their return types though, but haven't got time to get there yet.
Comment #19
aporieOk, so as expected, patch #18 is useless because functions don't return their expected return type.
I investigated, and I wonder if Drupal caches are compatible with function definitions in symfony.
If I check in vendor/symfony/cache/Traits/AbstractAdapterTrait.php::doSave(), the function should return @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not.
Though Drupal backend cache throw errors on failure.
I ended up returning TRUE for each function. At least it does work now.
Comment #20
bhanu951 commentedAnyone got any suggestion on how to fix this issue. Seems Neither the patch from #9 nor #19 can resolve this issue.
Comment #21
bhanu951 commented#9 fixes the issue but only with "php-ffmpeg/php-ffmpeg" version "0.19.0"
Comment #22
aporieYou should check the version of FFmpeg installed on your server. It's possible you have an incompatibility between the PHP library and your server version.
ffmpeg -versionComment #23
ivnishPatch #19 looks good
Comment #27
berdirTotally forgot I was a maintainer here. Looking into this now and starting a new MR with the changes.
To be able to test this, I merged in the D10 rector patch from #3297867: Automated Drupal 10 compatibility fixes and also enabled Gitlab CI.
I'm not sure why we allow 0.19 *and* 1.1 at this point, #21 mentions this only works with 0.19, will try to do some real tests now to see how this works.
Comment #29
berdirDid some basic tests for our use case, that works with version 1.1. Keeping the version string as it is for now.