Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#5561: Taxon root is not being checked #5662

Merged
merged 1 commit into from
Aug 2, 2016
Merged

Issue#5561: Taxon root is not being checked #5662

merged 1 commit into from
Aug 2, 2016

Conversation

vcraescu
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related tickets fixes #5561
License MIT

@pjedrzejewski pjedrzejewski merged commit 6a3bcc5 into Sylius:master Aug 2, 2016
@pjedrzejewski
Copy link
Member

Thank you Viorel! :)

@vcraescu
Copy link
Contributor Author

vcraescu commented Aug 2, 2016

uw :)

$queryBuilder = $this->createQueryBuilder('o');
$queryBuilder
->innerJoin('o.taxons', 'taxon')
->andWhere($queryBuilder->expr()->eq('o.root', ':root'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something, but I cannot find root field on any Product mapping.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests may pass as this method is only used in OrmFinder in SearchBundle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct. it should be 'taxon' instead of 'o'. my fault!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, for nested set tree, left / right conditions should be enough - https://en.wikipedia.org/wiki/Nested_set_model. Moreover, we can replace this:

->andWhere($queryBuilder->expr()->orX(
    'taxon = :taxon',
    ':left < taxon.left AND taxon.right < :right'
))

with:

->andWhere(':left <= taxon.left AND taxon.right <= :right')

But there should be some automatic tests made before (if we need this method at all).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell they are not enough. You can have left and right value which match the condition from above but the node actually have a different root. I came up with this fix because in sylius admin we found some products being listed under a taxon even they were never assigned to it. Of course it's not easy to replicate this issue but it happens.

Copy link
Contributor

@pamil pamil Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If parent's left is always smaller than child's left and parent's right is always bigger than child's right, there is no way that this issue may exist (assuming that nested set tree implementation is correct).

Which version do you use? I remember that there were some issues when we used both nested set tree and softdeletable back in the days. (This may still exist in newer versions if using the same database then and now).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on sylius 0.18. Also tested on fresh sylius instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, I created a new pr for the error you spot.
https://github.com/Sylius/Sylius/pull/5676/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaxonRepository

Isn't quite the same thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Taxon root is not being checked in ProductRepository
3 participants