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

Bug #780237 reported by Hugh Davenport
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Wishlist
Hugh Davenport

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

Changed in mahara:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Yeah, I've always had the same problem, so I fix it in config.php.

Shouldn't be too big a deal for people, config.php says "Normally, this is automatically detected - if it doesn't work for you then try specifying it here".

Changed in mahara:
importance: Low → Wishlist
Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

Moodle seems to do this well, or at least in my situation.

Would it be worth reusing the stuff there, or just leave it as is and put it in config.php :)

Cheers,

Hugh

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Hugh, yeah definitely, let's generate it the moodle way if that's more reliable.

Revision history for this message
François Marier (fmarier) wrote :

By the way, I think we should fix this in master once we have branched 1.4 off of master.

(It's a bit late in the development cycle to make a change that could potentially break a lot of sites.)

Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

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

Changed in mahara:
status: Confirmed → In Progress
assignee: nobody → Hugh Davenport (hugh-catalyst)
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

That is good solution Hugh, I have verified it, it works fine.

Francois: do we need to abadon the change and recover afterwards or just keep it in the list with the curent status.

Revision history for this message
François Marier (fmarier) wrote :

Ruslan, we can just keep it in Gerrit with a temporary "Do not submit" and then merge it onto master once we've branched off 1.4

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/140
Committed: http://gitorious.org/mahara/mahara/commit/a5887e1c500ad4640934962731ed78e819b58fdd
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit a5887e1c500ad4640934962731ed78e819b58fdd
Author: Hugh Davenport <email address hidden>
Date: Wed May 11 14:12:05 2011 +1200

    Fix autogen of wwwroot to detect symbolic links correctly

    Test by appending each directory in PHP_SELF to DOCUMENT_ROOT
    when the realpath of that is the same as dirname(__FILE__) then
    stop processing.

    For most users there is little performance hit, only a few will
    have more than say two levels above DOCUMENT_ROOT

    If nothing can be autoconfigured, use a default of root (ie no
    path)

    Bug #780237

    Change-Id: I60339a180ac043ab0b89c3a49ff5f2485112f567
    Signed-off-by: Hugh Davenport <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Changed in mahara:
milestone: none → 1.5.0
Changed in mahara:
status: Fix Committed → Confirmed
status: Confirmed → Fix Committed
Revision history for this message
Melissa Draper (melissa) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

status fixreleased
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPjqdlAAoJECXBtiziiXdcxeoH/iQi1ljFCaDUrA07cq6IAZga
p3Tw7VRtZBy6Cl5NwOFg1b4/DsqFIM9fQPb+WpJqUAcTVP6B44QElOCtb0ldeZCw
cgWlkkSj1jk/gpCdKhCZ2MMHkRjMao5ZpUyF4vSO26tIiYcvPIhRoF6uWu0Z40xe
1wee4ZKGEEvO13bujMyuu4nEQSd9TK5VWPn+PbIKFEyJgCY19Zw62fWBXoanPbWj
LDuO9AnaQOPyVEx2qtoH8M5LFra2zq+dZ9Ac7oAiLffcWJAB9MqL8o2zbQHpOuVi
Ynrh6BIyUYaqdt1BhALrJ6/MQ0h7mDKGy8CVg0z4e2VHyxecYwc84kwzrItH7I0=
=mdeb
-----END PGP SIGNATURE-----

Revision history for this message
Melissa Draper (melissa) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 status fixreleased
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPjrRzAAoJECXBtiziiXdcggYH/39bWTAPjHe9fUi3ve11K6iW
/R7j+mSc51e/47Cx0Z1Xv1HkDY0ymFLyRU/4CgErzWLWtrlSVhDx/r3gf8aHj+A+
ICmHRmTTCRBij5sKZVZbzZDN/t9drPvJ1u1dWcagGR2DiXoxAa9Kd2LUXKScRvS6
DqhQWj42JiOoo1R1FGFLa8dpPwlzwuLKyQQ6gvdDutva0E3RqktUUBy8w6ieMG6E
UM/K4sdgx7AAhfBxg91349DOjKeHE/69Vb1gbJXE9UtY/xwe+3sgBtAM7aN4e5US
PhBcGckRLkgxpwLwDzTNGuDHFp51OjIdqXaoRAxXx3tgOonY2bs/eqg42RJBcR4=
=dLjM
-----END PGP SIGNATURE-----

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.