figure out how to handle dangling weak/path ReferenceOne/Many properties #440

Open
dbu opened this Issue Feb 28, 2014 · 4 comments

Projects

None yet

2 participants

@dbu
Member
dbu commented Feb 28, 2014

this is a follow-up of #116

the problem is: what happens when a ReferenceOne path or weak reference property points to something non-existing? is the property null? is the currently invalid reference removed on save or kept (which would make sense, in case the node at path appears later). but if it is usually kept, how can we delete it if we want?

@dbu dbu added the sanity checks label Feb 28, 2014
@eXsio
Contributor
eXsio commented Mar 31, 2014

I think, that the invalid reference should stay intact, but ODM should simply return null. (So basically the way it's handled in 1.0.1). If something is being deleted without proper cleanup, the chance is, that it's a bug/mistake. In that way, when WeakReferences are preserved, mistakenly deleted nodes can be restored from backup (eg. by Toromiro or other JCR tool) and previously broken references will be valid again.

The other thing to consider - is it possible to do some sort of optional cleanup, when deleting a node? Eg. I want to delete a node with image file, so ODM provides a simple way to null out all refering fields..

@dbu
Member
dbu commented Mar 31, 2014

i think i never tested, but so you tested that if you change a document
that has a weak reference / path reference to nonexisting, but you don't
touch the reference field, it stays intact? that would be very good
news, i was afraid it might lose the info. if its really preserved, this
issue is actually a documentation issue and not something that needs a
fix in code...

you can configure cascade delete on reference / referrer mappings for
the cleanup.

@eXsio
Contributor
eXsio commented Mar 31, 2014

Yes, I'm using ODM 1.0.1 and if I remove a node, which is referenced by another node, ODM (or Jackalope - I'm not sure on what level it's being done) returns null, but the reference field in JCR (I'm using Jackrabbit) is intact. Considering that's a pretty important thing, it should be heavily tested, both with Jackrabbit and DBAL implementation. I can't guarantee that I'll be able to provide tests for this though (primarily due to the lack of free time:/ )...

@dbu
Member
dbu commented Mar 31, 2014

thanks for the report. i will try to add some tests around this in the near future, so we at least know what works and what not.

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