-
Notifications
You must be signed in to change notification settings - Fork 0
Composer hash collision on autoloader #16
Description
When in a project that has used wordpress-plugin-template multiple times the uniqueness of the hash (md5sum) of an unmodified composer.json isn't unique for each instantiation of this plugin template. This becomes a problem because the hash is later used to name the ComposerAutoloaderInit class which then fails in a wider context because there is already a class with the same name e.g.:
PHP Fatal error: Cannot declare class ComposerAutoloaderInit986ff1f9de5f5f6a94f908c1e730deb9, because the name is already in use in phar:///var/www/html/wp-content/plugins/your-plugin/vendor.phar/vendor/composer/autoload_real.php on line 5, referer: http://localhost/wp-admin/plugins.php?plugin=your-plugin%2Findex.php
A solution to this is to make sure composer.json is always different in some way from the template composer.json and that the composer update --lock / composer dump-autoload has been run to uniquely name the class. The most readable way to do this is probably by specifying a autoloader-suffix property in composer.json.
"autoloader-suffix": "MyNewPluginNameHere",An interactive install script or a mention in the README might be good solutions here.