Code Duplication    Length = 9-10 lines in 2 locations

model/Versioned.php 2 locations

@@ 837-845 (lines=9) @@
834
	 * @param Member $member
835
	 * @return bool
836
	 */
837
	public function canViewStage($stage = 'Live', $member = null) {
838
		$oldMode = Versioned::get_reading_mode();
839
		Versioned::reading_stage($stage);
840
841
		$versionFromStage = DataObject::get($this->owner->class)->byID($this->owner->ID);
842
843
		Versioned::set_reading_mode($oldMode);
844
		return $versionFromStage ? $versionFromStage->canView($member) : false;
845
	}
846
847
	/**
848
	 * Determine if a table supports the Versioned extensions (e.g. $table_versions does exists).
@@ 1400-1409 (lines=10) @@
1397
	 * @param bool   $forceInsert Whether to force an INSERT query over an UPDATE query
1398
	 * @return int The ID of the item being written
1399
	 */
1400
	public function writeToStage($stage, $forceInsert = false) {
1401
		$oldMode = Versioned::get_reading_mode();
1402
		Versioned::reading_stage($stage);
1403
1404
		$this->owner->forceChange();
1405
		$result = $this->owner->write(false, $forceInsert);
1406
		Versioned::set_reading_mode($oldMode);
1407
1408
		return $result;
1409
	}
1410
1411
	/**
1412
	 * Roll the draft version of this object to match the published one.