Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DomCrawler] Revert previous restriction, allow selection of every DOMNode object#17021
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This should not be changed back, as this class cannot work with anything else than a DOMElement (it triggers fatal errors for others)
stof commentedDec 15, 2015
All changes in Form, Link and fields should be reverted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this change should be reverted. There is no reason to iterate on the crawler rather than iterator directly on the internal array
EdgarPE commentedDec 15, 2015
@stof Thank you for your comments. Later today I'll update my patch to incorporate everything you asked, and also fix fabpot.io errors. The Travis CI fail seems to be irrelevant, or at least caused by something else. |
EdgarPE commentedDec 15, 2015
@stof based on your input I kept all type hints in This way there is no need for a second BC BREAK. |
EdgarPE commentedDec 15, 2015
Also reworded the exceptions and made the changes in test cases. Now, this is a much smaller PR, only 2 files changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missing space before the opening parenthesis.
stof commentedDec 16, 2015
should we merge this in older branches as a bugfix ? |
xabbuh commentedDec 16, 2015
Does it work the same when applied to older branches? |
EdgarPE commentedDec 16, 2015
This change set reverts/rewrites9e60980 which was introduced in 2.8 Sadly, this exact change set as a patch does not apply to 2.8. Should I work on a 2.8 version of these changes? |
EdgarPE commentedDec 16, 2015
I don't know what is the policy of backports, so I made a different PR for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
For consistency, we should use single quotes to enclose the message, and double quotes inside the message:
thrownew \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.',get_class($node)));
jakzal commentedDec 17, 2015
@EdgarPE great job! 👍 once my comments are addressed |
EdgarPE commentedDec 17, 2015
@jakzal Thank you! Let me know if there is anything I should fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this could be only@expectedExceptionMessage (no regexp)
EdgarPE commentedDec 18, 2015
It looks like the tests are failing because of the new commit is master. Let me know if there is anything I should fix, or if I need to do a rebase now. |
EdgarPE commentedDec 21, 2015
Rebased my changes to latest master, DomCrawler tests still pass. I'm looking forward for your update on this. |
stof commentedDec 22, 2015
I suggest merging#17035 instead, which does the same changes in 2.8 |
xabbuh commentedDec 22, 2015
I agree with@stof. |
…MNode object.Squashed commit of the following:commit 69c97511c99e761dfeb612bb1d3b8a83b8984810Author: EdgarPE <hello@edgarpe.hu>Date: Tue Dec 15 17:01:10 2015 +0100 Add CHANGELOGcommit 19a171af813e83112fb404a1b86985215c83346aAuthor: EdgarPE <hello@edgarpe.hu>Date: Tue Dec 15 16:48:46 2015 +0100 Test coverage for InvalidArgumentExceptions in Crawler.phpcommit 8b050b780222e8c09c1b5ac2776584cd0d42d807Author: EdgarPE <hello@edgarpe.hu>Date: Tue Dec 15 15:43:13 2015 +0100 Reverted [DomCrawler] Changed typehints form DomNode to DomElementf416e70commit 52ff5af0c13417277b4e3b122f35536ed43d0668Author: EdgarPE <hello@edgarpe.hu>Date: Tue Dec 15 15:33:58 2015 +0100 Reverted: feature#16058 Prevent adding non-DOMElement elements in DomCrawler (stof)9f362a1
EdgarPE commentedDec 22, 2015
…ion of every DOMNode object (EdgarPE)This PR was squashed before being merged into the 2.8 branch (closes#17035).Discussion----------[DomCrawler] Revert previous restriction, allow selection of every DOMNode object| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes, revert to previous behaviour| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16933| License | MIT| Doc PR |This is a backport of PR#17021Commits-------d2872a3 [DomCrawler] Revert previous restriction, allow selection of every DOMNode object
Update: no BC break here.
Related Pull request:#16058
Mostly reverted previous commits:f416e709e60980
The linked PR above introduced a serious limitation in the DomCrawler component, namely only allows DOMElement and DOMDocument objects to be selected/added to the Crawler. Previously it was possible to completely parse, process, and also modify any Html, and XML documents.
Text nodes, attribute nodes and comment nodes are now impossible to search or add using the Crawler. I think these changes greatly reduce the usage possibilities of DomCrawler. So, my suggestion is:
Let's revert two previous changes and allow selecting every possible DOMNode object. There were fatal errors in some cases, witch were fixed with the changed type hints. Instead of type hints, now
\InvalidArgumentExceptionis thrown if needed in these methods:Crawler::link(),Crawler::links()andCrawler::form(), because these methods add special treatment for specific nodes.I am new to this community so I'm sorry if my commit or Pull Request have some flaws or miss something. In that case please let me know what should I do to fix it.