mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX SiteTree::DependentPages method returns non-SiteTree instance
This commit is contained in:
parent
14037a776f
commit
269eb5d70c
@ -2612,8 +2612,10 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
|
|
||||||
// Need to update pages linking to this one as no longer broken
|
// Need to update pages linking to this one as no longer broken
|
||||||
foreach ($stageSelf->DependentPages() as $page) {
|
foreach ($stageSelf->DependentPages() as $page) {
|
||||||
/** @var SiteTree $page */
|
if ($page->hasExtension(Versioned::class)) {
|
||||||
$page->writeWithoutVersion();
|
/** @var Versioned $page */
|
||||||
|
$page->writeWithoutVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ use SilverStripe\CMS\Model\VirtualPage;
|
|||||||
use SilverStripe\CMS\Tests\Controllers\SiteTreeTest_NamespaceMapTestController;
|
use SilverStripe\CMS\Tests\Controllers\SiteTreeTest_NamespaceMapTestController;
|
||||||
use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\BelongsToPage;
|
use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\BelongsToPage;
|
||||||
use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\PageWithChild;
|
use SilverStripe\CMS\Tests\CMSEditLinkExtensionTest\PageWithChild;
|
||||||
|
use SilverStripe\CMS\Tests\Model\SiteTreeBrokenLinksTest\NotPageObject;
|
||||||
use SilverStripe\CMS\Tests\Page\SiteTreeTest_NamespaceMapTest;
|
use SilverStripe\CMS\Tests\Page\SiteTreeTest_NamespaceMapTest;
|
||||||
use SilverStripe\Control\ContentNegotiator;
|
use SilverStripe\Control\ContentNegotiator;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
@ -69,6 +70,7 @@ class SiteTreeTest extends SapphireTest
|
|||||||
SiteTreeTest_DataObject::class,
|
SiteTreeTest_DataObject::class,
|
||||||
PageWithChild::class,
|
PageWithChild::class,
|
||||||
BelongsToPage::class,
|
BelongsToPage::class,
|
||||||
|
NotPageObject::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function reservedSegmentsProvider()
|
public function reservedSegmentsProvider()
|
||||||
@ -2119,4 +2121,23 @@ class SiteTreeTest extends SapphireTest
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOnAfterRevertToLive()
|
||||||
|
{
|
||||||
|
// Create new page and publish it
|
||||||
|
$page = SiteTree::create();
|
||||||
|
$page->Content = 'Test content';
|
||||||
|
$id = $page->write();
|
||||||
|
$page->publishRecursive();
|
||||||
|
|
||||||
|
// Add link to non-page object
|
||||||
|
/** @var NotPageObject $obj */
|
||||||
|
$obj = $this->objFromFixture(NotPageObject::class, 'object1');
|
||||||
|
$obj->Content = '<a href="[sitetree_link,id='. $id .']">Link to Page</a>';
|
||||||
|
$obj->write();
|
||||||
|
|
||||||
|
//Test that method doesn't throw exception
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
|
$page->onAfterRevertToLive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,3 +128,7 @@ SilverStripe\CMS\Tests\Model\SiteTreeTest_DataObject:
|
|||||||
relations:
|
relations:
|
||||||
Title: 'Linked DataObject'
|
Title: 'Linked DataObject'
|
||||||
Pages: =>Page.home,=>Page.about,=>Page.staff
|
Pages: =>Page.home,=>Page.about,=>Page.staff
|
||||||
|
|
||||||
|
SilverStripe\CMS\Tests\Model\SiteTreeBrokenLinksTest\NotPageObject:
|
||||||
|
object1:
|
||||||
|
Content: 'Everything will be ok'
|
||||||
|
Loading…
Reference in New Issue
Block a user