composer-changelogs icon indicating copy to clipboard operation
composer-changelogs copied to clipboard

Error when upgrading to v2.0.0 (Cannot assign Pyrech\ComposerChangelogs\Config\Config to property)

Open adrenth opened this issue 2 years ago • 4 comments

  • PHP v8.2
  • Composer v2.5.2

When having v1.8.2 installed and upgrading to v2.0.0 you might get this error:

  - Upgrading pyrech/composer-changelogs (v1.8.2 => v2.0.0): Extracting archive
    Update of pyrech/composer-changelogs failed

In PluginManager.php(274) : eval()'d code line 111:
                                                                                                                                                         
  [TypeError]                                                                                                                                            
  Cannot assign Pyrech\ComposerChangelogs\Config\Config to property Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0::$config of type ?Pyrech\C  
  omposerChangelogs\Model\Config                

After clearing composer cache it should work fine.

$ composer clear-cache

...

$ composer update

...

Changelogs summary:

 - pyrech/composer-changelogs updated from v1.8.2 to v2.0.0 major
   See changes: https://github.com/pyrech/composer-changelogs/compare/v1.8.2...v2.0.0
   Release notes: https://github.com/pyrech/composer-changelogs/releases/tag/v2.0.0

However... can this behavior be prevented? Anyone else experienced this issue?

adrenth avatar Feb 07 '23 14:02 adrenth

Hi @adrenth

I released v2 a few days ago so you might be the first to experience this issue. Sorry for that.

I guess this is due to some class that were renamed but Composer keep some cache for each plugin. I will try to reproduce the issue and fix it asap.

Thanks

pyrech avatar Feb 07 '23 15:02 pyrech

Can confirm clear-cache fixed this for me too

PHP Fatal error:  Uncaught TypeError: Typed property Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0::$config must be an instance of Pyrech\ComposerChangelogs\Model\Config or null, Pyrech\ComposerChangelogs\Config\Config used in phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code:111
Stack trace:
#0 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code(41): Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0->setupConfig()
#1 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(345): Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0->activate()
#2 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(233): Composer\Plugin\PluginManager->addPlugin()
#3 phar:///usr/bin/composer/src/Composer/Installer/PluginInstaller.php(103): Composer\Plugin\PluginManager->registerPackage()
#4 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}()
#5 phar:///usr/bin/composer/vendor/react/promise/src/React/Promise in phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code on line 111

Fatal error: Uncaught TypeError: Typed property Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0::$config must be an instance of Pyrech\ComposerChangelogs\Model\Config or null, Pyrech\ComposerChangelogs\Config\Config used in phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code:111
Stack trace:
#0 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code(41): Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0->setupConfig()
#1 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(345): Pyrech\ComposerChangelogs\ChangelogsPlugin_composer_tmp0->activate()
#2 phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(233): Composer\Plugin\PluginManager->addPlugin()
#3 phar:///usr/bin/composer/src/Composer/Installer/PluginInstaller.php(103): Composer\Plugin\PluginManager->registerPackage()
#4 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}()
#5 phar:///usr/bin/composer/vendor/react/promise/src/React/Promise in phar:///usr/bin/composer/src/Composer/Plugin/PluginManager.php(221) : eval()'d code on line 111
➜`

EPGDigital-MW avatar Mar 06 '23 11:03 EPGDigital-MW

@pyrech Maybe adding a note about it in the CHANGELOG would be enough. It's a simple fix once you know what to do.

NicolasCARPi avatar Mar 08 '23 01:03 NicolasCARPi

Sorry I did not find some time to dig this issue yet.

@NicolasCARPi You're right, thanks for the suggestion, I just added a note in the CHANGELOG.md and the GitHub release

pyrech avatar Mar 08 '23 11:03 pyrech