mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Made 'homepage for domain' feature work on all databases.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79318 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ab9c826ba2
commit
5d67fe14ad
@ -56,14 +56,18 @@ class RootURLController extends Controller {
|
||||
static function get_homepage_urlsegment() {
|
||||
$urlSegment = '';
|
||||
|
||||
// @todo Temporarily restricted to MySQL database while testing db abstraction
|
||||
if(DB::getConn() instanceof MySQLDatabase) {
|
||||
$homePageOBJ = null;
|
||||
|
||||
$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;
|
||||
$SQL_host = Convert::raw2sql($host);
|
||||
|
||||
$homePageOBJs = DataObject::get("SiteTree", "HomepageForDomain LIKE '%$SQL_host%'");
|
||||
if($homePageOBJs) foreach($homePageOBJs as $candidateObj) {
|
||||
if(preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidateObj->HomepageForDomain)) {
|
||||
$homePageOBJ = $candidateObj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(singleton('SiteTree')->hasExtension('Translatable') && !$homePageOBJ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user