mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Ensure that Versioned works on classes with underscores in the names. (from r100905)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101153 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
f3a666b89f
commit
f2bb6baa9f
@ -410,9 +410,13 @@ class Versioned extends DataObjectDecorator {
|
||||
* @return boolean Returns false if the field isn't in the table, true otherwise
|
||||
*/
|
||||
function hasVersionField($table) {
|
||||
|
||||
$tableParts = explode('_',$table);
|
||||
return ('DataObject' == get_parent_class($tableParts[0]));
|
||||
$rPos = strrpos($table,'_');
|
||||
if(($rPos !== false) && in_array(substr($table,$rPos), $this->stages)) {
|
||||
$tableWithoutStage = substr($table,0,$rPos);
|
||||
} else {
|
||||
$tableWithoutStage = $table;
|
||||
}
|
||||
return ('DataObject' == get_parent_class($tableWithoutStage));
|
||||
}
|
||||
function extendWithSuffix($table) {
|
||||
foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
|
||||
|
@ -8,13 +8,16 @@ class VersionedTest extends SapphireTest {
|
||||
);
|
||||
|
||||
function testForceChangeUpdatesVersion() {
|
||||
$page = $this->objFromFixture('Page', 'page3');
|
||||
$oldVersion = $page->Version;
|
||||
$page->forceChange();
|
||||
$page->write();
|
||||
$obj = new VersionedTest_DataObject();
|
||||
$obj->Name = "test";
|
||||
$obj->write();
|
||||
|
||||
$oldVersion = $obj->Version;
|
||||
$obj->forceChange();
|
||||
$obj->write();
|
||||
|
||||
$this->assertTrue(
|
||||
($page->Version > $oldVersion),
|
||||
($obj->Version > $oldVersion),
|
||||
"A object Version is increased when just calling forceChange() without any other changes"
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user