Skip to content

Commit

Permalink
BUG Fix WasDraft not being written
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Mar 13, 2018
1 parent 35cff90 commit 0be2a9d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Versioned.php
Expand Up @@ -950,7 +950,6 @@ protected function augmentWriteVersioned(&$manipulation, $class, $table, $record
$nextVersion = $nextVersion ?: 1;

if ($class === $baseDataClass) {
$appliesToStages = is_array($stages) ? $stages : [$stages];
// Write AuthorID for baseclass
if ((Security::getCurrentUser())) {
$userID = Security::getCurrentUser()->ID;
Expand All @@ -962,8 +961,8 @@ protected function augmentWriteVersioned(&$manipulation, $class, $table, $record
[
'AuthorID' => $userID,
'PublisherID' => $userID,
'WasPublished' => (int)in_array(static::LIVE, $appliesToStages),
'WasDraft' => (int)in_array(static::DRAFT, $appliesToStages),
'WasPublished' => (int)in_array(static::LIVE, (array)$stages),
'WasDraft' => (int)in_array(static::DRAFT, (array)$stages),
'WasDeleted' => (int)$isDelete,
]
);
Expand Down Expand Up @@ -1079,14 +1078,11 @@ public function augmentWrite(&$manipulation)
// Putting a Version of -1 is a signal to leave the version table alone, despite their being no version
unset($manipulation[$table]['fields']['Version']);
} else {
$this->augmentWriteVersioned(
$manipulation,
$class,
$table,
$id,
[static::get_stage()],
false
);
// All writes are to draft, only live affect both
$stages = static::get_stage() === static::LIVE
? [self::DRAFT, self::LIVE]
: [self::DRAFT];
$this->augmentWriteVersioned($manipulation, $class, $table, $id, $stages, false);
}

// Remove "Version" column from subclasses of baseDataClass
Expand Down

0 comments on commit 0be2a9d

Please sign in to comment.