Commit 5c8c72b
committed
bug symfony#59779 [DomCrawler] Bug symfony#43921 Check for null parent nodes in the case of orphaned branches (ttk)
This PR was submitted for the 7.2 branch but it was merged into the 6.4 branch instead.
Discussion
----------
[DomCrawler] Bug symfony#43921 Check for null parent nodes in the case of orphaned branches
| Q | A
| ------------- | ---
| Branch | 7.2
| Bug fix | yes
| New feature | no
| Deprecations | no
| Issues | Fix symfony#43921
| License | MIT
This simple fix checks for null parent nodes when traversing the DOM tree when calling the `closest()` function. Instead of failing, the function will return null instead. This bring it into alignment with how the `ancestors()` function behaves (not failing on null parent nodes).
Null parent nodes can occur when a DOM branch is orphaned due to manipulations on the document, and this is a perfectly normal scenario.
Unit tests added that checks for this specific bug.
This fix should not break any backward compatibility.
Commits
-------
9a98452 Check for null parent Nodes in the case of orphaned branchesFile tree
2 files changed
+24
-1
lines changed- src/Symfony/Component/DomCrawler
- Tests
2 files changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1034 | 1057 | | |
1035 | 1058 | | |
1036 | 1059 | | |
| |||
0 commit comments