Skip to content

Commit

Permalink
fix(TemplateLayout): core is not an app but the server itself
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

[skip ci]
  • Loading branch information
susnux authored and AndyScherzinger committed Jan 27, 2025
1 parent aedc4da commit 9cfafb0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
17 changes: 11 additions & 6 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,18 @@ private function getVersionHashByPath(string $path): string|false {
return false;
}

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

$hash = substr(md5($appVersion), 0, 8);
$hash = substr(md5($appVersion), 0, 8);
}
self::$cacheBusterCache[$path] = $hash;
}

Expand Down
12 changes: 9 additions & 3 deletions tests/lib/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
use OC\AppConfig;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
use OCP\IURLGenerator;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -541,8 +547,8 @@ public function testEnabledAppsCache() {
private function setupAppConfigMock() {
/** @var AppConfig|MockObject */
$appConfig = $this->getMockBuilder(AppConfig::class)
->setMethods(['getValues'])
->setConstructorArgs([\OC::$server->getDatabaseConnection()])
->onlyMethods(['getValues'])
->setConstructorArgs([\OCP\Server::get(IDBConnection::class)])
->disableOriginalConstructor()
->getMock();

Expand Down

0 comments on commit 9cfafb0

Please sign in to comment.