mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX #5245 Sometimes page records will have a NULL ParentID value, it should be a number even if it's 0 (thanks wrossiter!)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101657 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
20f0da7c05
commit
935db2a9c5
@ -1322,10 +1322,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
|
||||
protected function onBeforeWrite() {
|
||||
parent::onBeforeWrite();
|
||||
|
||||
|
||||
// If Sort hasn't been set, make this page come after it's siblings
|
||||
if(!$this->Sort && $this->ParentID) {
|
||||
$this->Sort = DB::query("SELECT MAX(\"Sort\") + 1 FROM \"SiteTree\" WHERE \"ParentID\" = $this->ParentID")->value();
|
||||
if(!$this->Sort) {
|
||||
$parentID = ($this->ParentID) ? $this->ParentID : 0;
|
||||
$this->Sort = DB::query("SELECT MAX(\"Sort\") + 1 FROM \"SiteTree\" WHERE \"ParentID\" = $parentID")->value();
|
||||
}
|
||||
|
||||
// If there is no URLSegment set, generate one from Title
|
||||
|
Loading…
x
Reference in New Issue
Block a user