Restricted RootURLController's REGEXP call to MySQL databases only.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@66424 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-23 23:21:29 +00:00
parent d2d22aa2d7
commit 8eed347ca2

View File

@ -34,10 +34,15 @@ class RootURLController extends Controller {
* Return the URL segment for the current HTTP_HOST value
*/
static function get_homepage_urlsegment() {
$host = $_SERVER['HTTP_HOST'];
$host = str_replace('www.','',$host);
$SQL_host = str_replace('.','\\.',Convert::raw2sql($host));
$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain REGEXP '(,|^) *$SQL_host *(,|\$)'");
// Temporarily restricted to MySQL database while testing db abstraction
if(DB::getConn() instanceof MySQLDatabase) {
$host = $_SERVER['HTTP_HOST'];
$host = str_replace('www.','',$host);
$SQL_host = str_replace('.','\\.',Convert::raw2sql($host));
$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain REGEXP '(,|^) *$SQL_host *(,|\$)'");
} else {
$homePageOBJ = null;
}
if($homePageOBJ) {
return $homePageOBJ->URLSegment;