-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
NamespaceReplacer inserts duplicate namespace #11
Comments
@iandillon Could you have a look at #12, if this still applies on that branch? I've taken a different approach to handle the dependency tree and I think this bug is fixed with that as well. Thanks in advance! |
I believe this is no longer an issue, since the dependency tree rewrite is done differently in release 0.3.0. Please test that release to verify and feel free to reopen this issue if the issue still exists. |
I still have this issue. @iandillon's suggestion solves it though. Edit: I spoke too soon. This is a breaking change as it doesn't replace everything anymore. |
@ju5t can you give some more context, perhaps share the Mozart configuration you're using? |
@coenjacobs Absolutely. The source can be found here: https://github.com/sensson/whmcs-moneybird/tree/implement-mozart
I know this isn't WordPress but I think that shouldn't make a difference at this stage. It could be that I've done something wrong though. |
Sorry about the bump, but I am also experiencing this issue |
Same issue here using 0.4.0. What I've figured is that in order to avoid the issue, I must make sure that each package is only processed once by Mozart. So for example if I use This is indeed just a workaround to only tell Mozart about the last package in the dependancy chain, as I am indeed lucky to have this issue with chained packages. But but if someone would have a fork of dependencies, like package |
This probably might need another fix in order to solve all cases, but let me get the following straight: Mozart should only be used to rewrite the dependencies of the project itself. If those dependencies have dependencies of their own, those should not be added to the Mozart configuration. So if your project requires a and a requires b, only a should be added to the Mozart configuration. During the package discovery, Mozart will also rewrite b, because that is a dependency of a, without b being added to the Mozart configuration itself. Can you provide an example of a |
@coenjacobs I'll post mine for you
In the above config, |
Hi 👋 I stumbled over your project when I was looking for ways to scope composer packages for Nextcloud apps (plugins). As far as I understood we're facing the same problem as Wordpress developers do. In any case I found the same issue reported here to block us from the adoption of this package. Our goal is to bundle With The file is located at You can find my PR at ChristophWurst/nextcloud_sentry#172. It should be possible to reproduce the issue without any knowledge about Nextcloud. Just treat is as any other composer package or Wordpress plugin :) Is there anything we can do to help you diagnose or solve the problem? Cheers and thanks for this package 🚀 |
@ChristophWurst Not really related to the issue in this thread but just thought I would let you know. |
Thanks for the heads-up, @EvanShaw. That is quite a bummer as Guzzle is our #1 conflicting dependency in the Nextcloud ecosystem right now. |
Potentially fixed with: #40. I didn't see the issue until after the PR. To quickly test it, add:
|
@BrianHenryIE good stuff! I tried with the patch and the original bug is gone. Guzzle is not rewritten with the prefix twice. Nice! I still can't get Guzzle to work here because it's used (detected) via httplug and Mozart does not rewrite all imports, thus it does not detect the implementation. So, even with this follow-up problem, I think you patch is a great improvement :) Thanks a lot ❤️ |
The original problem for which this issue was raised is fixed thanks to @BrianHenryIE. Therefore, I'm closing this issue. This can now be tested with the 0.6.0 beta 1 release. @ChristophWurst could you do me a favour and test that to see if the followup issues you ran into, are also fixed with that beta release? There's been significant improvements in the replace logic in parent/using classes as well, in that same release. If not, it would be greatly appreciated if you could open a separate issue for the remaining issue, so we can tackle those as well. |
I will test it next Monday, thanks! 👍 |
The duplicate namespace issue is fixed. The failing auto discovery with httplug remains. I'll try to create a minimal example project to demonstrate the issue. |
I've found this behaviour since implementing the commit by costasovo for supporting dependency trees. The regex within the replace function in NamespaceReplacer.php can result in the configured mozart dep_namespace value to be inserted into namespace definitions multiple times if a file is passed to the method more than once
Changing the regex so that only namespaces which don't already contain the configured value are matched, resolves the issue.
e.g '/([^\\?])(?<!'.addslashes($this->dep_namespace).')(' . addslashes($searchNamespace) . '[\|;])/U'
The text was updated successfully, but these errors were encountered: