mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fixed Versioned::get_latest_version when called on live site (parents upgrade issue)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45104 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0d5b5b36de
commit
0c04f14f37
@ -466,7 +466,7 @@ class Versioned extends DataObjectDecorator {
|
||||
$fields = array_keys($fromRecord->getAllFields());
|
||||
|
||||
foreach($fields as $field) {
|
||||
if(in_array($field, array("ID","Version","RecordID","AuthorID"))) continue;
|
||||
if(in_array($field, array("ID","Version","RecordID","AuthorID", "ParentID"))) continue;
|
||||
|
||||
$fromRecord->$field = Diff::compareHTML($fromRecord->$field, $toRecord->$field);
|
||||
}
|
||||
@ -623,6 +623,9 @@ class Versioned extends DataObjectDecorator {
|
||||
* Return the latest version of the given page
|
||||
*/
|
||||
static function get_latest_version($class, $id) {
|
||||
$oldStage = Versioned::$reading_stage;
|
||||
Versioned::$reading_stage = null;
|
||||
|
||||
$baseTable = ClassInfo::baseDataClass($class);
|
||||
$query = singleton($class)->buildVersionSQL("`{$baseTable}`.RecordID = $id", "`{$baseTable}`.Version DESC");
|
||||
$query->limit = 1;
|
||||
@ -633,6 +636,9 @@ class Versioned extends DataObjectDecorator {
|
||||
Debug::show($record);
|
||||
user_error("Versioned::get_version: Couldn't get $class.$id, version $version", E_USER_ERROR);
|
||||
}
|
||||
|
||||
Versioned::$reading_stage = $oldStage;
|
||||
|
||||
return new $className($record);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user