Jump to content
kongondo

[SOLVED] Multi-instance Support in Multi-site Setup

Recommended Posts

I am trying out multi-instance support in a multi-site setup (option #1, multiple databases) on a Windows Machine (but using a LAMP stack). I am getting a Fatal error in ProcessWire.php #line 877, Failed opening required  '/F:/vhosts/sandpit.dev/wire/config.php' (include_path='.;C:\php\pear') in F:\vhosts\sandpit.dev\wire\core\ProcessWire.php on line 877

I am using the following API

$path = "F:/vhosts/sandpit.dev/site-mediamanager/";
// OR
// $path = "F:\\vhosts\\sandpit.dev\\site-mediamanager\\";
$url = "http://mediamanager.sandpit.local/";
$site = new ProcessWire($path, $url);

Here is Line #877

require("$rootPath/$wireDir/config.php");

In my code, $path is an absolute path on the windows machine. In the above example, I want ProcessWire to find the /site-mediamanager/config.php, which is a multi-site running off one Wire powered through the main /site/.

As you can see in the error, ProcessWire is adding an extra forward slash to the path, i.e. 

'/F:/vhosts/sandpit.dev/wire/config.php' 

instead of 

'F:/vhosts/sandpit.dev/wire/config.php' 

which obviously fails. I have traced the origin to line #784 in ProcessWire.php

$rootPath = '/' . implode('/', $parts); // remove siteDir from rootPath

The pre-pended / causes the error. Remove that and multi-instance works fine in my environment.

Before I report this as a bug, has anyone ran into this issue? Alternatively, could someone on a Windows machine please test the multi-instance feature for me? Maybe even someone using an absolute path on any machine? Preferably test in a multi-site setup (option #1). If this is a bug, it would be nice if it gets fixed before the imminent master release.

PW version 3.0.85 (but also tested on the latest dev version).

 

Thanks.

Share this post


Link to post
Share on other sites

None of you cool kids use Windows :P? Or you don't use multi-sites option #1?

Share this post


Link to post
Share on other sites

@kongondo I do. I would be able to test it tomorrow if still needed. 

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Zeka said:

@kongondo I do. I would be able to test it tomorrow if still needed. 

Yes, still needed. That'd be awesome @Zeka, thanks! 

Share this post


Link to post
Share on other sites

I don't use multi-instance support but looking at the code it's a bug for me. The culprit is here: 

$parts = explode('/', $rootPath);

Since windows path doesn't start with a slash, $parts is different on nix and windows. Temporary detour (until Ryan fix it) could be using / as the first character in the path:

$path = "/F:/vhosts/sandpit.dev/site-mediamanager";
// OR
// $path = "\\F:\\vhosts\\sandpit.dev\\site-mediamanager"

I'm not sure what impact would that have later on...

  • Like 2

Share this post


Link to post
Share on other sites
28 minutes ago, matjazp said:

$path = "/F:/vhosts/sandpit.dev/site-mediamanager";
// OR
// $path = "\\F:\\vhosts\\sandpit.dev\\site-mediamanager"

I'm not sure what impact would that have later on...

Thanks. I'd already tested these and no joy. Still doesn't work. 

Share this post


Link to post
Share on other sites
20 hours ago, kongondo said:

I'd already tested these and no joy. Still doesn't work. 

Yeah. As / is prepended to the $rootPath. Maybe you could rename site-mediamanager to sitemediamanager  and also modify .htacces to reflect that change? But this is a hacky approach. Ryan must fix that, shouldn't be a problem (and also the realpath() where path contains ..)

  • Like 1

Share this post


Link to post
Share on other sites

@kongondoWould this work? Just a workaround, until Ryan fix it...

$rootPath = "F:/vhosts/sandpit.dev";
$sitePath = "site-mediamanager";
$url = "http://mediamanager.sandpit.local/";

$cfg = Processwire::buildConfig($rootPath, $url, array("siteDir" => $sitePath));

$site = new ProcessWire($cfg);


 

  • Like 2

Share this post


Link to post
Share on other sites
On 04/03/2018 at 4:58 PM, matjazp said:

@kongondoWould this work? Just a workaround, until Ryan fix it...


$rootPath = "F:/vhosts/sandpit.dev";
$sitePath = "site-mediamanager";
$url = "http://mediamanager.sandpit.local/";

$cfg = Processwire::buildConfig($rootPath, $url, array("siteDir" => $sitePath));

$site = new ProcessWire($cfg);


 

Brilliant! That did it! Meanwhile, I submitted an issue report here.

Share this post


Link to post
Share on other sites

Ryan committed a fix for this yesterday. I'll make this thread as solved, although a subsequent potential issue was raised.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By wbmnfktr
      I know from a trusted source that some of you use Laragon as their prefered Windows DEV solution.
      Due to a recent conversation I noticed that there might be a nice little feature some of you may not know about.
      Laragon offers the Quick app option with some tools already predefined. In order to have ProcessWire there as well you just have to add one (two with a comment) line to your Laragon configuration.
      # ProcessWire ProcessWire=composer create-project processwire/processwire %s
      Just in case you want to start your next project a little bit faster.
    • By FrancisChung
      Hi there,
      I have an older Macbook Pro which I'm trying to use as a Desktop Machine for the occasional work-at-home machine.
      I was using Resilio Sync to sync my projects between my main laptop and every time there's a problem with the sync, it seems to delete random files and folders. So anyone using Resilio Sync, think again.
      I would have used rsync but if I recall correctly, I couldn't the get the command to work with my other laptop (rsync wouldn't accept my destination path).  I also have some files I sync between the main laptop and my Windows box, so that was another reason why I opted for Resilio Sync at the time.
      So after spending a few hours recovering my files today, I've decided enough is enough (3rd time it's failed)  and am looking for a new way to sync files between 2 OSX Laptops and a Windows box.

      Anyone have a foolproof, stress-free solution that they use?
      Thanks!
    • By steveooo
      Hello guys,
      I am using some nested PageTables and with every PageTable field the user clicks on, a modal window appears. Because every modal window's width & height are not 100%, every nesting step shrinks the window.

      Does someone have any solution for this problem?
      Best wishes,
      steveooo
    • By mrjasongorman
      I have IIS 8.5 running PHP 5.6 and i can't get Processwire to work.
      Normal PHP executes, but when i go to processwire it's just a blank page, even trying to display PHP errors just returns a blank page.
      my web.config is as follows (which worked on a previous windows processwire setup)
      <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="CLEAN URLS" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php?it={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration> Can anyone with IIS and windows server knowledge help out?
    • By MichaMichaMicha
      I've now twice noticed a problem after I deployed a version to a live server.
      For example the top buttons in Admin.
      Usually they are in the order:
      Pages Setup Modules Access Only when I pushed everyting (incl database export) live the order seems to have changed to 
      Pages Modules Setup Access I also noticed a simple selector seems to ignore the sort I used, and used I think the ID for sorting.
      It was a critical moment so I quick-hacked a sort after the selector got it results, and thus was not able to get the source ot the problem.
      The production server uses CentOS with Php 5.2.17 and MySQL 5.0.51a
      Before I lose hours in debugging and testing, maybe anyone has noticed the same issues and already figured out what was wrong?
×
×
  • Create New...