Merge branch '3.3' into 3.4

This commit is contained in:
Daniel Hensby 2016-07-25 14:12:31 +01:00
commit 4f99ced5df
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E

View File

@ -358,7 +358,7 @@ class CMSPageHistoryController extends CMSMain {
/** /**
* @param int $versionID * @param int $versionID
* @param int $otherVersionID * @param int $otherVersionID
* @return Form * @return mixed
*/ */
public function CompareVersionsForm($versionID, $otherVersionID) { public function CompareVersionsForm($versionID, $otherVersionID) {
if($versionID > $otherVersionID) { if($versionID > $otherVersionID) {
@ -369,16 +369,20 @@ class CMSPageHistoryController extends CMSMain {
$fromVersion = $versionID; $fromVersion = $versionID;
} }
if(!$toVersion || !$fromVersion) return false; if(!$toVersion || !$toVersion) {
return false;
}
$id = $this->currentPageID(); $id = $this->currentPageID();
$page = DataObject::get_by_id("SiteTree", $id); $page = DataObject::get_by_id("SiteTree", $id);
if($page && !$page->canView()) { if($page && $page->exists()) {
if(!$page->canView()) {
return Security::permissionFailure($this); return Security::permissionFailure($this);
} }
$record = $page->compareVersions($fromVersion, $toVersion); $record = $page->compareVersions($fromVersion, $toVersion);
}
$fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion); $fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion);
$toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion); $toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion);
@ -391,7 +395,7 @@ class CMSPageHistoryController extends CMSMain {
user_error("Can't find version $toVersion of page $id", E_USER_ERROR); user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
} }
if($record) { if(isset($record)) {
$form = $this->getEditForm($id, null, null, true); $form = $this->getEditForm($id, null, null, true);
$form->setActions(new FieldList()); $form->setActions(new FieldList());
$form->addExtraClass('compare'); $form->addExtraClass('compare');
@ -414,6 +418,8 @@ class CMSPageHistoryController extends CMSMain {
return $form; return $form;
} }
return false;
} }
public function Breadcrumbs($unlinked = false) { public function Breadcrumbs($unlinked = false) {