Permalink
Browse files

FIX: Remove version field from default scaffolded CMS fields.

  • Loading branch information...
1 parent 1bc945f commit f6cd582dd94e1f1010a9de6f96d01b0ac6ed6cfb @wilr wilr committed May 10, 2013
Showing with 36 additions and 1 deletion.
  1. +9 −0 model/Versioned.php
  2. +27 −1 tests/model/VersionedTest.php
View
@@ -1313,6 +1313,15 @@ public function updateFieldLabels(&$labels) {
$labels['Versions'] = _t('Versioned.has_many_Versions', 'Versions', 'Past Versions of this page');
}
+ /**
+ * @param FieldList
+ */
+ public function updateCMSFields(&$fields) {
+ // remove the version field from the CMS as this should be left
+ // entirely up to the extension (not the cms user).
+ $fields->removeByName('Version');
+ }
+
public function flushCache() {
self::$cache_versionnumber = array();
}
@@ -1,6 +1,11 @@
<?php
+/**
+ * @package framework
+ * @subpackage tests
+ */
class VersionedTest extends SapphireTest {
+
protected static $fixture_file = 'VersionedTest.yml';
protected $extraDataObjects = array(
@@ -124,6 +129,13 @@ public function testVersionedFieldsAdded() {
$this->assertInstanceOf('Int', $obj2->dbObject('Version'));
}
+ public function testVersionedFieldsNotInCMS() {
+ $obj = new VersionedTest_DataObject();
+
+ // the version field in cms causes issues with Versioned::augmentWrite()
+ $this->assertNull($obj->getCMSFields()->dataFieldByName('Version'));
+ }
+
public function testPublishCreateNewVersion() {
$page1 = $this->objFromFixture('VersionedTest_DataObject', 'page1');
$page1->Content = 'orig';
@@ -442,6 +454,11 @@ public function testArchiveRelatedDataWithoutVersioned() {
}
+
+/**
+ * @package framework
+ * @subpackage tests
+ */
class VersionedTest_DataObject extends DataObject implements TestOnly {
private static $db = array(
"Name" => "Varchar",
@@ -463,6 +480,10 @@ class VersionedTest_DataObject extends DataObject implements TestOnly {
}
+/**
+ * @package framework
+ * @subpackage tests
+ */
class VersionedTest_RelatedWithoutVersion extends DataObject implements TestOnly {
private static $db = array(
@@ -475,6 +496,10 @@ class VersionedTest_RelatedWithoutVersion extends DataObject implements TestOnly
}
+/**
+ * @package framework
+ * @subpackage tests
+ */
class VersionedTest_Subclass extends VersionedTest_DataObject implements TestOnly {
private static $db = array(
"ExtraField" => "Varchar",
@@ -486,7 +511,8 @@ class VersionedTest_Subclass extends VersionedTest_DataObject implements TestOnl
}
/**
- * @ignore
+ * @package framework
+ * @subpackage tests
*/
class VersionedTest_UnversionedWithField extends DataObject implements TestOnly {
private static $db = array('Version' => 'Varchar(255)');

3 comments on commit f6cd582

@tractorcow
Collaborator

I think that updateCMSFields(&$fields); should be updateCMSFields(FieldList $fields);, right?

@tractorcow
Collaborator

Fixed this at #1967 :)

@halkyon
Member

Hey @wilr, make sure your E_STRICT is enabled if you've overridden the framework error_reporting() :P

Please sign in to comment.