-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Improve stream wrapper support #12396
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
Draft
BrianHenryIE
wants to merge
28
commits into
composer:main
Choose a base branch
from
BrianHenryIE:use/realpath
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2ab3d1e
use `Composer\Util\Platform::realpath()`
BrianHenryIE 708c809
use `Composer\Util\Platform::realpath()`
BrianHenryIE e8a516f
Always treat stream wrappers as absolute paths
BrianHenryIE 198a7ea
Remove `false` check which no longer can evaluate to false
BrianHenryIE 9f03eba
Add `::testIsAbsolutePath()`
BrianHenryIE ed968c0
Do not treat `file://` paths as absolute path without check it un-pre…
BrianHenryIE 27fac4b
Recursively call `::realpath()` until `$path` does not change
BrianHenryIE d1081a3
Replace `realpath()` with `Platform::realpath()`
BrianHenryIE 4b5129b
Update src/Composer/Util/Filesystem.php
BrianHenryIE 21b7a7e
Refactor `::isStreamWrapperPath()` to `public static` method
BrianHenryIE a23e7ce
Do not treat `file://` as a streamwrapper
BrianHenryIE 40eb099
Return existing path for streamwrapper; throw exception for invalid path
BrianHenryIE 0cd95aa
Move `stream_wrapper_register()` to `bootstrap.php`
BrianHenryIE 598e88e
Replace `realpath()` with `Platform::realpath()`
BrianHenryIE 413dd88
Add test `::realpath()` throws `RuntimeException`
BrianHenryIE d859488
Add `::testIsStreamWrapperPath()`
BrianHenryIE 7542d71
Add `::testIsLocalPath()`
BrianHenryIE faeac42
Remove outdated redundant throw
BrianHenryIE aa70941
Return `false` on `::realpath()` `RuntimeException`
BrianHenryIE 1430918
`continue` on failed `::realpath()`
BrianHenryIE 1baf8bd
Strip `file://` before running system `realpath()`
BrianHenryIE 2c9ed1f
Add `::testRealPathFileStreamStripsScheme()`
BrianHenryIE d32e015
Update `::isStreamWrapperPath()
BrianHenryIE 463cebe
Don't `file://` prefix stream paths
BrianHenryIE 32e6c08
No need to catch and throw `RuntimeException` here, the message was fine
BrianHenryIE d359604
Preserve `null` or `realpath()`
BrianHenryIE 6592d1d
Update PhpDoc arguing we how we treat stream wrappers in `::isLocalPa…
BrianHenryIE 95353bc
Preserver behaviour; redundant throw
BrianHenryIE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int | |
&& $input->hasParameterOption('-h', true) === false | ||
) { | ||
$dir = dirname(Platform::getCwd(true)); | ||
$home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/'); | ||
$home = Platform::realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one too I'd probably try/catch and use |
||
|
||
// abort when we reach the home dir or top of the filesystem | ||
while (dirname($dir) !== $dir && $dir !== $home) { | ||
|
@@ -288,7 +288,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int | |
} catch (ParsingException $e) { | ||
$details = $e->getDetails(); | ||
|
||
$file = realpath(Factory::getComposerFile()); | ||
$file = Platform::realpath(Factory::getComposerFile()); | ||
|
||
$line = null; | ||
if ($details && isset($details['line'])) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 preserves current behaviour but isn't great IMO.
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 I'd say that is probably ok to expect the realpath to work here and remove the catch.