mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1211 from stevie-mayhew/pulls/get-calls
FIX: explicitly call get functions for site tree checks
This commit is contained in:
commit
9fcda11969
@ -100,7 +100,6 @@ class CMSBatchAction_Delete extends CMSBatchAction {
|
|||||||
'"SiteTree"."ID"' => $id
|
'"SiteTree"."ID"' => $id
|
||||||
));
|
));
|
||||||
if($liveRecord) {
|
if($liveRecord) {
|
||||||
$liveRecord->IsDeletedFromStage = true;
|
|
||||||
$status['modified'][$liveRecord->ID] = array(
|
$status['modified'][$liveRecord->ID] = array(
|
||||||
'TreeTitle' => $liveRecord->TreeTitle,
|
'TreeTitle' => $liveRecord->TreeTitle,
|
||||||
);
|
);
|
||||||
@ -148,7 +147,6 @@ class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
|
|||||||
'"SiteTree"."ID"' => $id
|
'"SiteTree"."ID"' => $id
|
||||||
));
|
));
|
||||||
if($stageRecord) {
|
if($stageRecord) {
|
||||||
$stageRecord->IsAddedToStage = true;
|
|
||||||
$status['modified'][$stageRecord->ID] = array(
|
$status['modified'][$stageRecord->ID] = array(
|
||||||
'TreeTitle' => $stageRecord->TreeTitle,
|
'TreeTitle' => $stageRecord->TreeTitle,
|
||||||
);
|
);
|
||||||
|
@ -601,8 +601,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$actions = $form->Actions();
|
$actions = $form->Actions();
|
||||||
|
|
||||||
if($record) {
|
if($record) {
|
||||||
$deletedFromStage = $record->IsDeletedFromStage;
|
$deletedFromStage = $record->getIsDeletedFromStage();
|
||||||
$deleteFromLive = !$record->ExistsOnLive;
|
$deleteFromLive = !$record->getExistsOnLive();
|
||||||
|
|
||||||
$fields->push($idField = new HiddenField("ID", false, $id));
|
$fields->push($idField = new HiddenField("ID", false, $id));
|
||||||
// Necessary for different subsites
|
// Necessary for different subsites
|
||||||
|
@ -259,7 +259,7 @@ class CMSSIteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
|
|||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
return $page->ExistsOnLive;
|
return $page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
|||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
// If page is removed from stage but not live
|
// If page is removed from stage but not live
|
||||||
return $page->IsDeletedFromStage && $page->ExistsOnLive;
|
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
|||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
// If page exists on stage but not on live
|
// If page exists on stage but not on live
|
||||||
return (!$page->IsDeletedFromStage && $page->IsAddedToStage);
|
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
|
||||||
});
|
});
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
|||||||
|
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
// Doesn't exist on either stage or live
|
// Doesn't exist on either stage or live
|
||||||
return $page->IsDeletedFromStage && !$page->ExistsOnLive;
|
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
|
@ -2275,7 +2275,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage && $this->canDeleteFromLive()) {
|
if($this->isPublished() && $this->canPublish() && !$this->getIsDeletedFromStage() && $this->canDeleteFromLive()) {
|
||||||
// "unpublish"
|
// "unpublish"
|
||||||
$moreOptions->push(
|
$moreOptions->push(
|
||||||
FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')
|
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()) {
|
if($this->isPublished() && $this->canEdit()) {
|
||||||
// "rollback"
|
// "rollback"
|
||||||
$moreOptions->push(
|
$moreOptions->push(
|
||||||
@ -2295,7 +2295,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->canEdit()) {
|
if($this->canEdit()) {
|
||||||
if($this->IsDeletedFromStage) {
|
if($this->getIsDeletedFromStage()) {
|
||||||
// The usual major actions are not available, so we provide alternatives here.
|
// The usual major actions are not available, so we provide alternatives here.
|
||||||
if($existsOnLive) {
|
if($existsOnLive) {
|
||||||
// "restore"
|
// "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.
|
// "publish", as with "save", it supports an alternate state to show when action is needed.
|
||||||
$majorActions->push(
|
$majorActions->push(
|
||||||
$publish = FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))
|
$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) {
|
if($linkedPages) foreach($linkedPages as $page) {
|
||||||
$page->copyFrom($page->CopyContentFrom());
|
$page->copyFrom($page->CopyContentFrom());
|
||||||
$page->write();
|
$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
|
// 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) {
|
public function getStatusFlags($cached = true) {
|
||||||
if(!$this->_cache_statusFlags || !$cached) {
|
if(!$this->_cache_statusFlags || !$cached) {
|
||||||
$flags = array();
|
$flags = array();
|
||||||
if($this->IsDeletedFromStage) {
|
if($this->getIsDeletedFromStage()) {
|
||||||
if($this->ExistsOnLive) {
|
if($this->getExistsOnLive()) {
|
||||||
$flags['removedfromdraft'] = array(
|
$flags['removedfromdraft'] = array(
|
||||||
'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'),
|
'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'),
|
||||||
'title' => _t('SiteTree.REMOVEDFROMDRAFTHELP', 'Page is published, but has been deleted 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'),
|
'title' => _t('SiteTree.ARCHIVEDPAGEHELP', 'Page is removed from draft and live'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if($this->IsAddedToStage) {
|
} else if($this->getIsAddedToStage()) {
|
||||||
$flags['addedtodraft'] = array(
|
$flags['addedtodraft'] = array(
|
||||||
'text' => _t('SiteTree.ADDEDTODRAFTSHORT', 'Draft'),
|
'text' => _t('SiteTree.ADDEDTODRAFTSHORT', 'Draft'),
|
||||||
'title' => _t('SiteTree.ADDEDTODRAFTHELP', "Page has not been published yet")
|
'title' => _t('SiteTree.ADDEDTODRAFTHELP', "Page has not been published yet")
|
||||||
);
|
);
|
||||||
} else if($this->IsModifiedOnStage) {
|
} else if($this->getIsModifiedOnStage()) {
|
||||||
$flags['modified'] = array(
|
$flags['modified'] = array(
|
||||||
'text' => _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified'),
|
'text' => _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified'),
|
||||||
'title' => _t('SiteTree.MODIFIEDONDRAFTHELP', 'Page has unpublished changes'),
|
'title' => _t('SiteTree.MODIFIEDONDRAFTHELP', 'Page has unpublished changes'),
|
||||||
|
@ -71,7 +71,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
|||||||
// Publish the source page
|
// Publish the source page
|
||||||
$page = $this->objFromFixture('Page', 'page1');
|
$page = $this->objFromFixture('Page', 'page1');
|
||||||
$this->assertTrue($page->doPublish());
|
$this->assertTrue($page->doPublish());
|
||||||
$this->assertFalse($page->IsModifiedOnStage);
|
$this->assertFalse($page->getIsModifiedOnStage());
|
||||||
|
|
||||||
// Rename the file
|
// Rename the file
|
||||||
$file = $this->objFromFixture('File', 'file1');
|
$file = $this->objFromFixture('File', 'file1');
|
||||||
@ -83,7 +83,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
|||||||
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID));
|
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID));
|
||||||
|
|
||||||
// Confirm that the page hasn't gone green.
|
// Confirm that the page hasn't gone green.
|
||||||
$this->assertFalse($page->IsModifiedOnStage);
|
$this->assertFalse($page->getIsModifiedOnStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTwoFileRenamesInARowWork() {
|
public function testTwoFileRenamesInARowWork() {
|
||||||
|
@ -194,17 +194,17 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
// newly created page
|
// newly created page
|
||||||
$createdPage = new SiteTree();
|
$createdPage = new SiteTree();
|
||||||
$createdPage->write();
|
$createdPage->write();
|
||||||
$this->assertFalse($createdPage->IsDeletedFromStage);
|
$this->assertFalse($createdPage->getIsDeletedFromStage());
|
||||||
$this->assertTrue($createdPage->IsAddedToStage);
|
$this->assertTrue($createdPage->getIsAddedToStage());
|
||||||
$this->assertTrue($createdPage->IsModifiedOnStage);
|
$this->assertTrue($createdPage->getIsModifiedOnStage());
|
||||||
|
|
||||||
// published page
|
// published page
|
||||||
$publishedPage = new SiteTree();
|
$publishedPage = new SiteTree();
|
||||||
$publishedPage->write();
|
$publishedPage->write();
|
||||||
$publishedPage->publish('Stage','Live');
|
$publishedPage->publish('Stage','Live');
|
||||||
$this->assertFalse($publishedPage->IsDeletedFromStage);
|
$this->assertFalse($publishedPage->getIsDeletedFromStage());
|
||||||
$this->assertFalse($publishedPage->IsAddedToStage);
|
$this->assertFalse($publishedPage->getIsAddedToStage());
|
||||||
$this->assertFalse($publishedPage->IsModifiedOnStage);
|
$this->assertFalse($publishedPage->getIsModifiedOnStage());
|
||||||
|
|
||||||
// published page, deleted from stage
|
// published page, deleted from stage
|
||||||
$deletedFromDraftPage = new SiteTree();
|
$deletedFromDraftPage = new SiteTree();
|
||||||
@ -212,9 +212,9 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$deletedFromDraftPageID = $deletedFromDraftPage->ID;
|
$deletedFromDraftPageID = $deletedFromDraftPage->ID;
|
||||||
$deletedFromDraftPage->publish('Stage','Live');
|
$deletedFromDraftPage->publish('Stage','Live');
|
||||||
$deletedFromDraftPage->deleteFromStage('Stage');
|
$deletedFromDraftPage->deleteFromStage('Stage');
|
||||||
$this->assertTrue($deletedFromDraftPage->IsDeletedFromStage);
|
$this->assertTrue($deletedFromDraftPage->getIsDeletedFromStage());
|
||||||
$this->assertFalse($deletedFromDraftPage->IsAddedToStage);
|
$this->assertFalse($deletedFromDraftPage->getIsAddedToStage());
|
||||||
$this->assertFalse($deletedFromDraftPage->IsModifiedOnStage);
|
$this->assertFalse($deletedFromDraftPage->getIsModifiedOnStage());
|
||||||
|
|
||||||
// published page, deleted from live
|
// published page, deleted from live
|
||||||
$deletedFromLivePage = new SiteTree();
|
$deletedFromLivePage = new SiteTree();
|
||||||
@ -222,9 +222,9 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$deletedFromLivePage->publish('Stage','Live');
|
$deletedFromLivePage->publish('Stage','Live');
|
||||||
$deletedFromLivePage->deleteFromStage('Stage');
|
$deletedFromLivePage->deleteFromStage('Stage');
|
||||||
$deletedFromLivePage->deleteFromStage('Live');
|
$deletedFromLivePage->deleteFromStage('Live');
|
||||||
$this->assertTrue($deletedFromLivePage->IsDeletedFromStage);
|
$this->assertTrue($deletedFromLivePage->getIsDeletedFromStage());
|
||||||
$this->assertFalse($deletedFromLivePage->IsAddedToStage);
|
$this->assertFalse($deletedFromLivePage->getIsAddedToStage());
|
||||||
$this->assertFalse($deletedFromLivePage->IsModifiedOnStage);
|
$this->assertFalse($deletedFromLivePage->getIsModifiedOnStage());
|
||||||
|
|
||||||
// published page, modified
|
// published page, modified
|
||||||
$modifiedOnDraftPage = new SiteTree();
|
$modifiedOnDraftPage = new SiteTree();
|
||||||
@ -232,9 +232,9 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$modifiedOnDraftPage->publish('Stage','Live');
|
$modifiedOnDraftPage->publish('Stage','Live');
|
||||||
$modifiedOnDraftPage->Content = 'modified';
|
$modifiedOnDraftPage->Content = 'modified';
|
||||||
$modifiedOnDraftPage->write();
|
$modifiedOnDraftPage->write();
|
||||||
$this->assertFalse($modifiedOnDraftPage->IsDeletedFromStage);
|
$this->assertFalse($modifiedOnDraftPage->getIsDeletedFromStage());
|
||||||
$this->assertFalse($modifiedOnDraftPage->IsAddedToStage);
|
$this->assertFalse($modifiedOnDraftPage->getIsAddedToStage());
|
||||||
$this->assertTrue($modifiedOnDraftPage->IsModifiedOnStage);
|
$this->assertTrue($modifiedOnDraftPage->getIsModifiedOnStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,46 +209,46 @@ class VirtualPageTest extends SapphireTest {
|
|||||||
$vp->write();
|
$vp->write();
|
||||||
|
|
||||||
// VP is oragne
|
// VP is oragne
|
||||||
$this->assertTrue($vp->IsAddedToStage);
|
$this->assertTrue($vp->getIsAddedToStage());
|
||||||
|
|
||||||
// VP is still orange after we publish
|
// VP is still orange after we publish
|
||||||
$p->doPublish();
|
$p->doPublish();
|
||||||
$this->fixVersionNumberCache($vp);
|
$this->fixVersionNumberCache($vp);
|
||||||
$this->assertTrue($vp->IsAddedToStage);
|
$this->assertTrue($vp->getIsAddedToStage());
|
||||||
|
|
||||||
// A new VP created after P's initial construction
|
// A new VP created after P's initial construction
|
||||||
$vp2 = new VirtualPage();
|
$vp2 = new VirtualPage();
|
||||||
$vp2->CopyContentFromID = $p->ID;
|
$vp2->CopyContentFromID = $p->ID;
|
||||||
$vp2->write();
|
$vp2->write();
|
||||||
$this->assertTrue($vp2->IsAddedToStage);
|
$this->assertTrue($vp2->getIsAddedToStage());
|
||||||
|
|
||||||
// Also remains orange after a republish
|
// Also remains orange after a republish
|
||||||
$p->Content = "new content";
|
$p->Content = "new content";
|
||||||
$p->write();
|
$p->write();
|
||||||
$p->doPublish();
|
$p->doPublish();
|
||||||
$this->fixVersionNumberCache($vp2);
|
$this->fixVersionNumberCache($vp2);
|
||||||
$this->assertTrue($vp2->IsAddedToStage);
|
$this->assertTrue($vp2->getIsAddedToStage());
|
||||||
|
|
||||||
// VP is now published
|
// VP is now published
|
||||||
$vp->doPublish();
|
$vp->doPublish();
|
||||||
|
|
||||||
$this->fixVersionNumberCache($vp);
|
$this->fixVersionNumberCache($vp);
|
||||||
$this->assertTrue($vp->ExistsOnLive);
|
$this->assertTrue($vp->getExistsOnLive());
|
||||||
$this->assertFalse($vp->IsModifiedOnStage);
|
$this->assertFalse($vp->getIsModifiedOnStage());
|
||||||
|
|
||||||
// P edited, VP and P both go green
|
// P edited, VP and P both go green
|
||||||
$p->Content = "third content";
|
$p->Content = "third content";
|
||||||
$p->write();
|
$p->write();
|
||||||
|
|
||||||
$this->fixVersionNumberCache($vp, $p);
|
$this->fixVersionNumberCache($vp, $p);
|
||||||
$this->assertTrue($p->IsModifiedOnStage);
|
$this->assertTrue($p->getIsModifiedOnStage());
|
||||||
$this->assertTrue($vp->IsModifiedOnStage);
|
$this->assertTrue($vp->getIsModifiedOnStage());
|
||||||
|
|
||||||
// Publish, VP goes black
|
// Publish, VP goes black
|
||||||
$p->doPublish();
|
$p->doPublish();
|
||||||
$this->fixVersionNumberCache($vp);
|
$this->fixVersionNumberCache($vp);
|
||||||
$this->assertTrue($vp->ExistsOnLive);
|
$this->assertTrue($vp->getExistsOnLive());
|
||||||
$this->assertFalse($vp->IsModifiedOnStage);
|
$this->assertFalse($vp->getIsModifiedOnStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testVirtualPagesCreateVersionRecords() {
|
public function testVirtualPagesCreateVersionRecords() {
|
||||||
|
Loading…
Reference in New Issue
Block a user