Merge pull request #1551 from phptek/issue/1054

FIX: Fixes #1054 By preventing errors in the CMS _only_.
This commit is contained in:
Daniel Hensby 2016-07-21 12:18:33 +01:00 committed by GitHub
commit a8cf17b008

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 || !$toVersion) 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()) {
return Security::permissionFailure($this); if(!$page->canView()) {
} 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) {