Skip to content

Commit 6e2f2ac

Browse files
committed
Fix relative path resolving for static lists
1 parent a6e2795 commit 6e2f2ac

4 files changed

+12
-16
lines changed

src/AutoloadRenderer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function setVariable($name, $value) {
227227
*
228228
* @return string
229229
*/
230-
private function resolvePath($fname) {
230+
protected function resolvePath($fname) {
231231
if (empty($this->baseDir)) {
232232
return str_replace('\\', '/', $fname);
233233
}

src/CacheWarmingListRenderer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public function __construct($addReset, $indent, $linebreak) {
2929
* @return string
3030
*/
3131
public function render(array $list) {
32-
$line = $this->indent . 'opcache_compile_file(';
33-
$glue = ');' . $this->linebreak . $line;
32+
$line = $this->indent . 'opcache_compile_file(___BASEDIR___\'';
33+
$glue = '\');' . $this->linebreak . $line;
3434

3535
$firstLine = $this->addReset ? $this->indent . 'opcache_reset();' . $this->linebreak : '';
36-
return $firstLine . $line . implode($glue, $list) . ');';
36+
return $firstLine . $line . implode($glue, $list) . '\');';
3737

3838
}
3939
}

src/StaticRenderer.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ public function render($template) {
9898
$baseDir = $this->compat ? 'dirname(__FILE__) . ' : '__DIR__ . ';
9999
}
100100

101-
$entries = $this->sortByDependency();
101+
$entries = array();
102+
foreach($this->sortByDependency() as $fname) {
103+
$entries[] = $this->resolvePath($fname);
104+
}
102105

103106
$replace = array_merge(
104107
$this->variables,
@@ -121,15 +124,8 @@ public function render($template) {
121124
protected function sortByDependency() {
122125
$sorter = new ClassDependencySorter($this->classes, $this->dependencies);
123126
$list = $sorter->process();
124-
$entries = array();
125-
foreach(array_unique($list) as $file) {
126-
$fname = realpath($file);
127-
if (!empty($this->baseDir) && strpos($fname, $this->baseDir)===0) {
128-
$fname = str_replace($this->baseDir, '', $fname);
129-
}
130-
$entries[] = "___BASEDIR___'$fname'";
131-
}
132-
return $entries;
127+
128+
return array_unique($list);
133129
}
134130

135131
}

src/StaticRequireListRenderer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function __construct($useOnce, $indent, $linebreak) {
2626
*/
2727
public function render(array $list) {
2828
$require = (boolean)$this->useOnce ? 'require_once' : 'require';
29-
$glue = ';' . $this->linebreak . $this->indent . $require . ' ';
29+
$glue = '\';' . $this->linebreak . $this->indent . $require . ' ___BASEDIR___\'';
3030

31-
return $this->indent . $require . ' ' . implode($glue, $list) . ';';
31+
return $this->indent . $require . ' ' . implode($glue, $list) . '\';';
3232
}
3333
}

0 commit comments

Comments
 (0)