mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #4463: Set AuthorID and PublisherID correctly
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@85086 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e3d31f1bdd
commit
e4ca69dc3f
@ -309,7 +309,7 @@ class Versioned extends DataObjectDecorator {
|
||||
foreach($tables as $table) {
|
||||
$baseDataClass = ClassInfo::baseDataClass($table);
|
||||
|
||||
$isRootClass = ($this->owner->class == ClassInfo::baseDataClass($this->owner->class));
|
||||
$isRootClass = ($table == $baseDataClass);
|
||||
|
||||
// Make sure that the augmented write is being applied to a table that can be versioned
|
||||
if( !$this->canBeVersioned($table) ) {
|
||||
|
@ -305,6 +305,38 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->assertFalse($product4->canEdit($editor));
|
||||
}
|
||||
|
||||
function testAuthorIDAndPublisherIDFilledOutOnPublish() {
|
||||
// Ensure that we have a member ID who is doing all this work
|
||||
$member = Member::currentUser();
|
||||
if($member) {
|
||||
$memberID = $member->ID;
|
||||
} else {
|
||||
$memberID = $this->idFromFixture("Member", "admin");
|
||||
Session::set("loggedInAs", $memberID);
|
||||
}
|
||||
|
||||
// Write the page
|
||||
$about = $this->objFromFixture('Page','about');
|
||||
$about->Title = "Another title";
|
||||
$about->write();
|
||||
|
||||
// Check the version created
|
||||
$savedVersion = DB::query("SELECT AuthorID, PublisherID FROM SiteTree_versions
|
||||
WHERE RecordID = $about->ID ORDER BY Version DESC LIMIT 1")->record();
|
||||
$this->assertEquals($memberID, $savedVersion['AuthorID']);
|
||||
$this->assertEquals(0, $savedVersion['PublisherID']);
|
||||
|
||||
// Publish the page
|
||||
$about->doPublish();
|
||||
$publishedVersion = DB::query("SELECT AuthorID, PublisherID FROM SiteTree_versions
|
||||
WHERE RecordID = $about->ID ORDER BY Version DESC LIMIT 1")->record();
|
||||
|
||||
// Check the version created
|
||||
$this->assertEquals($memberID, $publishedVersion['AuthorID']);
|
||||
$this->assertEquals($memberID, $publishedVersion['PublisherID']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We make these extend page since that's what all page types are expected to do
|
||||
|
Loading…
Reference in New Issue
Block a user