Fixed commit order#7660
Conversation
|
Can you please cover your changes with tests? I'm also not sure yet if this introduces changes in the behaviour on first look. |
|
The test I added passes when runs against the fixed code and fails when runs against the original code. |
|
There should be only one commit, the test does not make sense without the code, and the code should not come without tests. Please improve the commit message to make as interesting as the pull request text. |
| * @param \stdClass $vertex | ||
| */ | ||
| private function visit($vertex) | ||
| private function visit($vertex, $minimumWeight = 0) |
There was a problem hiding this comment.
This branch requires 7.2, you can use a type hint:
| private function visit($vertex, $minimumWeight = 0) | |
| private function visit($vertex, int $minimumWeight = 0) |
There was a problem hiding this comment.
I applied the suggested change in the last (squashed) commit. Thank you.
6b69f19 to
02c7172
Compare
Update homepage
[2.7] CI: Test against PHP 7.4snapshot instead of nightly (8.0)
Allow Symfony 5.0
Fix compat of commands with Symfony 5
Add deprecation warnings for 2.7.x
Merge up 2.6 to 2.7
* Fixes and improvements * fix param type
Adds the website config to be compatible with the doctrine/doctrine-website#356 changes
* Update working-with-indexed-associations.rst Fixing broken link * Update docs/en/tutorials/working-with-indexed-associations.rst Co-authored-by: Claudio Zizza <[email protected]> Co-authored-by: Claudio Zizza <[email protected]>
- Some uppercase letters were used in the middle of sentence - Some dots were missing - There was two sentences with wrong or missing words
|
Both commits explain what they fix, but not how. Please include the explanation and follow the guidelines at https://www.doctrine-project.org/contribute/index.html#working-on-topic-branches |
* Use a classname that exists Doctrine\ORM\Mapping\TableGenerator does not exist, only Doctrine\ORM\Id\TableGenerator does. * Upgrade doctrine/coding-standard That library has a dependency on another library that requires composer plugin API v1. Updating both libs allow to use Composer v2. * Account for doctrine/reflection deprecation
* Update outdated doc parts - The cache implementation moved from `Common` to `doctrine/cache` - APCu is mor appropiate nowadays I guess - AbstractQuery::useResultCache() is deprecated since 2.7 * Fix wrong argument * Fix wrong arguments and remove useless line
* Move PHPUnit runs from Travis to Github Actions This removes all artifacts used for TravisCI testing and replaces them with the existing infrastructure for Github Actions from DBAL component. In addition some test changes were needed and triggered larger Coding Style cleanups in 3 test files. * Remove composer.lock and improve naming in CI workflow.
* Revert to whitelist coverage requires PHPunit 9, and we don't have that yet. * Upgrade to PHPUnit 8 This unlocks PCOV usage for coverage * Upload coverage files to Codecov
…8329) This fixes a regression from 099c5b4. Without the fix, "where part" in SQL is generated with incorrect aliases. See doctrine#8229 (comment).
4fb4e9d to
bd120ff
Compare
This fixes a commit order when persisting many entities with cyclic associations within one flush. Before the fix, when multiple cycles were presented in the precedence graph and more than two classes existed in within a cycle the calculated commit order was likely to be wrong, resulting in not null constraint violation when saving to a database. An example of such situation is provided in CommitOrderCalculatorTest::testCommitOrdering4() - this is a test case with won’t pass without the introduced fix. Prior to the fix the weight of an edge in a class precedence graph was compared only to the weight of the subsequent edges. Therefore, in case of cycles containing more than two classes the result was unpredictable. The fixed code uses also the weight of further nodes in the precedence graph. It is achieved by adding minimum weight argument to the visitor function of CommitOrderCalulator – edges having weight below the minimum weight are ignored. The minimum weight is increased each time a node is revisited, i. e. a cycle is detected. It guarantees that edges of highest priority representing not nullable relationships are processed first.
It may happen that an entity class A has multiple many-to-one associations with the same target entity B. These associations may differ in “nullable” parameter. In such situation CommitOrderCalculator::addDependency() is called multiple times for the same pair of $fromHash and $toHash, with different value of $weight argument. Before the fix the subsequent call to CommitOrderCalculator::addDependency() for the same $fromHash and $toHash overrode $weight set at the previous call. It caused unpredictable commit order of entities which resulted in not null constraint violation when saving to a database. Fixed code preserves the highest value of weight argument. If at subsequent call the weight is lower than previously established weight the addition of edge to the dependency list is skipped.
bd120ff to
7e79973
Compare
|
Closing in favor of #8349 |
Fixes visit method of CommitOrderCalculator.
Without the fix the insertion order is not properly calculated when a cycle within the graph involves more than 2 classes, leading to a violation of not null constraints on the owning side of ManyToOne relation.
With the fix when a cycle is detected a node is revisited ignoring edges of weight 0.