dotnetic Posted July 18, 2023 Share Posted July 18, 2023 I am using How to use multi-instance in PW 3.x (processwire.com) to connect two PW instances, because I need to display data from one instance in the other. But when using this code in one of my template files in the second instance, <?php $shopSite = new \Processwire\ProcessWire('../../../fugamo-shop/dist/'); I get the following error https://fugamo.ddev.site/textilien/ Compile Error: Cannot declare class ProcessWire\InputfieldFieldsetOpen, because the name is already in use (Row 0 in /var/www/html/fugamo-shop/dist/wire/modules/Fieldtype/FieldtypeFieldsetOpen.module) It works with two fresh PW instances, but not with my existing sites. I really don't know where to look to debug this. As you can see the PHP template file does not use a namespace. But even when using the namespace it does not work. I disabled template compilation in the settings, and also disabled automatic prepending/appending of _header.php and _footer.php Some more info, the site I try to bootstrap has many modules and fields and templates installed. The site where I try to include it in, just has a few modules installed and not many fields. ProcessWire version ist the latest dev 3.0.222 in both instances. Link to comment Share on other sites More sharing options...
dotnetic Posted July 18, 2023 Author Share Posted July 18, 2023 As this is not working right now and I need to proceed, I have chosen to use url hooks ProcessWire 3.0.173 core updates: New URL hooks instead, and provide an API where I pull the data I need via AJAX. Anyways I would be interested in solving the issue with multi-instance. Link to comment Share on other sites More sharing options...
flydev Posted July 18, 2023 Share Posted July 18, 2023 It look like a namespace issue. To debug it, what I would do in first instance, is to make backup of databases of the fresh installs which is working, and then the others. After that, I would compare dbs with a good tools like BeyondCompare. In second instance, I would write a script to extract all namespace declaration and use directives to see if there is something to spot. Link to comment Share on other sites More sharing options...
MarkE Posted July 18, 2023 Share Posted July 18, 2023 Does this help? 1 Link to comment Share on other sites More sharing options...
dotnetic Posted July 19, 2023 Author Share Posted July 19, 2023 @MarkE I don't know what you are referring to, but the post you linked is about multilingual websites. I am talking about multi-instance (including data of one PW into another). Link to comment Share on other sites More sharing options...
bernhard Posted July 19, 2023 Share Posted July 19, 2023 I don't have a real solution, but I have had similar Problems when using multi-instance. I don't think it is a namespace issue. At least in my case this was not the case. In my case the problem came from including some dependencies by using "require_once". At least on my modules I was able to fix that problem by using the PW internal class loader instead of require or require_once. This tells me that PHP seems not to be able to correctly understand "require_once" when it is used from different directories. So for PHP including the same PHP class (eg /foo/wire/MyClass.php and /bar/wire/MyClass.php) looks like including two different things and therefore it will fire the include twice and not only once. This would then lead to such "is already in use" errors. In my modules that was easy to fix, but you can't easily refactor modules that are not under your control. What I'm wondering though is why it works with plain installs and does not with your real life projects. So maybe it's another issue. But maybe my observations help nonetheless ? 2 Link to comment Share on other sites More sharing options...
flydev Posted July 19, 2023 Share Posted July 19, 2023 @dotnetic @MarkE was refering about multi-instance issue, where there are some hints with Ryan intervention, it might help: 2 Link to comment Share on other sites More sharing options...
MarkE Posted July 19, 2023 Share Posted July 19, 2023 8 hours ago, dotnetic said: I don't know what you are referring to Hi @dotnetic. Hopefully @flydevpointed you in the right direction. What I was referring to was @ryan’s snippet to prevent multiple booting of the instance. Link to comment Share on other sites More sharing options...
dotnetic Posted July 19, 2023 Author Share Posted July 19, 2023 Here is what I tried. Removed all site modules from the to be included instance (shop). Did not work. Also remove all site modules from the instance (web) where I try to include the first instance (shop). Did also not work. The error still occurs even with no modules at all. I am pointless at the moment, so I am going further with the url hooks approach. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now