mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
Merge pull request #51 from open-sausages/pulls/fix-phantom-draft-changes
BUG Prevent non-real draft changes forcing record to appear as changed when saved
This commit is contained in:
commit
25c0556499
@ -257,7 +257,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
$member = Member::currentUser();
|
$member = Member::currentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
return $member->FirstName . " " . $member->Surname;
|
return $member->getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -478,8 +478,12 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function onBeforeWrite()
|
public function onBeforeWrite()
|
||||||
{
|
{
|
||||||
$this->owner->LastEditedByName = $this->owner->getEditorName();
|
// Only update if DB fields have been changed
|
||||||
$this->owner->OwnerNames = $this->owner->getOwnerNames();
|
$changedFields = $this->owner->getChangedFields(true, 2);
|
||||||
|
if($changedFields) {
|
||||||
|
$this->owner->LastEditedByName = $this->owner->getEditorName();
|
||||||
|
$this->owner->OwnerNames = $this->owner->getOwnerNames();
|
||||||
|
}
|
||||||
|
|
||||||
// If the user changed the type, we need to recalculate the review date.
|
// If the user changed the type, we need to recalculate the review date.
|
||||||
if ($this->owner->isChanged("ContentReviewType", 2)) {
|
if ($this->owner->isChanged("ContentReviewType", 2)) {
|
||||||
@ -504,7 +508,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parent page change it's review period
|
// parent page change its review period
|
||||||
// && !$this->owner->isChanged('ContentReviewType', 2)
|
// && !$this->owner->isChanged('ContentReviewType', 2)
|
||||||
if ($this->owner->isChanged("ReviewPeriodDays", 2)) {
|
if ($this->owner->isChanged("ReviewPeriodDays", 2)) {
|
||||||
$nextReviewUnixSec = strtotime(" + " . $this->owner->ReviewPeriodDays . " days", SS_Datetime::now()->format("U"));
|
$nextReviewUnixSec = strtotime(" + " . $this->owner->ReviewPeriodDays . " days", SS_Datetime::now()->format("U"));
|
||||||
|
@ -244,6 +244,38 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
|
|||||||
SS_Datetime::clear_mock_now();
|
SS_Datetime::clear_mock_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUnModifiedPagesDontChangeEditor() {
|
||||||
|
SS_Datetime::set_mock_now("2013-03-01 12:00:00");
|
||||||
|
|
||||||
|
/** @var Member $author */
|
||||||
|
$author = $this->objFromFixture("Member", "author");
|
||||||
|
$this->logInAs($author);
|
||||||
|
|
||||||
|
// Page which is un-modified doesn't advance version of have an editor assigned
|
||||||
|
$contactPage = $this->objFromFixture("Page", "contact");
|
||||||
|
$contactPageVersion = $contactPage->Version;
|
||||||
|
$contactPage->write();
|
||||||
|
$this->assertEmpty($contactPage->LastEditedByName);
|
||||||
|
$this->assertEquals(
|
||||||
|
$contactPageVersion,
|
||||||
|
Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $contactPage->ID, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Page with modifications gets marked
|
||||||
|
$homePage = $this->objFromFixture("Page", "home");
|
||||||
|
$homePageVersion = $homePage->Version;
|
||||||
|
$homePage->Content = '<p>Welcome!</p>';
|
||||||
|
$homePage->write();
|
||||||
|
$this->assertNotEmpty($homePage->LastEditedByName);
|
||||||
|
$this->assertEquals($author->getTitle(), $homePage->LastEditedByName);
|
||||||
|
$this->assertGreaterThan(
|
||||||
|
$homePageVersion,
|
||||||
|
Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $homePage->ID, false)
|
||||||
|
);
|
||||||
|
|
||||||
|
SS_Datetime::clear_mock_now();
|
||||||
|
}
|
||||||
|
|
||||||
public function testReviewActionVisibleForAuthor()
|
public function testReviewActionVisibleForAuthor()
|
||||||
{
|
{
|
||||||
SS_Datetime::set_mock_now("2020-03-01 12:00:00");
|
SS_Datetime::set_mock_now("2020-03-01 12:00:00");
|
||||||
|
Loading…
Reference in New Issue
Block a user