diff --git a/src/Dev/VersionedTestSessionExtension.php b/src/Dev/VersionedTestSessionExtension.php index 5de18d25..e9f69f7b 100644 --- a/src/Dev/VersionedTestSessionExtension.php +++ b/src/Dev/VersionedTestSessionExtension.php @@ -12,7 +12,6 @@ * Decorates TestSession object to update get / post requests with versioned querystring arguments. * Session vars assigned by FunctionalTest::useDraftSite are respected here. * - * @deprecated 2.2.0 Use ?stage=Stage|Live in your request's querystring instead * @property TestSession $owner */ class VersionedTestSessionExtension extends VersionedStateExtension @@ -22,11 +21,6 @@ class VersionedTestSessionExtension extends VersionedStateExtension * * @param string $url */ - public function __construct() - { - Deprecation::notice('2.2.0', 'Use ?stage=Stage|Live in your request\'s querystring instead', Deprecation::SCOPE_CLASS); - } - public function updateLink(&$url) { $session = $this->owner->session(); diff --git a/src/GraphQL/Resolvers/VersionedResolver.php b/src/GraphQL/Resolvers/VersionedResolver.php index 97eba240..30152e57 100644 --- a/src/GraphQL/Resolvers/VersionedResolver.php +++ b/src/GraphQL/Resolvers/VersionedResolver.php @@ -83,10 +83,17 @@ public static function resolveVersionList(array $resolverContext): Closure } // Get all versions - return $object->VersionsList(); + return self::getVersionsList($object); }; } + private static function getVersionsList(DataObject $object) + { + $id = $object->ID ?: $object->OldID; + $class = DataObject::getSchema()->baseDataClass($object); + return Versioned::get_all_versions($class, $id); + } + /** * @param DataList $list * @param array $args diff --git a/src/Versioned.php b/src/Versioned.php index f0be1911..86568b26 100644 --- a/src/Versioned.php +++ b/src/Versioned.php @@ -1968,7 +1968,7 @@ public function doRevertToLive() */ public function onAfterRevertToLive() { - Deprecation::notice('1.2.0', 'Will be removed without equivalent functionality to replace it'); + // noop } /** @@ -1977,7 +1977,7 @@ public function onAfterRevertToLive() public function publish($fromStage, $toStage, $createNewVersion = true) { Deprecation::notice('1.0.0', 'Use copyVersionToStage() instead'); - $this->owner->copyVersionToStage($fromStage, $toStage, true); + $this->owner->copyVersionToStage($fromStage, $toStage); } /** @@ -2077,38 +2077,6 @@ public function stagesDiffer() */ public function Versions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { - return $this->allVersions($filter, $sort, $limit, $join, $having); - } - - /** - * NOTE: Versions() will be replaced with this method in SilverStripe 5.0 - * - * @internal - * @deprecated 1.5.0 Use Versions() instead - * @return DataList - */ - public function VersionsList() - { - Deprecation::notice('1.5.0', 'Use Versions() instead'); - $id = $this->owner->ID ?: $this->owner->OldID; - $class = DataObject::getSchema()->baseDataClass($this->owner); - return Versioned::get_all_versions($class, $id); - } - - /** - * Return a list of all the versions available. - * - * @deprecated 1.5.0 Use Versions() instead - * @param string $filter - * @param string $sort - * @param string $limit - * @param string $join - * @param string $having - * @return ArrayList - */ - public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") - { - Deprecation::notice('1.5.0', 'Use Versions() instead'); /** @var DataObject $owner */ $owner = $this->owner; @@ -2164,6 +2132,36 @@ public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $ return $versions; } + /** + * @internal + * @deprecated 1.5.0 Use allVersions() instead + * @return DataList + */ + public function VersionsList() + { + Deprecation::notice('1.5.0', 'Use allVersions() instead'); + $id = $this->owner->ID ?: $this->owner->OldID; + $class = DataObject::getSchema()->baseDataClass($this->owner); + return Versioned::get_all_versions($class, $id); + } + + /** + * Return a list of all the versions available. + * + * @deprecated 1.5.0 Use Versions() instead + * @param string $filter + * @param string $sort + * @param string $limit + * @param string $join + * @param string $having + * @return ArrayList + */ + public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") + { + Deprecation::notice('1.5.0', 'Use Versions() instead'); + return $this->Versions($filter, $sort, $limit, $join, $having); + } + /** * Compare two version, and return the diff between them. * diff --git a/tests/php/ChangeSetTest.php b/tests/php/ChangeSetTest.php index 9d85560c..768e70b9 100644 --- a/tests/php/ChangeSetTest.php +++ b/tests/php/ChangeSetTest.php @@ -48,7 +48,9 @@ protected function tearDown(): void protected function publishAllFixtures() { $this->logInWithPermission('ADMIN'); - foreach ($this->fixtureFactory->getFixtures() as $class => $fixtures) { + /** @var FixtureTestState $state */ + $state = static::$state->getStateByName('fixtures'); + foreach ($state->getFixtureFactory(static::class)->getFixtures() as $class => $fixtures) { foreach ($fixtures as $handle => $id) { /** @var Versioned|DataObject $object */ $object = $this->objFromFixture($class, $handle); diff --git a/tests/php/VersionedOwnershipTest.php b/tests/php/VersionedOwnershipTest.php index c8581d95..2c79ca00 100644 --- a/tests/php/VersionedOwnershipTest.php +++ b/tests/php/VersionedOwnershipTest.php @@ -16,6 +16,7 @@ use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\Dev\SapphireTest; use DateTime; +use SilverStripe\Dev\State\FixtureTestState; /** * Tests ownership API of versioned DataObjects @@ -46,7 +47,9 @@ protected function setUp(): void Versioned::set_stage(Versioned::DRAFT); // Automatically publish any object named *_published - foreach ($this->getFixtureFactory()->getFixtures() as $class => $fixtures) { + /** @var FixtureTestState $state */ + $state = static::$state->getStateByName('fixtures'); + foreach ($state->getFixtureFactory(static::class)->getFixtures() as $class => $fixtures) { foreach ($fixtures as $name => $id) { if (stripos($name ?? '', '_published') !== false) { /** @var Versioned|DataObject $object */ diff --git a/tests/php/VersionedTest.php b/tests/php/VersionedTest.php index cdcb38cd..9e0f3f4c 100644 --- a/tests/php/VersionedTest.php +++ b/tests/php/VersionedTest.php @@ -294,7 +294,7 @@ public function testPublishCreateNewVersion() $page1->Content = 'orig'; $page1->write(); $firstVersion = $page1->Version; - $page1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE, false); + $page1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $this->assertEquals( $firstVersion, $page1->Version, @@ -306,7 +306,7 @@ public function testPublishCreateNewVersion() $secondVersion = $page1->Version; $this->assertTrue($firstVersion < $secondVersion, 'write creates new version'); - $page1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE, true); + $page1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); /** @var VersionedTest\TestObject $thirdVersionObject */ $thirdVersionObject = Versioned::get_latest_version(VersionedTest\TestObject::class, $page1->ID); $thirdVersion = $thirdVersionObject->Version; @@ -896,10 +896,10 @@ public function testAllVersions() public function testAllVersionsOnUnsavedRecord() { $newPage = new VersionedTest\Subclass(); - $this->assertCount(0, $newPage->allVersions(), 'No versions on unsaved record'); + $this->assertCount(0, $newPage->Versions(), 'No versions on unsaved record'); $singleton = VersionedTest\Subclass::singleton(); - $this->assertCount(0, $singleton->allVersions(), 'No versions for singleton'); + $this->assertCount(0, $singleton->Versions(), 'No versions for singleton'); } public function testArchiveRelatedDataWithoutVersioned() @@ -1065,7 +1065,7 @@ public function testLazyLoadFieldsRetrieval() public function testReadingNotPersistentWhenUseSessionFalse() { - Config::modify()->update(Versioned::class, 'use_session', false); + Config::modify()->set(Versioned::class, 'use_session', false); $session = new Session([]); $this->logInWithPermission('ADMIN'); @@ -1563,7 +1563,7 @@ public function testAuthor() $record = new VersionedTest\TestObject(); $record->write(); - $versions = $record->VersionsList(); + $versions = $record->Versions(); $latestVersion = $versions->last(); $author = $latestVersion->Author(); @@ -1578,7 +1578,7 @@ public function testPublisher() $record->write(); $record->publishRecursive(); - $versions = $record->VersionsList(); + $versions = Versioned::get_all_versions(get_class($record), $record->ID); $latestVersion = $versions->last(); $publisher = $latestVersion->Publisher(); @@ -1613,7 +1613,7 @@ public function testWriteWithoutVersion() 1 => 'First version', 2 => 'Second version original', ], - $record->VersionsList()->map('Version', 'Name')->toArray() + $record->Versions()->map('Version', 'Name')->toArray() ); @@ -1633,7 +1633,7 @@ public function testWriteWithoutVersion() // ...however the versions list has the original value // Note that publication creates a new version - $versions = $record->VersionsList()->map('Version', 'Name')->toArray(); + $versions = $record->Versions()->map('Version', 'Name')->toArray(); $this->assertEquals( [ 1 => 'First version', @@ -1644,7 +1644,7 @@ public function testWriteWithoutVersion() ); // The second version has WasPublished = true - $versions = $record->VersionsList()->map('Version', 'WasPublished')->toArray(); + $versions = $record->Versions()->map('Version', 'WasPublished')->toArray(); $this->assertEquals( [ 1 => 0, @@ -1669,7 +1669,7 @@ public function testArchivedEntries() $record->doArchive(); // ensure the version entries are correct - $versions = $record->VersionsList()->toArray(); + $versions = Versioned::get_all_versions(get_class($record), $record->ID)->toArray(); $this->assertCount(3, $versions, 'All versions should be retrieved'); /** @var TestObject $createdVersion */