mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX: Updated models to suit minor changes in the new ORM.
This commit is contained in:
parent
2ef1ae397a
commit
d3ca4dac5b
@ -269,8 +269,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
);
|
||||
|
||||
/// Fall back on a unique URLSegment for b/c.
|
||||
if(!$sitetree && self::nested_urls() && $pages = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")) {
|
||||
return ($pages->Count() == 1) ? $pages->First() : null;
|
||||
if(!$sitetree && self::nested_urls() && $page = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")->First()) {
|
||||
return $page;
|
||||
}
|
||||
|
||||
// Attempt to grab an alternative page from extensions.
|
||||
@ -1622,9 +1622,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
if(is_callable('Subsite::disable_subsite_filter')) Subsite::disable_subsite_filter(true);
|
||||
|
||||
// Content links
|
||||
$items = $this->BackLinkTracking();
|
||||
if(!$items) $items = new DataObjectSet();
|
||||
else foreach($items as $item) $item->DependentLinkType = 'Content link';
|
||||
$items = new DataObjectSet();
|
||||
|
||||
// We merge all into a regular DataObjectSet, because DataList doesn't support merge
|
||||
if($contentLinks = $this->BackLinkTracking()) {
|
||||
foreach($contentLinks as $item) $item->DependentLinkType = 'Content link';
|
||||
$items->merge($contentLinks);
|
||||
}
|
||||
|
||||
// Virtual pages
|
||||
if($includeVirtuals) {
|
||||
@ -1706,7 +1710,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
|
||||
$parentPageLinks = array();
|
||||
|
||||
if(isset($linkedPages)) {
|
||||
if($linkedPages->Count() > 0) {
|
||||
foreach($linkedPages as $linkedPage) {
|
||||
$parentPage = $linkedPage->Parent;
|
||||
if($parentPage) {
|
||||
|
@ -411,7 +411,6 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
||||
|
||||
$siteconfig->CanViewType = 'OnlyTheseUsers';
|
||||
$siteconfig->ViewerGroups()->add($editorGroup);
|
||||
$siteconfig->ViewerGroups()->write();
|
||||
$siteconfig->write();
|
||||
$this->assertTrue($page->canView($editor), 'Editors can view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to OnlyTheseUsers');
|
||||
$this->assertFalse($page->canView(FALSE), 'Anonymous can\'t view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to OnlyTheseUsers');
|
||||
@ -433,7 +432,6 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
||||
|
||||
$siteconfig->CanEditType = 'OnlyTheseUsers';
|
||||
$siteconfig->EditorGroups()->add($editorGroup);
|
||||
$siteconfig->EditorGroups()->write();
|
||||
$siteconfig->write();
|
||||
$this->assertTrue($page->canEdit($editor), 'Editors can edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set to OnlyTheseUsers');
|
||||
$this->session()->inst_set('loggedInAs', null);
|
||||
|
@ -296,8 +296,8 @@ class SiteTreeTest extends SapphireTest {
|
||||
Versioned::reading_stage('Live');
|
||||
$deletedPage = Versioned::get_latest_version('SiteTree', $page2ID);
|
||||
$deletedPage->doRestoreToStage();
|
||||
$this->assertTrue(!Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID));
|
||||
|
||||
$this->assertFalse((bool)Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID));
|
||||
|
||||
Versioned::reading_stage('Stage');
|
||||
$requeriedPage = DataObject::get_by_id("Page", $page2ID);
|
||||
$this->assertEquals('Products', $requeriedPage->Title);
|
||||
@ -385,9 +385,16 @@ class SiteTreeTest extends SapphireTest {
|
||||
$pageStaffDuplicate->doPublish();
|
||||
|
||||
$parentPage = $this->objFromFixture('Page', 'about');
|
||||
|
||||
$parentPage->doDeleteFromLive();
|
||||
|
||||
Versioned::reading_stage('Live');
|
||||
|
||||
// Confirm that none of the given pages exist
|
||||
$this->assertEquals(array(), DataObject::get("Page")
|
||||
->byIDs(array($pageAbout->ID, $pageStaff->ID, $pageStaffDuplicate->ID))
|
||||
->column('URLSegment'));
|
||||
|
||||
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
|
||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
||||
|
@ -273,7 +273,7 @@ class VirtualPageTest extends SapphireTest {
|
||||
// Unpublish the source page, confirm that the virtual page has also been unpublished
|
||||
$p->doUnpublish();
|
||||
$vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
||||
$this->assertFalse($vpLive);
|
||||
$this->assertNull($vpLive);
|
||||
|
||||
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
||||
$p->delete();
|
||||
@ -307,7 +307,7 @@ class VirtualPageTest extends SapphireTest {
|
||||
$pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
|
||||
$this->assertTrue($pLive->doDeleteFromLive());
|
||||
$vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
||||
$this->assertFalse($vpLive);
|
||||
$this->assertNull($vpLive);
|
||||
|
||||
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
||||
$pLive->delete();
|
||||
|
Loading…
Reference in New Issue
Block a user