Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Versioning support #96

Merged
merged 33 commits into from

4 participants

@dbu
Collaborator
dbu commented

adding versioning support as discussed on the mailing list. please see the added doc in the readme to see how this is to be used. the rudimentary versioning support that existed before is heavily refactored. if you used it, you will need to change:

  • Document attribute versionable is now required. it must be set to either "simple" or "full"
  • the @Version annotation is gone, it makes not much sense. for old version snapshot documents, you can use @ VersionName and @VersionCreated to track the metadata.
  • checkin and checkout are now lowercased to be consistent. note that we added checkpoint for convenience
  • restore has been renamed to restoreVersion and expects as parameter an old version rather than the document and version name.
  • instead of getPredecessors (which was misnamed anyways), use getAllLinearVersions to get metadata about versions, and use findVersionByName to get a detached document of the old version of your data.

apart from that, we added a removeVersion and update to latest jackalope with lots of fixes in version handling code.

Daniel Barsotti and others added some commits
Daniel Barsotti Added a `translated` attribute to all the translatable field annotations f4ab6d5
Daniel Barsotti Revert "Added a `translated` attribute to all the translatable field …
…annotations"

This reverts commit f4ab6d53bacc074f9f98dd338a90234f8f007460.
8b9cc53
Daniel Barsotti Merge remote-tracking branch 'github/master' 69d5a6c
Daniel Barsotti Merge remote-tracking branch 'upstream/master' 0cf26f1
Daniel Barsotti Implemented the new Document(versioningType=...) annotation a257b1a
Daniel Barsotti Updated jackalope to the latest version f808e1a
Daniel Barsotti Refactored the versionable annotation to be compatible with the new s…
…emantic
fd882ea
Daniel Barsotti Fixed case in versioning related methods 5cb4b88
Daniel Barsotti Corrected case inconsistency in method calls ee662cb
Daniel Barsotti Cleanup about versioning annotation
- The correct versionable mixin is set on document creation, checkin and checkout
- A document cannot have a @Version field if it is not versionable
- Corrected the exiting version related tests
ede00dd
Daniel Barsotti Moved the existing VersioningTest to the proper directory 54f2728
Daniel Barsotti Implemented checkpoint and getAllLinearVersions (IN PROGRESS) cd72e9a
Daniel Barsotti Finished implementation of DocumentManager::getAllLinearVersions a78aea2
@0x616469 0x616469 work in progress for findVersionByName() f0503d2
Daniel Barsotti Added basic tests for DocumentManager::findVersionByName e838c50
@dbu dbu cleaning up findVersionByName and refactoring restore to restoreVersion 72fa043
@dbu dbu little code cleanup on checkpoint 0499d41
Daniel Barsotti Implemented DocumentManager::removeVersion - the test VersioningTest:…
…:testRemoveVersion is still failing !!
05dede9
@dbu dbu check for version node rather than the frozen node, use fixed jackalo…
…pe that handles version deletion correctly
44f08f6
@dbu dbu annotation for VersionName and VersionCreated, clean up some locale a…
…ccess to use reflection
9c4aec0
@dbu dbu code and doc cleanups 571f834
@dbu dbu code cleanups and use the newly implemented PHPCR getAllLinearVersion…
…s instead of the hack
4999e2c
@dbu dbu adjust test to cleanup aaab6e0
@dbu dbu removing obsolete getPRedecessors 3e042f4
@dbu dbu and we do have doc for versioning too eb5cbbc
@dbu dbu Merge remote branch 'upstream/master' into versioning, remove alias f…
…rom test documents

Conflicts:
	README.md
	lib/Doctrine/ODM/PHPCR/UnitOfWork.php
	lib/vendor/jackalope
	tests/Doctrine/Tests/ODM/PHPCR/Functional/VersioningTest.php
8f150f9
@dbu dbu adjust LocaleChooserInterface to implementation f422a96
@dbu dbu removing @Version annotation as its no longer needed, tweaking handli…
…ng of @VersionName and @VersionCreated
0b86501
@dbu dbu move validation from driver into ClassMetadata d0c1471
@dbu dbu add the version mappings in yml and xml drivers e62e666
lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -1647,4 +1738,17 @@ private static function objToStr($obj)
{
return method_exists($obj, '__toString') ? (string)$obj : get_class($obj) . '@' . spl_object_hash($obj);
}
+
+ protected function setVersionableMixin(Mapping\ClassMetadata $metadata, NodeInterface $node)
+ {
+ if ($metadata->versionable === 'simple') {
+ $node->addMixin('mix:simpleVersionable');
+ } elseif ($metadata->versionable === 'full') {
+ $node->addMixin('mix:versionable');
+ } elseif ($metadata->versionable) {
@lsmith77 Owner
lsmith77 added a note

no need for those 2 last "else"

@dbu Collaborator
dbu added a note

i removed the check whether the document is versionable of an unknown type.
but i want to keep the last line, we call this method on checkin and checkout as well, whithout sanitizing. and there we want to notice if somebody tries to checkin a document that is not versionable.

@lsmith77 Owner
lsmith77 added a note

ah no .. my point wasn't that the exception throwing should be removed .. but actually my comment was bogus .. never mind :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
README.md
@@ -445,6 +441,20 @@ class DocumentRepository extends BaseDocumentRepository implements RepositoryIdI
</td>
</tr>
<tr>
+ <td> VersionName: </td>
@lsmith77 Owner
lsmith77 added a note

some extra spaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php
@@ -14,7 +14,7 @@
public $nodeType = 'nt:unstructured';
/** @var string */
public $repositoryClass;
- /** @var boolean */
+ /** @var string */
public $versionable = false;
@stof
stof added a note

string with a boolean default ? this seems weird

@dbu Collaborator
dbu added a note

removed the default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stof stof commented on the diff
lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
@@ -372,6 +382,9 @@ public function setLifecycleCallbacks(array $callbacks)
*/
public function setVersioned($versionable)
{
+ if (!in_array($versionable, self::$validVersionableAnnotations)) {
@stof
stof added a note

does it work when the attribute is false ?

@stof
stof added a note

ah nvm, the method is not called in such case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
.../Doctrine/Tests/ODM/PHPCR/Functional/ChildrenTest.php
@@ -141,6 +141,7 @@ public function testRemoveChildParent()
$parent = $this->dm->find('Doctrine\Tests\ODM\PHPCR\Functional\ChildrenTestObj', '/functional/parent');
$this->assertNull($parent);
}
+ public function assertCount($exp, $col) {$this->assertTrue($exp==count($col));}
@stof
stof added a note

what is it ?

@lsmith77 Owner
lsmith77 added a note

its time we require phpunit 3.6

@dbu Collaborator
dbu added a note

ups, damn. i just put that in so i could run the tests without updating my phpunit during a train ride...

i promise to update, remove this and will look for tests that could use assertCount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ts/ODM/PHPCR/Functional/Versioning/VersioningTest.php
((82 lines not shown))
+ $user = $this->dm->find($this->type, '/functional/versionTestObj');
+ $this->assertEquals('lsmith', $user->username);
+ }
+
+ public function testGetAllLinearVersions()
+ {
+ $doc = $this->dm->find($this->type, '/functional/versionTestObj');
+
+ $this->dm->checkpoint($doc);
+ $this->dm->checkpoint($doc);
+ $this->dm->checkpoint($doc);
+ $this->dm->checkpoint($doc);
+
+ $versions = $this->dm->getAllLinearVersions($doc);
+
+ $this->assertEquals(5, count($versions));
@stof
stof added a note

why not using the dedicated assertion assertCount ?

@dbu Collaborator
dbu added a note

done. there is lots of existing code with this issue too. will update when i find time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dbu
Collaborator
dbu commented

i will merge tomorrow unless somebody finds more issues. went through the api with lukas again and he is ok with it.

@lsmith77 lsmith77 merged commit a574615 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 18, 2011
  1. Revert "Added a `translated` attribute to all the translatable field …

    Daniel Barsotti authored
    …annotations"
    
    This reverts commit f4ab6d53bacc074f9f98dd338a90234f8f007460.
Commits on Dec 21, 2011
  1. Merge remote-tracking branch 'github/master'

    Daniel Barsotti authored
Commits on Jan 10, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Daniel Barsotti authored
  2. Implemented the new Document(versioningType=...) annotation

    Daniel Barsotti authored
  3. Updated jackalope to the latest version

    Daniel Barsotti authored
Commits on Jan 12, 2012
  1. Refactored the versionable annotation to be compatible with the new s…

    Daniel Barsotti authored
    …emantic
  2. Fixed case in versioning related methods

    Daniel Barsotti authored
  3. Corrected case inconsistency in method calls

    Daniel Barsotti authored
  4. Cleanup about versioning annotation

    Daniel Barsotti authored
    - The correct versionable mixin is set on document creation, checkin and checkout
    - A document cannot have a @Version field if it is not versionable
    - Corrected the exiting version related tests
  5. Moved the existing VersioningTest to the proper directory

    Daniel Barsotti authored
Commits on Jan 13, 2012
Commits on Jan 26, 2012
  1. @0x616469
  2. Added basic tests for DocumentManager::findVersionByName

    Daniel Barsotti authored
  3. @dbu
  4. @dbu

    little code cleanup on checkpoint

    dbu authored
Commits on Jan 27, 2012
  1. Implemented DocumentManager::removeVersion - the test VersioningTest:…

    Daniel Barsotti authored
    …:testRemoveVersion is still failing !!
Commits on Jan 30, 2012
  1. @dbu

    check for version node rather than the frozen node, use fixed jackalo…

    dbu authored
    …pe that handles version deletion correctly
  2. @dbu

    annotation for VersionName and VersionCreated, clean up some locale a…

    dbu authored
    …ccess to use reflection
Commits on Feb 1, 2012
  1. @dbu

    code and doc cleanups

    dbu authored
  2. @dbu
  3. @dbu

    adjust test to cleanup

    dbu authored
  4. @dbu

    removing obsolete getPRedecessors

    dbu authored
  5. @dbu
Commits on Feb 2, 2012
  1. @dbu

    Merge remote branch 'upstream/master' into versioning, remove alias f…

    dbu authored
    …rom test documents
    
    Conflicts:
    	README.md
    	lib/Doctrine/ODM/PHPCR/UnitOfWork.php
    	lib/vendor/jackalope
    	tests/Doctrine/Tests/ODM/PHPCR/Functional/VersioningTest.php
  2. @dbu
  3. @dbu

    removing @Version annotation as its no longer needed, tweaking handli…

    dbu authored
    …ng of @VersionName and @VersionCreated
  4. @dbu
  5. @dbu
  6. @dbu
  7. @dbu

    cleanups for the comments

    dbu authored
  8. @dbu
Something went wrong with that request. Please try again.