This one was pretty crazy. The bug itself causes really unpredictable things. Lost 5 hours debugging recursion of nodes & taxonomy.

Anyway, I think the patch is pretty self-explanatory. Please, take a look.

Comments

neochief’s picture

StatusFileSize
new782 bytes
neochief’s picture

I'm not sure how it intended to be, but maybe the better option is to have dependancies actually keyed as IDs.

Status: Needs review » Needs work

The last submitted patch, entity-dependency-wrong-key-1427810.patch, failed testing.

neochief’s picture

Status: Needs work » Needs review
StatusFileSize
new1.3 KB

There's one more issue with iterator. For example, if you have a teaxonomy term, which is a child of another term and they both related to separate nodes in deployment plan, there will be a case, when parent term will get to traversed items faster then the rest of it's node terms, causing all of them skipped due to expression in valid(). To solve this, we need to skip all traversed items, but not terminate loop on them.

neochief’s picture

By the way, I've also found, that origin of a term, which originally created from node might be re-written by it's parent term. Since origin is not used anywhere, it's not critical, but it may cause some issues later.

Status: Needs review » Needs work

The last submitted patch, entity-dependency-wrong-key-1427810-2.patch, failed testing.

neochief’s picture

Status: Needs work » Needs review
StatusFileSize
new3.35 KB

This one should be final. I've find a better way to handle problem, than in last patch + updated tests (they fail with old code base).

vladsavitsky’s picture

+1. Commit it please.

neochief’s picture

StatusFileSize
new5.09 KB

It turns out that next() should be changed as well to catch some test circumstances. Tests & codeupdated.

neochief’s picture

I've found additional usecase in which iterator may fail: if some module will add the same entity as top item to dependencies, we won't be able to remove it on reset stage. So, we should get rid of it earlier.

dixon_’s picture

Status: Needs review » Fixed

Thanks neochief for you work on this (and all the other issues ;)).

I've committed the patch with some very minor code style fixes.

neochief’s picture

Status: Fixed » Needs work
StatusFileSize
new11.3 KB
new3.76 KB

Actually, this is not the end. Yesterday I've rewritten the iterator's structure, as even with latest patches it fails from time to time.

Example:
- Node A
- Node B, translation of A
- User U, author of A

iterator(A)

Curent iterator will try traverse a tree like this:

level #1
nodes:
-Node A

level #2
nodes:
--Node B
--Node A // added to the node type sub tree as parent
users:
--User U // but user is still in the trail

As you see from above, user will still be below it's parent node.

I've changed the way iterator builds a tree and got rid of entity type subtrees. Instead entities are listed in each pass as simple list of arrays, containing the data about an item:

level #1
(0 => array(id => A, type => node))

level #2
(0 => array(id => B, type => node))
(1 => array(id => U, type => user))
(2 => array(id => A, type => node))

The patch requires updating Entity dependency API and Deploy module. Since you're the author, I'm posting both here.

neochief’s picture

StatusFileSize
new10.28 KB

Sorry, last patch included some additional code from books support, not relevant to this issue. New version attached. Deploy's patch was ok.

neochief’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, entity_dependency.patch, failed testing.

dixon_’s picture

Hm, yeah I've had this limitation in mind as well at some point. But I never ran into the problem, so I guess I never fixed it :)

The approach looks good, but I have to look deeper into it. But before we commit anything, I'd like to have passing tests for everything.

neochief’s picture

Status: Needs work » Fixed

I've committed the full fix to both modules, included extended tests to the module. Here are commits:
http://drupalcode.org/project/entity_dependency.git/commit/66394f3
http://drupalcode.org/project/deploy.git/commit/d0b9b6a

dixon_’s picture

Awesome! neochief++++

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.