Skip to content

Commit 422e6be

Browse files
committed
Fix : get asset version with symbolic link
1 parent 8c09915 commit 422e6be

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

component/AssetsVersions.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,28 @@ private function getFromPath(string $assetPath): ?AssetVersion
109109

110110
private function getAssetVersionFromGitRevisions(string $assetPath): ?AssetVersion
111111
{
112-
$command = sprintf('git log --oneline %s | wc -l', escapeshellarg($this->pathToBeProcessed . $assetPath));
113-
$revision = exec($command);
112+
$realPath = realpath($this->pathToBeProcessed . $assetPath);
113+
114+
$command = sprintf('git log --oneline %s | wc -l', escapeshellarg($realPath));
115+
$revision = (int) exec($command);
114116

115117
if (!$revision) {
116118
return null;
117119
}
118120

119-
return new AssetVersion($assetPath, AssetVersion::TYPE_VERSION, (int) $revision);
121+
return new AssetVersion($assetPath, AssetVersion::TYPE_VERSION, $revision);
120122
}
121123

122124
private function getAssetVersionFromFileUpdateTime(string $assetPath): ?AssetVersion
123125
{
124-
$modificationTime = filemtime($this->pathToBeProcessed . $assetPath);
126+
$realPath = realpath($this->pathToBeProcessed . $assetPath);
127+
$modificationTime = (int) filemtime($realPath);
125128

126129
if (!$modificationTime) {
127130
return null;
128131
}
129132

130-
return new AssetVersion($assetPath, AssetVersion::TYPE_MODIFICATION_TIME, (int) $modificationTime);
133+
return new AssetVersion($assetPath, AssetVersion::TYPE_MODIFICATION_TIME, $modificationTime);
131134
}
132135

133136
private function getAssetPathList(string $subpath = ''): array

0 commit comments

Comments
 (0)