From 95d37b282d0a08918c96a351243d47ac116e46b2 Mon Sep 17 00:00:00 2001 From: Dylan Wagstaff Date: Wed, 11 Apr 2018 14:10:55 +1200 Subject: [PATCH 1/4] Revert "fix page history: remove DMSSiteTreeExtension.getDocumentSets()" --- code/DMS.php | 2 +- code/extensions/DMSSiteTreeExtension.php | 7 ++----- templates/Includes/DocumentSets.ss | 4 ++-- tests/DMSDocumentSetTest.php | 6 +++--- tests/DMSEmbargoTest.php | 2 +- tests/tasks/MigrateToDocumentSetsTaskTest.php | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/code/DMS.php b/code/DMS.php index 46950a0..887e877 100644 --- a/code/DMS.php +++ b/code/DMS.php @@ -151,7 +151,7 @@ class DMS extends Object implements DMSInterface public function getDocumentSetsByPage(SiteTree $page) { - return $page->DocumentSets(); + return $page->getDocumentSets(); } /** diff --git a/code/extensions/DMSSiteTreeExtension.php b/code/extensions/DMSSiteTreeExtension.php index a6f6959..abeb7de 100644 --- a/code/extensions/DMSSiteTreeExtension.php +++ b/code/extensions/DMSSiteTreeExtension.php @@ -55,14 +55,11 @@ class DMSSiteTreeExtension extends DataExtension /** * Get a list of document sets for the owner page * - * @deprecated 3.0 Use DocumentSets() instead. - * * @return ArrayList */ public function getDocumentSets() { - Deprecation::notice('3.0', 'Use DocumentSets() instead'); - return $this->owner->hasManyComponent('DocumentSets'); + return $this->owner->DocumentSets(); } /** @@ -74,7 +71,7 @@ class DMSSiteTreeExtension extends DataExtension { $documents = ArrayList::create(); - foreach ($this->owner->DocumentSets() as $documentSet) { + foreach ($this->getDocumentSets() as $documentSet) { /** @var DocumentSet $documentSet */ $documents->merge($documentSet->getDocuments()); } diff --git a/templates/Includes/DocumentSets.ss b/templates/Includes/DocumentSets.ss index 3998fa8..632fb29 100644 --- a/templates/Includes/DocumentSets.ss +++ b/templates/Includes/DocumentSets.ss @@ -1,6 +1,6 @@ -<% if $DocumentSets %> +<% if $getDocumentSets %>
- <% loop $DocumentSets %> + <% loop $getDocumentSets %> <% include DocumentSet %> <% end_loop %>
diff --git a/tests/DMSDocumentSetTest.php b/tests/DMSDocumentSetTest.php index f1bdac4..c088618 100644 --- a/tests/DMSDocumentSetTest.php +++ b/tests/DMSDocumentSetTest.php @@ -50,9 +50,9 @@ class DMSDocumentSetTest extends SapphireTest $ds2 = $this->objFromFixture('DMSDocumentSet', 'ds2'); $ds3 = $this->objFromFixture('DMSDocumentSet', 'ds3'); - $this->assertCount(0, $s4->DocumentSets(), 'Page 4 has no document sets associated'); - $this->assertCount(2, $s1->DocumentSets(), 'Page 1 has 2 document sets'); - $this->assertEquals(array($ds1->ID, $ds2->ID), $s1->DocumentSets()->column('ID')); + $this->assertCount(0, $s4->getDocumentSets(), 'Page 4 has no document sets associated'); + $this->assertCount(2, $s1->getDocumentSets(), 'Page 1 has 2 document sets'); + $this->assertEquals(array($ds1->ID, $ds2->ID), $s1->getDocumentSets()->column('ID')); } /** diff --git a/tests/DMSEmbargoTest.php b/tests/DMSEmbargoTest.php index 54ca2a7..bd5faed 100644 --- a/tests/DMSEmbargoTest.php +++ b/tests/DMSEmbargoTest.php @@ -142,7 +142,7 @@ class DMSEmbargoTest extends SapphireTest $doc->Folder = "0"; $dID = $doc->write(); - $s1->DocumentSets()->first()->getDocuments()->add($doc); + $s1->getDocumentSets()->first()->getDocuments()->add($doc); $s1->publish('Stage', 'Live'); $s1->doPublish(); diff --git a/tests/tasks/MigrateToDocumentSetsTaskTest.php b/tests/tasks/MigrateToDocumentSetsTaskTest.php index d58ea16..de26945 100644 --- a/tests/tasks/MigrateToDocumentSetsTaskTest.php +++ b/tests/tasks/MigrateToDocumentSetsTaskTest.php @@ -65,9 +65,9 @@ class MigrateToDocumentSetsTaskTest extends SapphireTest $this->assertContains('Skipped: already has a set: 1', $result); // Test that some of the relationship records were written correctly - $this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->DocumentSets()); + $this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->getDocumentSets()); $this->assertSame('Default', $firstPageSets->first()->Title); - $this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->DocumentSets()); + $this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->getDocumentSets()); // With dryrun enabled and being run the second time, nothing should be done $result = $this->runTask(array('action' => 'create-default-document-set', 'dryrun' => '1')); From 42275f5d13ad47ed7e4a51e622d2aac2a6f43c97 Mon Sep 17 00:00:00 2001 From: James Ayers Date: Mon, 20 Aug 2018 20:23:14 +1200 Subject: [PATCH 2/4] =?UTF-8?q?FIX:=20Escape=20double=20quotes=20so=20Fiel?= =?UTF-8?q?d=20can=20be=20safely=20eval()=E2=80=99d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/model/DMSDocument.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/model/DMSDocument.php b/code/model/DMSDocument.php index bafe0d2..0c057c9 100644 --- a/code/model/DMSDocument.php +++ b/code/model/DMSDocument.php @@ -820,12 +820,12 @@ class DMSDocument extends DataObject implements DMSDocumentInterface new GridFieldDataColumns(), new GridFieldPaginator(30) ); + $versionsGridFieldConfig->getComponentByType('GridFieldDataColumns') ->setDisplayFields(Config::inst()->get('DMSDocument_versions', 'display_fields')) ->setFieldFormatting( array( - 'FilenameWithoutID' => '' - . '$FilenameWithoutID' + 'FilenameWithoutID' => '$FilenameWithoutID' ) ); From 209737c4b6e7212e1a8b6654e84d0e5979218e73 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 12 Dec 2019 17:30:11 +1300 Subject: [PATCH 3/4] Change date on unit test --- tests/DMSEmbargoTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/DMSEmbargoTest.php b/tests/DMSEmbargoTest.php index bd5faed..484444f 100644 --- a/tests/DMSEmbargoTest.php +++ b/tests/DMSEmbargoTest.php @@ -73,7 +73,7 @@ class DMSEmbargoTest extends SapphireTest $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); $this->assertTrue($doc->isExpired(), "Document is expired"); - $expireTime = "2019-04-05 11:43:13"; + $expireTime = "2069-12-12 17:10:13"; $doc->expireAtDate($expireTime); $this->assertFalse($doc->isHidden(), "Document is not hidden"); $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); @@ -114,7 +114,7 @@ class DMSEmbargoTest extends SapphireTest $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); - $embargoTime = "2019-04-05 11:43:13"; + $embargoTime = "2069-12-12 17:10:13"; $doc->embargoUntilDate($embargoTime); $this->assertTrue($doc->isHidden(), "Document is hidden"); $this->assertTrue($doc->isEmbargoed(), "Document is embargoed"); From 402dc77ed643b7a742809c8e9430e919abaed6e7 Mon Sep 17 00:00:00 2001 From: Serge Latyntcev Date: Tue, 26 Nov 2019 16:37:01 +1300 Subject: [PATCH 4/4] Require spyc 0.6.2 or less (0.6.3 requires at least php 5.6) --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 08fbf37..6acf963 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "silverstripe/framework": "^3.5", "silverstripe/cms": "^3.5", "symbiote/silverstripe-gridfieldextensions": "^2.0", - "silverstripe/taxonomy": "^1.2" + "silverstripe/taxonomy": "^1.2", + "mustangostang/spyc": "<=0.6.2" }, "suggest": { "undefinedoffset/sortablegridfield": "Allow documents to be reordered via drag-and-drop"