BUGFIX: Updated models to suit minor changes in the new ORM.

This commit is contained in:
Sam Minnee 2009-11-22 18:16:38 +13:00
parent 8fe9283181
commit 488a04c670
4 changed files with 21 additions and 12 deletions

View File

@ -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.
@ -1612,9 +1612,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) {
@ -1696,7 +1700,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) {

View File

@ -410,7 +410,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');
@ -432,7 +431,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);

View File

@ -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);

View File

@ -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();