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

7 REPLIES 7

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

To accelerate handling of this issue, ensure that you gave the accompanying data:

Synopsis of the issue
Data on your current circumstance
Moves toward imitate
Expected and genuine outcomes
Ensure that the issue is reproducible on the vanilla Magento case following Steps to replicate. To send vanilla Magento example on our current circumstance, Add a remark to the issue:

@Magento give me 2.4-foster occasion - forthcoming 2.4.x delivery

For additional subtleties, audit the Magento Contributor Assistant documentation.

Add a remark to dole out the issue: @Magento I am dealing with this

To look into issue handling work process, allude to the Code Contributions.

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