FIX: explicitly call get functions for site tree checks

This commit is contained in:
Stevie Mayhew 2015-06-05 11:09:23 +12:00
parent bb68036854
commit a819bcfc97
7 changed files with 42 additions and 44 deletions

View File

@ -100,7 +100,6 @@ class CMSBatchAction_Delete extends CMSBatchAction {
'"SiteTree"."ID"' => $id
));
if($liveRecord) {
$liveRecord->IsDeletedFromStage = true;
$status['modified'][$liveRecord->ID] = array(
'TreeTitle' => $liveRecord->TreeTitle,
);
@ -148,7 +147,6 @@ class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
'"SiteTree"."ID"' => $id
));
if($stageRecord) {
$stageRecord->IsAddedToStage = true;
$status['modified'][$stageRecord->ID] = array(
'TreeTitle' => $stageRecord->TreeTitle,
);

View File

@ -601,8 +601,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$actions = $form->Actions();
if($record) {
$deletedFromStage = $record->IsDeletedFromStage;
$deleteFromLive = !$record->ExistsOnLive;
$deletedFromStage = $record->getIsDeletedFromStage();
$deleteFromLive = !$record->getExistsOnLive();
$fields->push($idField = new HiddenField("ID", false, $id));
// Necessary for different subsites

View File

@ -259,7 +259,7 @@ class CMSSIteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
$pages = Versioned::get_including_deleted('SiteTree');
$pages = $this->applyDefaultFilters($pages);
$pages = $pages->filterByCallback(function($page) {
return $page->ExistsOnLive;
return $page->getExistsOnLive();
});
return $pages;
}
@ -339,7 +339,7 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
$pages = $this->applyDefaultFilters($pages);
$pages = $pages->filterByCallback(function($page) {
// If page is removed from stage but not live
return $page->IsDeletedFromStage && $page->ExistsOnLive;
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
});
return $pages;
}
@ -368,7 +368,7 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
$pages = $this->applyDefaultFilters($pages);
$pages = $pages->filterByCallback(function($page) {
// If page exists on stage but not on live
return (!$page->IsDeletedFromStage && $page->IsAddedToStage);
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
});
return $pages;
}
@ -408,7 +408,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
$pages = $pages->filterByCallback(function($page) {
// Doesn't exist on either stage or live
return $page->IsDeletedFromStage && !$page->ExistsOnLive;
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
});
return $pages;
}

View File

@ -2275,7 +2275,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
return $actions;
}
if($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage && $this->canDeleteFromLive()) {
if($this->isPublished() && $this->canPublish() && !$this->getIsDeletedFromStage() && $this->canDeleteFromLive()) {
// "unpublish"
$moreOptions->push(
FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')
@ -2284,7 +2284,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
);
}
if($this->stagesDiffer('Stage', 'Live') && !$this->IsDeletedFromStage) {
if($this->stagesDiffer('Stage', 'Live') && !$this->getIsDeletedFromStage()) {
if($this->isPublished() && $this->canEdit()) {
// "rollback"
$moreOptions->push(
@ -2295,7 +2295,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
}
if($this->canEdit()) {
if($this->IsDeletedFromStage) {
if($this->getIsDeletedFromStage()) {
// The usual major actions are not available, so we provide alternatives here.
if($existsOnLive) {
// "restore"
@ -2360,7 +2360,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
}
}
if($this->canPublish() && !$this->IsDeletedFromStage) {
if($this->canPublish() && !$this->getIsDeletedFromStage()) {
// "publish", as with "save", it supports an alternate state to show when action is needed.
$majorActions->push(
$publish = FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))
@ -2415,7 +2415,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
if($linkedPages) foreach($linkedPages as $page) {
$page->copyFrom($page->CopyContentFrom());
$page->write();
if($page->ExistsOnLive) $page->doPublish();
if($page->getExistsOnLive()) $page->doPublish();
}
// Need to update pages linking to this one as no longer broken, on the live site
@ -2783,8 +2783,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
public function getStatusFlags($cached = true) {
if(!$this->_cache_statusFlags || !$cached) {
$flags = array();
if($this->IsDeletedFromStage) {
if($this->ExistsOnLive) {
if($this->getIsDeletedFromStage()) {
if($this->getExistsOnLive()) {
$flags['removedfromdraft'] = array(
'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'),
'title' => _t('SiteTree.REMOVEDFROMDRAFTHELP', 'Page is published, but has been deleted from draft'),
@ -2795,12 +2795,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
'title' => _t('SiteTree.ARCHIVEDPAGEHELP', 'Page is removed from draft and live'),
);
}
} else if($this->IsAddedToStage) {
} else if($this->getIsAddedToStage()) {
$flags['addedtodraft'] = array(
'text' => _t('SiteTree.ADDEDTODRAFTSHORT', 'Draft'),
'title' => _t('SiteTree.ADDEDTODRAFTHELP', "Page has not been published yet")
);
} else if($this->IsModifiedOnStage) {
} else if($this->getIsModifiedOnStage()) {
$flags['modified'] = array(
'text' => _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified'),
'title' => _t('SiteTree.MODIFIEDONDRAFTHELP', 'Page has unpublished changes'),

View File

@ -71,7 +71,7 @@ class FileLinkTrackingTest extends SapphireTest {
// Publish the source page
$page = $this->objFromFixture('Page', 'page1');
$this->assertTrue($page->doPublish());
$this->assertFalse($page->IsModifiedOnStage);
$this->assertFalse($page->getIsModifiedOnStage());
// Rename the file
$file = $this->objFromFixture('File', 'file1');
@ -83,7 +83,7 @@ class FileLinkTrackingTest extends SapphireTest {
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID));
// Confirm that the page hasn't gone green.
$this->assertFalse($page->IsModifiedOnStage);
$this->assertFalse($page->getIsModifiedOnStage());
}
public function testTwoFileRenamesInARowWork() {

View File

@ -194,17 +194,17 @@ class SiteTreeTest extends SapphireTest {
// newly created page
$createdPage = new SiteTree();
$createdPage->write();
$this->assertFalse($createdPage->IsDeletedFromStage);
$this->assertTrue($createdPage->IsAddedToStage);
$this->assertTrue($createdPage->IsModifiedOnStage);
$this->assertFalse($createdPage->getIsDeletedFromStage());
$this->assertTrue($createdPage->getIsAddedToStage());
$this->assertTrue($createdPage->getIsModifiedOnStage());
// published page
$publishedPage = new SiteTree();
$publishedPage->write();
$publishedPage->publish('Stage','Live');
$this->assertFalse($publishedPage->IsDeletedFromStage);
$this->assertFalse($publishedPage->IsAddedToStage);
$this->assertFalse($publishedPage->IsModifiedOnStage);
$this->assertFalse($publishedPage->getIsDeletedFromStage());
$this->assertFalse($publishedPage->getIsAddedToStage());
$this->assertFalse($publishedPage->getIsModifiedOnStage());
// published page, deleted from stage
$deletedFromDraftPage = new SiteTree();
@ -212,9 +212,9 @@ class SiteTreeTest extends SapphireTest {
$deletedFromDraftPageID = $deletedFromDraftPage->ID;
$deletedFromDraftPage->publish('Stage','Live');
$deletedFromDraftPage->deleteFromStage('Stage');
$this->assertTrue($deletedFromDraftPage->IsDeletedFromStage);
$this->assertFalse($deletedFromDraftPage->IsAddedToStage);
$this->assertFalse($deletedFromDraftPage->IsModifiedOnStage);
$this->assertTrue($deletedFromDraftPage->getIsDeletedFromStage());
$this->assertFalse($deletedFromDraftPage->getIsAddedToStage());
$this->assertFalse($deletedFromDraftPage->getIsModifiedOnStage());
// published page, deleted from live
$deletedFromLivePage = new SiteTree();
@ -222,9 +222,9 @@ class SiteTreeTest extends SapphireTest {
$deletedFromLivePage->publish('Stage','Live');
$deletedFromLivePage->deleteFromStage('Stage');
$deletedFromLivePage->deleteFromStage('Live');
$this->assertTrue($deletedFromLivePage->IsDeletedFromStage);
$this->assertFalse($deletedFromLivePage->IsAddedToStage);
$this->assertFalse($deletedFromLivePage->IsModifiedOnStage);
$this->assertTrue($deletedFromLivePage->getIsDeletedFromStage());
$this->assertFalse($deletedFromLivePage->getIsAddedToStage());
$this->assertFalse($deletedFromLivePage->getIsModifiedOnStage());
// published page, modified
$modifiedOnDraftPage = new SiteTree();
@ -232,9 +232,9 @@ class SiteTreeTest extends SapphireTest {
$modifiedOnDraftPage->publish('Stage','Live');
$modifiedOnDraftPage->Content = 'modified';
$modifiedOnDraftPage->write();
$this->assertFalse($modifiedOnDraftPage->IsDeletedFromStage);
$this->assertFalse($modifiedOnDraftPage->IsAddedToStage);
$this->assertTrue($modifiedOnDraftPage->IsModifiedOnStage);
$this->assertFalse($modifiedOnDraftPage->getIsDeletedFromStage());
$this->assertFalse($modifiedOnDraftPage->getIsAddedToStage());
$this->assertTrue($modifiedOnDraftPage->getIsModifiedOnStage());
}
/**

View File

@ -209,46 +209,46 @@ class VirtualPageTest extends SapphireTest {
$vp->write();
// VP is oragne
$this->assertTrue($vp->IsAddedToStage);
$this->assertTrue($vp->getIsAddedToStage());
// VP is still orange after we publish
$p->doPublish();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->IsAddedToStage);
$this->assertTrue($vp->getIsAddedToStage());
// A new VP created after P's initial construction
$vp2 = new VirtualPage();
$vp2->CopyContentFromID = $p->ID;
$vp2->write();
$this->assertTrue($vp2->IsAddedToStage);
$this->assertTrue($vp2->getIsAddedToStage());
// Also remains orange after a republish
$p->Content = "new content";
$p->write();
$p->doPublish();
$this->fixVersionNumberCache($vp2);
$this->assertTrue($vp2->IsAddedToStage);
$this->assertTrue($vp2->getIsAddedToStage());
// VP is now published
$vp->doPublish();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->ExistsOnLive);
$this->assertFalse($vp->IsModifiedOnStage);
$this->assertTrue($vp->getExistsOnLive());
$this->assertFalse($vp->getIsModifiedOnStage());
// P edited, VP and P both go green
$p->Content = "third content";
$p->write();
$this->fixVersionNumberCache($vp, $p);
$this->assertTrue($p->IsModifiedOnStage);
$this->assertTrue($vp->IsModifiedOnStage);
$this->assertTrue($p->getIsModifiedOnStage());
$this->assertTrue($vp->getIsModifiedOnStage());
// Publish, VP goes black
$p->doPublish();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->ExistsOnLive);
$this->assertFalse($vp->IsModifiedOnStage);
$this->assertTrue($vp->getExistsOnLive());
$this->assertFalse($vp->getIsModifiedOnStage());
}
public function testVirtualPagesCreateVersionRecords() {