mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Versioned::get_version() didn't work if you were on the live site
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45079 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d80432972d
commit
ef5aabf666
@ -637,6 +637,9 @@ class Versioned extends DataObjectDecorator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function get_version($class, $id, $version) {
|
static function get_version($class, $id, $version) {
|
||||||
|
$oldStage = Versioned::$reading_stage;
|
||||||
|
Versioned::$reading_stage = null;
|
||||||
|
|
||||||
$baseTable = ClassInfo::baseDataClass($class);
|
$baseTable = ClassInfo::baseDataClass($class);
|
||||||
$query = singleton($class)->buildVersionSQL("`{$baseTable}`.RecordID = $id AND `{$baseTable}`.Version = $version");
|
$query = singleton($class)->buildVersionSQL("`{$baseTable}`.RecordID = $id AND `{$baseTable}`.Version = $version");
|
||||||
$record = $query->execute()->record();
|
$record = $query->execute()->record();
|
||||||
@ -646,6 +649,9 @@ class Versioned extends DataObjectDecorator {
|
|||||||
Debug::show($record);
|
Debug::show($record);
|
||||||
user_error("Versioned::get_version: Couldn't get $class.$id, version $version", E_USER_ERROR);
|
user_error("Versioned::get_version: Couldn't get $class.$id, version $version", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Versioned::$reading_stage = $oldStage;
|
||||||
|
|
||||||
return new $className($record);
|
return new $className($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user