-
Notifications
You must be signed in to change notification settings - Fork 81
Mechanism for storing and retrieving Parsoid HTML from JS and PHP #1179
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
Conversation
|
I haven't looked in any of the details, but I strongly disagree with the implementation approach taken here. Touching parsoid.js in this manner was never intended and doing so creates so much more complexity... Here's what needs to be done in my opinion:
|
I agree. Too many places in
I agree this is the way to go, but there are some caveats. These could be mounted onto
I think we can tackle the tests after the first two points have been completed (but still in this PR). |
d00rman
left a comment
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.
Needs to be reworked as per above discussion.
I added the proxy and a couple basic tests. |
d00rman
left a comment
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.
Gave it a first pass, but looking much better now.
5d61671 to
9f86111
Compare
sys/parsoid_proxy.js
Outdated
| .then((res) => { | ||
| if (res) { | ||
| res.headers = res.headers || {}; | ||
| res.headers[VARIANT_HDR_NAME] = rootReqHeaders[VARIANT_HDR_NAME]; |
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.
I'm not quite sure this is a right behavior that wouldn't accidentally mask issues. We assume we've routed the request to correct Parsoid, but who knows? Why would we set the response header for parsed variant here??
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.
It's in the ticket: "Furthermore, RESTBase must include this header in the response, ..." https://phabricator.wikimedia.org/T230791
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.
Ideally, the variant header would be added by the Parsoid instances instead of Restbase
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.
Yeah, that's what I meant. Or, the content-type would be different. Would you mind filing a ticket, something like 'Parsoid JS/PHP should indicate which Parsoid implementation the page was rendered with'?
|
A couple of issues left, but you're close. One thing I'm wondering about is testing. With the current patch we will be testing PHP parsoid compatibility with exactly 1 test. We need more. We need to have an env variable that would set a parsoid variant header in preq for all requests, (I believe we'd need to support this in preq, but maybe |
hknustwmf
left a comment
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.
Doesn't look like request has support for what you want to do. Do you intend to modify the tests with the additional header field? The value would be whatever the env var says or JS as the default?
…id HTML from JS and PHP
Pchelolo
left a comment
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.
Doesn't look like
requesthas support for what you want to do. Do you intend to modify the tests with the additional header field? The value would be whatever the env var says or JS as the default?
There's https://github.com/request/request#requestdefaultsoptions. We can add this to 'preq' as well - preq.defaults will return a wrapper that will modify the request options. Should be fairly easy to achieve. Then we can modify the tests to require some instance of preq from utils and that one would be a wrapper based on an env var.
I've realized we can't really add the header based on the env var in preq itself cause we use preq not only in test code but in the application code as well.
There's a bunch of things to be done to be able to run CI and local testing agains Parsoid-PHP. We can't access production wikis on beta PHP Parsoid, see T231933 so we need to convert all the tests to only talk to beta wikis. I think we can work on that in separate PRs. |
|
Based on the discussion with Giuseppe yesterday, let's also think about/create tasks to remove external dependencies from integration tests. |
Creating tasks makes sense, but actually blocking this on them is a bit too ambitious in my opinion. |
|
It was meant as a suggestion not a blocker |
|
Superseded by #1207 |
It may look like a lot of changes, but there are actually only a few. The key pieces are parsoid.js and the new test variant_config.js. The transform.js test battery is now executed twice -- once for each variant. The tests themselves did not change except for the headers.