junaidbhura/composer-wp-pro-plugins

pathinfo(): Argument #1 ($path) must be of type string, null given

Twansparant opened this issue ยท 9 comments

Hi there,

Since composer versions 2.3+, I'm getting this error when running composer install with gravityforms:

In FileDownloader.php line 439:
                                                                      
  [TypeError]                                                         
  pathinfo(): Argument #1 ($path) must be of type string, null given

Exception trace:
  at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:439
 pathinfo() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:439
 Composer\Downloader\FileDownloader->getFileName() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:143
 Composer\Downloader\FileDownloader->download() at phar:///usr/local/bin/composer/src/Composer/Downloader/ZipDownloader.php:100
 Composer\Downloader\ZipDownloader->download() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:228
 Composer\Downloader\DownloadManager->Composer\Downloader\{closure}() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:240
 Composer\Downloader\DownloadManager->download() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:105
 Composer\Installer\LibraryInstaller->download() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:353
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:282
 Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:759
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:588
 Composer\Installer->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Installer.php:279
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:241
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1015
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:334
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:130
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:83
 require() at /usr/local/bin/composer:29

Any idea what's going on?
Thanks!

@Twansparant Twansparant
we've been facing same issue
composer-wp-pro-plugins is simply not yet compatible to 2.3.0 (no release done since 7 months and composer had released 2.3.0 this month (yday): https://github.com/composer/composer/releases

a solution would be to rollback to previous composer version (2.1, 2.2 seems to be ok) and wait for junaidbhura to be compatible with 2.3.0

Yeah I just rolled back to version 2.2.10 and that just throws a notice instead of an error:

Deprecation Notice: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:457

@Twansparant Twansparant then 2.1 (works on our side)

No sorry, I meant 2.2.10 also works for me!

Came across this yesterday. Downgraded Composer to 2.2.10 and it worked for me too. I think its because of strict type checking. Will have to take a look.

More info:
https://blog.packagist.com/composer-2-3/
https://github.com/composer/composer/releases/tag/2.3.0

@junaidbhura i can have a look this week if needed
meanwhile, it might worth updating (or adding a note on) README.md (https://github.com/junaidbhura/composer-wp-pro-plugins/blob/master/README.md?plain=1#L31) until compatible with composer 2.3.0

I'm also experiencing this problem on composer 2.3.0 and initial debugging (I might be totally wrong tho) shows that the PluginEvents::PRE_FILE_DOWNLOAD event is loaded after it loads the $package->getDistUrl() in the composer/src/Composer/Downloader/FileDownloader.php#L437 getFileName function, which means the distUrl gets changed too late.

I think I found a solution, add a trailing slash to the "dist" url:

"dist": {
    "type": "zip",
    "url": "https://www.advancedcustomfields.com/"
}, 

The packages will now install like before. The downside is that this requires developers to edit their composer.json file, instead of simply updating this package.

Hello All,

Unfortunately it looks like this happens outside of the plugin here: https://github.com/composer/composer/blob/main/src/Composer/Downloader/FileDownloader.php#L439

So as @arjendejong12 pointed out - the solution in this case will be to just add a trailing slash / in the packages' dist URLs. I'm going to close this issue and update the README of this plugin to reflect this.