[pmwiki-users] Nesting in a Wiki Farm.

Patrick R. Michaud pmichaud at pobox.com
Mon Jan 15 11:08:14 CST 2007


On Wed, Jan 10, 2007 at 02:28:07PM -0600, John McGinnis wrote:
>    Have a different question in regards to Farms. Can you nest? For example
>    can you do --
>     
>    /Home Wiki
>    |
>    -\Child Wiki
>      |
>      -\GrandChild Wiki
>     
>    I have setup a test Wiki of this depth and each Wiki in kind does work.
>    What I want to do is have the settings of the config.php be inherited from
>    the level above plus any local customization.  However when I get to the
>    GrandChild Wiki level I get the following notice:
>     
>    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
>    allocate 8192 bytes) in /var/www/pmwiki/jgrp/local/config.php on line 1
>     
>    In the Child and GrandChild Wikis I have the following statement included
>    in their respective /local dir:
>     
>    <?php include('../local/config.php');

This is creating an infinite loop of loading the Child's 
local/config.php, which is why you're getting the "memory 
exhausted" error.  

It's important to remember that the include() statement is
relative to the directory in which pmwiki is running, and
not the file in which it's written.  Thus when the GrandChild's
config.php does include('../local/config.php') it doesn't change
directories -- it simply starts executing the statements in that
file from the current directory.

So, we start reading commands from ../local/config.php, and
the first statement is again include('../local/config.php'),
which means we load the same file again -- i.e., an infinite loop.

Instead of a simple '../local/config.php', you might try 
the following instead in each of the configuration files:

  $pconfig = preg_replace('![^/]*/(local/config\.php)$!', '$1', __FILE__);
  include_once($pconfig);

This computes the absolute path of a parent's local/config.php
from the current local/config.php .

Hope this helps,

>    2) Is there anything from a design perspective that would be problematic
>    with setting up the Farm this way? For example, does this cause an issue
>    with accessing the Home cookbook, pub and scripts dir?

There's nothing that prevents this from working, although things might
get a bit confusing along the way.  Just keep in mind that $FarmD
still always points to the farm directory, and that any scripts
that are activated in the parent directories act exactly as though
they are executing from the current directory.  In particular, the
only pub/ directory that matters is the one at the current level --
the pub/ directories of any parent wikis aren't accessed.

Pm





More information about the pmwiki-users mailing list