Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between two projects using the same package with file autoloading #130

Open
jakubmikita opened this issue Mar 13, 2020 · 2 comments

Comments

@jakubmikita
Copy link

Let's assume we have a package with:

"autoload": {
	"files": [
		"src/functions.php"
	]
},

Where this functions.php file content is:

namespace PackageName

function my_func() {}

Now, when two different projects load the same package, they may have other prefixes:

  • ProjectOne\Vendor\
  • ProjectTwo\Vendor\

So in the first project which loads ealier you do:

ProjectOne\Vendor\PackageName\my_func();

which is fine, but the other:

ProjectTwo\Vendor\PackageName\my_func();

Gives function not found fatal error.

The reason why is because of both function.php files, despite changed namespace has the same content hash generated by composer autoloader. And because the file with given hash has been already loaded it doesn't load it again.

Any idea why this is happening? Does Imposter change the namespace after the Composer generates the file hashes?

@tangrufus
Copy link
Member

Why PHP is loading 2 projects at the same time?
In other words, why there is 2 root composer.json?

@jakubmikita
Copy link
Author

No no, it's two separate WordPress plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants