← Back to team overview

mahara-contributors team mailing list archive

[Bug 780237] Re: autogen of wwwroot doesn't work when htdocs is linked to www directory

 

Ok so the way moodle does it is work it out at install time and write to
config.php (they require document root to be writeable...)

The way they get the wwwroot path is get the proto + hostname roughly
the same way as mahara, then for the path above / they do the following:

get the path from one of the following (in order)
$_S['REQUEST_URI']
$_S['PHP_SELF']
$_S['SCRIPT_NAME']
$_S['URL']
The final three have '?'.$_S['QUERY_STRING'] appended if it is not empty

This string is then exploded around '/install.php' and voila, path to
wwwroot.

The problem with doing this in mahara is that we don't know each time
what should be exploded (ie what file is being run, as __FILE__ will
always be init.php in the /true/ path (ie
/home/hugh/src/mahara/mahara/htdocs/init.php in my case))

How I have done it is append each directory in PHP_SELF to
DOCUMENT_ROOT, test it with realpath() against dirname(__FILE__), and
stop when they are the same.

This should work no matter what script is actually being called, and
only is a performance issue if the users have several directorys under
document root (most will have none, then maybe a few with one, little
with two or more most likely...)

https://reviews.mahara.org/140

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
https://bugs.launchpad.net/bugs/780237

Title:
  autogen of wwwroot doesn't work when htdocs is linked to www directory

Status in Mahara ePortfolio:
  Confirmed

Bug description:
  In my situation, I have a git directory containing the mahara files.
  Instead of editing apache configs to make a site I just linked it (ln
  -s) to the /var/www directory.

  my git directory is /home/hugh/src/mahara/mahara
  the htdocs directory is linked to /var/www/mahara
  the autogen of wwwroot is http://localhost/gh/src/mahara/mahara/htdocs

  Cheers,

  Hugh


References