Skip to content

Commit c848671

Browse files
susnuxAndyScherzinger
authored andcommitted
fix(TemplateLayout): core is not an app but the server itself
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> [skip ci]
1 parent 5ea40c7 commit c848671

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

lib/private/TemplateLayout.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,18 @@ private function getVersionHashByPath(string $path): string|false {
342342
return false;
343343
}
344344

345-
$appVersion = $this->appManager->getAppVersion($appId);
346-
// For shipped apps the app version is not a single source of truth, we rather also need to consider the Nextcloud version
347-
if ($this->appManager->isShipped($appId)) {
348-
$appVersion .= '-' . self::$versionHash;
349-
}
345+
if ($appId === 'core') {
346+
// core is not a real app but the server itself
347+
$hash = self::$versionHash;
348+
} else {
349+
$appVersion = $this->appManager->getAppVersion($appId);
350+
// For shipped apps the app version is not a single source of truth, we rather also need to consider the Nextcloud version
351+
if ($this->appManager->isShipped($appId)) {
352+
$appVersion .= '-' . self::$versionHash;
353+
}
350354

351-
$hash = substr(md5($appVersion), 0, 8);
355+
$hash = substr(md5($appVersion), 0, 8);
356+
}
352357
self::$cacheBusterCache[$path] = $hash;
353358
}
354359

tests/lib/AppTest.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
use OC\AppConfig;
1313
use OCP\EventDispatcher\IEventDispatcher;
1414
use OCP\IAppConfig;
15-
use OCP\IURLGenerator;
15+
use OCP\ICacheFactory;
16+
use OCP\IConfig;
17+
use OCP\IDBConnection;
18+
use OCP\IGroupManager;
19+
use OCP\IUserManager;
20+
use OCP\IUserSession;
21+
use OCP\ServerVersion;
1622
use PHPUnit\Framework\MockObject\MockObject;
1723
use Psr\Log\LoggerInterface;
1824

@@ -539,8 +545,8 @@ public function testEnabledAppsCache() {
539545
private function setupAppConfigMock() {
540546
/** @var AppConfig|MockObject */
541547
$appConfig = $this->getMockBuilder(AppConfig::class)
542-
->setMethods(['getValues'])
543-
->setConstructorArgs([\OC::$server->getDatabaseConnection()])
548+
->onlyMethods(['getValues'])
549+
->setConstructorArgs([\OCP\Server::get(IDBConnection::class)])
544550
->disableOriginalConstructor()
545551
->getMock();
546552

@@ -556,13 +562,13 @@ private function setupAppConfigMock() {
556562
private function registerAppConfig(AppConfig $appConfig) {
557563
$this->overwriteService(AppConfig::class, $appConfig);
558564
$this->overwriteService(AppManager::class, new AppManager(
559-
\OC::$server->getUserSession(),
560-
\OC::$server->getConfig(),
561-
\OC::$server->getGroupManager(),
562-
\OC::$server->getMemCacheFactory(),
563-
\OC::$server->get(IEventDispatcher::class),
564-
\OC::$server->get(LoggerInterface::class),
565-
\OC::$server->get(IURLGenerator::class),
565+
\OCP\Server::get(IUserSession::class),
566+
\OCP\Server::get(IConfig::class),
567+
\OCP\Server::get(IGroupManager::class),
568+
\OCP\Server::get(ICacheFactory::class),
569+
\OCP\Server::get(IEventDispatcher::class),
570+
\OCP\Server::get(LoggerInterface::class),
571+
\OCP\Server::get(ServerVersion::class),
566572
));
567573
}
568574

0 commit comments

Comments
 (0)