Jump to content

multi-instance compile error


dotnetic
 Share

Recommended Posts

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

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

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 🙂 

  • Like 2
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...