Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX #5245 Sometimes page records will have a NULL ParentID value, …

…it should be a number even if it's 0 (thanks wrossiter!) (from r101657)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112014 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit c08e277ba0df3b3fb54249b4806a254c9f0d3d20 1 parent 4414b8a
@sminnee sminnee authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 core/model/SiteTree.php
View
7 core/model/SiteTree.php
@@ -1339,10 +1339,11 @@ function requireDefaultRecords() {
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
Please sign in to comment.
Something went wrong with that request. Please try again.