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:
Sam Minnee 2009-08-24 07:35:05 +00:00
parent e3d31f1bdd
commit e4ca69dc3f
2 changed files with 33 additions and 1 deletions

View File

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

View File

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