Solved: Complex installation bug

Having trouble installing serendipity?
Post Reply
nealk
Regular
Posts: 26
Joined: Sun Sep 20, 2009 1:09 am

Solved: Complex installation bug

Post by nealk »

My first update went painlessly.
My second update was troublesome due to my server configuration. But I finally worked it out.

The setup:
I have multiple blogs on my server.

The first s9y instance is under "http://server1/blog/" and is actually at /home/me/html/blog/.

The second s9y instance is under "http://server2/blog/" (a different domain name) and is actually under /home/me/html/site2/blog/. Technically, going to http://server1/site2/ brings up the second domain. But since I don't advertise this link, nobody knows about it.

The second domain is managed by a web redirect. This way, it is never seen by the user, and my hosting provider doesn't charge me for having a second domain on the same server.

The problem (symptom):
Installing/updating s9y (1.6.2) for http://server2/blog/ ends up returning content for http://server1/blog/. The server2 install accesses all files in the server1 blog installation, including the database and templates.

The problem (technical):
serendipity_config.inc.php uses $_SERVER['DOCUMENT_ROOT'] to find the config file location. The problem is, DOCUMENT_ROOT points to /home/me/html/ and not /home/me/html/site2/.

This probably would not be a problem if /home/me/html/blog/ didn't exist, since there is fallback code that looks in the correct place. But since I have /home/me/html/blog AND /home/me/html/site2/blog/, the second one sees the first's /blog/ and uses it for all files, including the local config.

This is a new issue. S9y didn't do this in 1.0.x or 1.4.x. (My previous versions that worked before needing the upgrade.) This problem exists in 1.6.2. (I don't know about other releases or when it was introduced.)

The solution:
In serendipity_config.inc.php, right after the check for S9Y_FRAMEWORK, I added in a hard-coded path:
$_SERVER['DOCUMENT_ROOT'] = "/home/me/html/site2/";
This fixed the problem. Since this config file is always loaded before everything else, the hard-coded path ensures that s9y will access the correct files.

A better long-term solution would be to use dirname(__FILE__) and set it as a global variable used by s9y for anything that needs the document root path, rather than depending on DOCUMENT_ROOT. DOCUMENT_ROOT is currently used in:
serendipity_config.inc.php
include/admin/installer.inc.php
include/functions_installer.inc.php
include/functions_smarty.inc.php
bundled-libs/Smarty/libs/plugins/function.html_image.php
bundled-libs/Text/Wiki/Render/Xhtml/Image.php
templates/bulletproof/config.inc.php

Alternately, the path is set correctly in the database (s_config: serendipityPath), so this should be used.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Solved: Complex installation bug

Post by garvinhicking »

Hi!

Sorry to hear about your issues. Funnily, recently it has come up on some of our developers instances as well, which use the same document-root for subdomains. The patches to change this have been committed to the serendipity 1.7 and 2.0 tree, so you might want to check out those installations to see if it also works out for you...

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply