cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

Hi,

I installed magento 2.4.4, and using php8.1, and now I have some problems. I don't know how to fix it.

Something went wrong while deploying static content. See the error log for details.
Disabling maintenance mode
Command returned non-zero exit code:
`/usr/bin/php8.1 -f /var/www/html/bin/magento setup:static-content:deploy -f en_US`
root@magento2opensource162onubuntu2004lts-s-4vcpu-8gb-amd-sfo3-01:/var/www/html# php bin/magento setup:static-content:deploy

Deploy using quick strategy
Error happened during deploy process: Deprecated Functionality: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /var/www/html/vendor/magento/framework/View/Asset/PreProcessor/FileNameResolver.php on line 44

Execution time: 0.14391589164734

Screenshot_1.pngScreenshot_2.png

10 REPLIES 10

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

Hi @Modest,

Greetings!

There is an issue with PHP 8.1. So you need to update the composer root update plugin. 

composer require magento/composer-root-update-plugin ~2.0 --no-update. 

Hope this will help you!

 

If solved? Click KUDOS and accept it as the solution.

Thank you Smiley Happy

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

I tried it but it didn't work

 

/var/www/html# php bin/magento/composer-root-update-plugin ~2.0 --no-update
Could not open input file: bin/magento/composer-root-update-plugin

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

Hey man, 

 

These deprecated errors are really annoying but equally, easy enough to fix.
So in this case it's saying you cannot pass null as the 1st parameter to the pathinfo() method. To fix this, you just need to return an empty string as the parameter if it's null, for example:

 

$path = null;
pathinfo($path);

echo $path; // this will trigger the deprecated error as  a null value has been passed

 

update the code to:

$path = null;
pathinfo($path ?? ""); // the ?? will take $path value and will convert it to an empty string if it's null

echo $path;

 


The error will now be gone as this satisfies the new rules for PHP 8.1


Hope this helps!

 

Cheers

 

Ash

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

I had the same view you posted with the CSS and JS files not loading by resetting the top-level  .htaccess file to match the official GitHub repo, which only contains

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

 

before updating the .htaccess filebefore updating the .htaccess file

after updating the .htaccess fileafter updating the .htaccess file

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

I have the same issue. And it is resolved based on the url https://www.thecoachsmb.com/solved-magento-2-4-4-deprecated-functionality-pathinfo-passing-null-to-p....

This is because my custom theme do not have the folder web/images or the folder is empty.

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

Hi

 

You need to replace the below code in the core Magento file for a quick fix.

FilePath: vendor/magento/framework/View/Asset/PreProcessor/FileNameResolver.php

Line No: 44

$extension = pathinfo($fileName, PATHINFO_EXTENSION);
to
$extension = pathinfo($fileName ?? "", PATHINFO_EXTENSION);

 

Thanks

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

This works for me

 

Thanks a lot :-)

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

lets take a look. Please run some commands and provide the output:

(note where i say 'php' you may need to use your longer specified version if you don't have an alias)

a) php bin/magento mo:st

b) php bin/magento mo:st|grep -v ^Magento

c) php -v

d) Are you using a custom theme?

 

Likely either a module that isn't ready for php 8.1 is firing off ('depreciated functionality') or you have some issue that provides a similar error such as the following "Static content deploy error after upgrading magento 2.4.3-p1 to 2.4.4" <- can google. I'm betting the latter given the sum of the issue.

 

Remember to test fixes in development not prod, and to version your code for easy reversions)

Re: Magento 2.4.4 and PHP8.1 Deprecated Functionality: pathinfo(): Passing null to parameter

super bro It worked for me