Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BrowserKit] add a way to switch to ajax for one request#24778

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

Conversation

@Simperfit
Copy link
Contributor

@SimperfitSimperfit commentedNov 1, 2017
edited
Loading

QA
Branch?4.1
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20306
LicenseMIT
Doc PRwill do

Follow the work on#20306.

/cc@fabpot is it the right implementation ?

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch fromebd9e48 toa2b7fe1CompareNovember 1, 2017 06:28
returnisset($this->server[$key]) ?$this->server[$key] :$default;
}

publicfunctionswitchToAjax()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make more sense to use the termXmlHttpRequest instead ofAjax?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I guess it would make more sense

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch froma2b7fe1 to5d2f196CompareNovember 1, 2017 08:09
foreach ($deprecations ?unserialize($deprecations) :array()as$deprecation) {
if ($deprecation[0]) {
trigger_error($deprecation[1],E_USER_DEPRECATED);
@trigger_error($deprecation[1],E_USER_DEPRECATED);

Choose a reason for hiding this comment

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

this change is adding a bug, fabbot is not always right

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

will revert

* @return Crawler
*/
publicfunctionsubmit(Form$form,array$values =array())
publicfunctionsubmit(Form$form,array$values =array(),$isAjax =false)

Choose a reason for hiding this comment

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

adding arguments to a public method is a BC break, seehttps://symfony.com/bc

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I understood. I have changed the implementation.

@nicolas-grekasnicolas-grekas added this to the4.1 milestoneNov 1, 2017
@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch 2 times, most recently from61ae5dc to512a02eCompareNovember 1, 2017 17:35

publicfunctionswitchToXMLHttpRequest()
{
$this->setServerParameter('HTTP_X-Requested-With','XMLHttpRequest');
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be'HTTP_X_REQUESTED_WITH'?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The header name is really X-Requested-With, so no I guess.

Copy link
Member

Choose a reason for hiding this comment

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

I think@dmaicher is right: PHP normalizes dash to low dashes when hydrating the $_SERVER parameter.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

fixed, i've tested it and@dmaicher is actually right, sorry I did just check the header name.

@Simperfit
Copy link
ContributorAuthor

Simperfit commentedNov 5, 2017
edited
Loading

fabbot failure seems unrelated

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from512a02e to317cdf3CompareDecember 1, 2017 12:11
@Simperfit
Copy link
ContributorAuthor

This one is ready for review.

$client->request('GET','http://example.com/',array(),array(),array(),null,true,true);
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'],'XMLHttpRequest');
$client->removeXMLHttpRequest();
$this->assertEquals('http://example.com/',$client->getRequest()->getUri(),'->getCrawler() returns the Request of the last request');
Copy link
Contributor

Choose a reason for hiding this comment

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

This should make sure the server param is not set anymore instead?

Simperfit reacted with thumbs up emoji
$this->setServerParameter('HTTP_X_REQUESTED_WITH','XMLHttpRequest');
}

publicfunctionremoveXMLHttpRequest()
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this name a bit confusing. We are not removing any request :)

Maybe we can just only have a setter instead?setXMLHttpRequest($isXMLHttpRequest)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I will add Header a the end I think

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from317cdf3 to7f79a7fCompareDecember 9, 2017 16:06
@Simperfit
Copy link
ContributorAuthor

Named changed and test added.

fabbot error is wrong.

@Simperfit
Copy link
ContributorAuthor

AppVeyor failure is unrelated and fabbot error is a false positive.

@fabpot WDYT of this new implem ?

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from7f79a7f to6c4f0b8CompareFebruary 16, 2018 09:19
@Simperfit
Copy link
ContributorAuthor

PR rebased with master

$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'],'XMLHttpRequest');
$client->removeXMLHttpRequestHeader();
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH',false));
$this->assertEquals('http://example.com/',$client->getRequest()->getUri(),'->getCrawler() returns the Request of the last request');
Copy link
Member

Choose a reason for hiding this comment

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

this last assertion looks useless

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

that's right, i've removed it.

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from6c4f0b8 to1a3bf19CompareFebruary 16, 2018 12:43
returnisset($this->server[$key]) ?$this->server[$key] :$default;
}

publicfunctionswitchToXMLHttpRequest()
Copy link
Member

Choose a reason for hiding this comment

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

What aboutswitchToXHR instead?

Simperfit reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

done

@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from1a3bf19 to02b1e69CompareFebruary 19, 2018 14:51
@SimperfitSimperfitforce-pushed thefeature/add-a-way-to-switch-to-ajax-for-one-request branch from02b1e69 toa10eae7CompareFebruary 19, 2018 14:52
@fabpot
Copy link
Member

Thank you@Simperfit.

@fabpotfabpot merged commita10eae7 intosymfony:masterFeb 19, 2018
fabpot added a commit that referenced this pull requestFeb 19, 2018
…st (Simperfit)This PR was merged into the 4.1-dev branch.Discussion----------[BrowserKit] add a way to switch to ajax for one request| Q             | A| ------------- | ---| Branch?       | 4.1| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#20306| License       | MIT| Doc PR        | will doFollow the work on#20306./cc@fabpot is it the right implementation ?Commits-------a10eae7 [BrowserKit] add a way to switch to ajax for one request
@javiereguiluz
Copy link
Member

I know ... it's too late to talk about this because it's merged ... but I wanted to say that I don't like the current implementation :( It modifies a global estate withswitchToXHR() and you must remember later to reset the original estate withremoveXHR().

As an alternative, I wonder if we could introduce a newxhrRequest() method that wraps therequest() method and it works like it, but does the XHR stuff internally just for that request. Thanks!

@Simperfit
Copy link
ContributorAuthor

@javiereguiluz I agree with this statement, however I think we should let both switchToXHR and removeXHR public, it can be useful to be able to do it by ourself.

@fabpot WDYT ?

@SimperfitSimperfit deleted the feature/add-a-way-to-switch-to-ajax-for-one-request branchMarch 2, 2018 10:16
@fabpot
Copy link
Member

I totally agree with@javiereguiluz here. I was too fast to merge. The description of the PR si misleading.

@Simperfit Can you submit a PR to implement what's on the tin?

@Simperfit
Copy link
ContributorAuthor

Simperfit commentedMar 2, 2018 via email

Yes I will be doing it today !Le ven. 2 mars 2018 à 14:14, Fabien Potencier <notifications@github.com> aécrit :
I totally agree with@javiereguiluz <https://github.com/javiereguiluz> here. I was too fast to merge. The description of the PR si misleading.@Simperfit <https://github.com/simperfit> Can you submit a PR to implement what's on the tin? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#24778 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ADSq8heSVCdp_GWHEUkllXNnl0jYxhNzks5taUWkgaJpZM4QNzPO> .

symfony-splitter pushed a commit to symfony/browser-kit that referenced this pull requestMar 20, 2018
…pRequest() (Simperfit)This PR was merged into the 4.1-dev branch.Discussion----------Transform both switchToXHR() and removeXhr() to xmlHttpRequest()| Q             | A| ------------- | ---| Branch?       | 4.1| Bug fix?      | no| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | none   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | Will do.Seesymfony/symfony#24778 (comment) for more information about this.We are switching from a possible global estate change to just only one request affected.Commits-------4ed08896fa feature: transform both switchToXHR and removeXhr to a xhrRequest
fabpot added a commit that referenced this pull requestMar 20, 2018
…pRequest() (Simperfit)This PR was merged into the 4.1-dev branch.Discussion----------Transform both switchToXHR() and removeXhr() to xmlHttpRequest()| Q             | A| ------------- | ---| Branch?       | 4.1| Bug fix?      | no| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | none   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | Will do.See#24778 (comment) for more information about this.We are switching from a possible global estate change to just only one request affected.Commits-------4ed0889 feature: transform both switchToXHR and removeXhr to a xhrRequest
@fabpotfabpot mentioned this pull requestMay 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

+2 more reviewers

@dmaicherdmaicherdmaicher left review comments

@linaorilinaorilinaori left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

9 participants

@Simperfit@fabpot@javiereguiluz@dunglas@nicolas-grekas@stof@dmaicher@linaori@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp