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

[Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argv#25304

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

Closed
ghost wants to merge5 commits intosymfony:masterfromunknown repository
Closed

[Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argv#25304

ghost wants to merge5 commits intosymfony:masterfromunknown repository

Conversation

@ghost
Copy link

@ghostghost commentedDec 4, 2017
edited by ghost
Loading

QA
Branch?master
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

This makes the script usable even if it is wrapped into another script, which is what some IDEs like PHPStorm do.

@ghostghost changed the title[Bridge/PhpUnit] Fix errors in PhpStorm[Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argvDec 4, 2017
}
array_splice($argv,1,0,array('--colors=always'));
$_SERVER['argv'] =$argv;
$_SERVER['argc'] = ++$argc;

Choose a reason for hiding this comment

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

this line should not be removed!

Copy link
Author

Choose a reason for hiding this comment

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

I forgot to put them back while I was debugging. They are back in67cc253.

array_splice($argv,1,0,array('--colors=always'));
$_SERVER['argv'] =$argv;
$_SERVER['argc'] = ++$argc;
array_splice($_SERVER['argv'],1,0,array('--colors=always'));

Choose a reason for hiding this comment

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

ok, in fact, this change introduces a bug
both$_SERVER['argv'] and$argv must be updated
this breaks the second

$cmd =array_map('escapeshellarg',$_SERVER['argv']);
$exit =0;

if (isset($argv[1]) &&'symfony' ===$argv[1] && !file_exists('symfony') &&file_exists('src/Symfony')) {

Choose a reason for hiding this comment

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

if you happen to be running this script in a context where $argv is not defined, then this line will always eval to false, which means it's useless
$argv is expected to be always defined in the current code. A better patch would be to always ensure the vars are defined

Copy link
Author

Choose a reason for hiding this comment

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

So the$cmd should be$argv to be sure it is always defined. That means that this is correct code but leaves$argv still used, not sure where to init the variable$_SERVER['argv'] so that$argv will be intact.

Choose a reason for hiding this comment

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

just start the script with:

$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;

Copy link
Author

Choose a reason for hiding this comment

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

Ah yea. I was thinking way too deep here. Thank you for your suggestion. I reverted everything in8fbf912 and added the lines at the beginning.


}

$argv =isset($_SERVER['argv']) ?$_SERVER['argv'] :array();
Copy link
Member

@nicolas-grekasnicolas-grekasDec 4, 2017
edited
Loading

Choose a reason for hiding this comment

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

onle last thing: before this line, add:global $argv, $argc;

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. Fixed in6140de9.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

for 3.3
@ricknox as an exercise, you might want to rebase+squash+retarget on 3.3?
otherwise, we can do it while merging.

@nicolas-grekasnicolas-grekas added this to the3.3 milestoneDec 4, 2017
@fabpot
Copy link
Member

No worries @ricknox, I'm taking care of everything.

@fabpot
Copy link
Member

Thank you @ricknox.

fabpot added a commit that referenced this pull requestDec 4, 2017
This PR was submitted for the master branch but it was squashed and merged into the 3.3 branch instead (closes#25304).Discussion----------[Bridge/PhpUnit] Prefer $_SERVER['argv'] over $argv| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aThis makes the script usable even if it is wrapped into another script, which is what some IDEs like PHPStorm do.Commits-------1ff22e6 [Bridge/PhpUnit] Prefer ['argv'] over
@fabpotfabpot closed thisDec 4, 2017
@ghost ghost deleted the PhpUnit-Bridge/PhpStorm branchDecember 4, 2017 20:34
This was referencedDec 4, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

4 participants

@fabpot@nicolas-grekas@carsonbot@ricardodevries

[8]ページ先頭

©2009-2025 Movatter.jp