Skip to content
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

[10.2.1] Do not try to override JS files from theme when there is no custom th… #35709

Merged
merged 1 commit into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions lib/private/Template/JSResourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ public function doFind($script) {
if ($found) {
return;
}
} elseif ($this->appendOnceIfExist($baseDirectory, $themeDirectory.'/apps/'.$fullScript, $webRoot)
|| $this->appendOnceIfExist($baseDirectory, $themeDirectory.'/'.$fullScript, $webRoot)
|| $this->appendOnceIfExist($this->serverroot, $fullScript)
|| $this->appendOnceIfExist($baseDirectory, $themeDirectory.'/core/'.$fullScript, $webRoot)
|| $this->appendOnceIfExist($this->serverroot, 'core/'.$fullScript)
) {
return;
} else {
// Search in an active theme first. But only if it is active
if (
$themeDirectory !== '' && $this->appendOnceIfExist($baseDirectory, $themeDirectory.'/apps/'.$fullScript, $webRoot)
) {
return;
}
if ($this->appendOnceIfExist($baseDirectory, $themeDirectory.'/'.$fullScript, $webRoot)
|| $this->appendOnceIfExist($this->serverroot, $fullScript)
|| $this->appendOnceIfExist($baseDirectory, $themeDirectory.'/core/'.$fullScript, $webRoot)
|| $this->appendOnceIfExist($this->serverroot, 'core/'.$fullScript)
) {
return;
}
}

$app = \substr($fullScript, 0, \strpos($fullScript, '/'));
Expand Down
26 changes: 26 additions & 0 deletions tests/lib/Template/JSResourceLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,32 @@ public function testFindAppScript() {
$locator->find(['randomapp/js/script']);
}

public function testFindAppScriptWithNoThemeActive() {
$this->themeAppDir = '';
/** @var \OC\Template\JSResourceLocator $locator */
$locator = $this->getResourceLocator(
'',
[$this->serverRoot => 'map'],
['foo' => 'bar']
);
$this->appManager->expects($this->any())
->method('getAppPath')
->with('randomapp')
->willReturn('/var/www/apps-external/randomapp');

$locator->expects($this->exactly(5))
->method('appendOnceIfExist')
->withConsecutive(
['/var/www/apps', '/randomapp/js/script.js', ''],
['/var/www/owncloud', 'randomapp/js/script.js', ''],
['/var/www/apps', '/core/randomapp/js/script.js', ''],
['/var/www/owncloud', 'core/randomapp/js/script.js', ''],
['/var/www/apps-external/randomapp', 'js/script.js', '']
);

$locator->find(['randomapp/js/script']);
}

public function testFindL10nScript() {
/** @var \OC\Template\JSResourceLocator $locator */
$locator = $this->getResourceLocator(
Expand Down