-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Magento: Added static-content-deploy relative symlink patch.
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
diff --git a/magento/framework/Filesystem/Driver/File.php b/magento/framework/Filesystem/Driver/File.php | ||
index 59c9775d73a..76609e6023f 100644 | ||
--- a/magento/framework/Filesystem/Driver/File.php | ||
+++ b/magento/framework/Filesystem/Driver/File.php | ||
@@ -353,7 +353,7 @@ class File implements DriverInterface | ||
{ | ||
$result = false; | ||
if ($targetDriver === null || get_class($targetDriver) == get_class($this)) { | ||
- $result = @symlink($this->getScheme() . $source, $destination); | ||
+ $result = symlink($this->relativePath($destination, $this->getScheme() . $source), $destination); | ||
} | ||
if (!$result) { | ||
throw new FileSystemException( | ||
@@ -370,6 +370,37 @@ class File implements DriverInterface | ||
return $result; | ||
} | ||
|
||
+ | ||
+ private function relativePath($basePath, $targetPath) | ||
+ { | ||
+ if ($basePath === $targetPath) { | ||
+ return ''; | ||
+ } | ||
+ | ||
+ $sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath); | ||
+ $targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath); | ||
+ array_pop($sourceDirs); | ||
+ $targetFile = array_pop($targetDirs); | ||
+ | ||
+ foreach ($sourceDirs as $i => $dir) { | ||
+ if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) { | ||
+ unset($sourceDirs[$i], $targetDirs[$i]); | ||
+ } else { | ||
+ break; | ||
+ } | ||
+ } | ||
+ | ||
+ $targetDirs[] = $targetFile; | ||
+ $path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); | ||
+ | ||
+ // A reference to the same base directory or an empty subdirectory must be prefixed with "./". | ||
+ // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used | ||
+ // as the first segment of a relative-path reference, as it would be mistaken for a scheme name | ||
+ // (see http://tools.ietf.org/html/rfc3986#section-4.2). | ||
+ return '' === $path || '/' === $path[0] | ||
+ || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos) | ||
+ ? "./$path" : $path; | ||
+ } | ||
/** | ||
* Delete file | ||
* |
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patch static-content-deploy relative symlinks | ||
|
||
Makes the static content deploy use relative symlinks in developer mode. Does not affect production mode. | ||
|
||
# Installation | ||
|
||
1. Install https://github.com/vaimo/composer-patches | ||
|
||
2. Add the following to the patches area of your `composer.json` | ||
|
||
``` | ||
{ | ||
"extra": { | ||
"patches": { | ||
"*": { | ||
"Patch static-content-deploy relative symlinks": { | ||
"source": "./vendor/reach-digital/docker-devbox/patch/static-content-deploy.diff" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |