#177 - Don't let people create a page name the same as a class name

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49186 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-02-07 03:39:51 +00:00
parent eda6a3b7e4
commit bee4f9423a

View File

@ -777,7 +777,7 @@ class SiteTree extends DataObject {
'';
$count = 1;
while(DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")) {
while(class_exists($this->URLSegment) || DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")) {
$count++;
$this->URLSegment = ereg_replace('-[0-9]+$','', $this->URLSegment) . "-$count";
}