-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] deprecate relative paths in makePathRelative() #24202
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
xabbuh
commented
Sep 14, 2017
Q | A |
---|---|
Branch? | 3.4 |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | yes |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR |
Our docblock always stated that we expected absolute paths. However, we also had tests for relative paths. Thus, I suggest as a compromise to (silently) keep support for relative paths in Symfony 3 (see #22321) and drop it explicitly in 4.0. |
6226154
to
3a70f82
Compare
Is there any reason why relative paths should not be supported? With #22321 relative paths work perfectly fine without problems, why should the method be limited to absolute paths? |
@ausi Because it's called |
Additionally, it's not clear to what base a path is relative. Will both paths be treated as being relative to the same directory? What if only one of the input paths is relative. All of this can (depending on the context in which it is used) lead to confusion and even be wrong (because of different perceptions of how the paths should be interpreted). |
UPGRADE-4.0.md
Outdated
@@ -200,6 +200,7 @@ Filesystem | |||
* The `Symfony\Component\Filesystem\LockHandler` has been removed, | |||
use the `Symfony\Component\Lock\Store\FlockStore` class | |||
or the `Symfony\Component\Lock\Store\FlockStore\SemaphoreStore` class directly instead. | |||
* support for passing relative paths to `Filesystem::makePathRelative()` has been removed in 4.0 |
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.
First letter should be uppercase for consistency, same for UPGRADE-3.3. in 4.0
could be removed also
The method description says “Given an existing path, convert it to a path relative to a given starting path.”. I don’t see why “existing path” and “starting path” have to be absolute. IMO it doesn’t imply that the input is not relative, but it implies that the “existing path” is not relative to the “starting path”.
I think it’s obvious that two relative paths would refer to the same base, just as two absolute paths refer to the same root.
From my point of view |
small conflict to resolve |
3a70f82
to
893df58
Compare
@ausi the confusion also comes from the case where one path is relative, and the other is not: this makes the result of the function context sensitive, thus non-predictable (sensitive to |
Couldn’t we just disallow this case? if ($this->isAbsolutePath($endPath) !== $this->isAbsolutePath($startPath)) {
throw new InvalidArgumentException('...');
} |
The goal is also to make things easier to maintain. WDYT @xabbuh? |
I would separate responsibilities. If there is need for relative paths, I would add a method that returns the absolute path (probably based on a working directory that can also be passed). |
Why should it be harder to maintain? Relative paths work already and are unit tested with #22321. @xabbuh your suggestion would then result in code like this: $fs->makePathRelative(
$fs->getAbsolutePath($endPath, $rootPath),
$fs->getAbsolutePath($startPath, $rootPath)
); instead of just: $fs->makePathRelative($endPath, $startPath); It would also require to know the root path of the relative paths. I don’t see the benefit here. |
Thank you @xabbuh. |
…ive() (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Filesystem] deprecate relative paths in makePathRelative() | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 893df58 deprecate relative paths in makePathRelative()