magento2: Magento 2.4.4 - Static content deploy - Deprecated Error - null value
I’ve made fresh install of Magento 2.4.4 PHP version is 8.1.4
I’ve created two child themes (one of luma & one of blank)
I’ve installed PL language pack using command:
composer require mageplaza/magento-2-polish-language-pack:dev-master mageplaza/module-smtp
Next step (after installing language pack) should be:
php bin/magento setup:static-content:deploy pl_PL -f
Following command causes an error:
Error happened during deploy process: Deprecated Functionality: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /workspaces/magento-demo/vendor/magento/framework/View/Asset/PreProcessor/FileNameResolver.php on line 44
Line 44 of FileNameResolver.php looks like this:
I’ve found somethinf like this: [PHP 8.1: Passing null
to non-nullable internal function parameters is deprecated]
How can I fix this error?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 15 (1 by maintainers)
I found the origin of the problem. The problem was we should put the logo.png image file in our theme: app/design/frontend/[our_vendor]/[theme]/web/images/logo.png
Quick fix in file:
magento/module-deploy/Collector/Collector.php
Change line 95 from:
if ($file->getModule() && !$this->moduleManager->isEnabled($file->getModule())) {
to:if ($file->getModule() && !$this->moduleManager->isEnabled($file->getModule()) || is_null($file->getFileName())) {
Patch here for you:
I have the same compilation error with the ‘empty’ (virtual) theme
https://github.com/magento/magento2/blob/2.4.4/app/code/Magento/Deploy/Collector/Collector.php#L96
$file->getFileName() is null
https://github.com/magento/magento2/blob/2.4.4/app/code/Magento/Deploy/Source/Themes.php#L52-L63
because in accumulateThemeStaticFiles system add nulled filename if any static files weren’t found
https://github.com/magento/magento2/blob/2.4.4/lib/internal/Magento/Framework/App/Utility/Files.php#L955
I had the same issue with my custom backend theme. I deleted an override on a css. So had a custom theme with no overrides. But funny thing is that it doesn’t matter which file you add to your custom theme. After i’ve added app/design/adminhtml/[our_vendor]/[theme]/web/test.txt it worked.
setup:static-content:deploy
did not brake. Apperently the magento/module-deploy/Collector/Collector.php need any file.Thank You! That worked for me, the problem is gone 😃