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

Fix translated app details #29004

Merged
merged 1 commit into from
Oct 13, 2021
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
2 changes: 1 addition & 1 deletion apps/theming/lib/Controller/ThemingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public function getManifest($app) {
$startUrl = $this->urlGenerator->getBaseUrl();
$description = $this->themingDefaults->getSlogan();
} else {
$info = $this->appManager->getAppInfo($app);
$info = $this->appManager->getAppInfo($app, false, $this->l10n->getLanguageCode());
$name = $info['name'] . ' - ' . $this->themingDefaults->getName();
$shortName = $info['name'];
if (strpos($this->request->getRequestUri(), '/index.php/') !== false) {
Expand Down
34 changes: 22 additions & 12 deletions apps/updatenotification/lib/Controller/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
use OCP\AppFramework\OCSController;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\L10N\IFactory;

class APIController extends OCSController {

Expand All @@ -46,23 +48,29 @@ class APIController extends OCSController {
/** @var AppFetcher */
protected $appFetcher;

/**
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param IAppManager $appManager
* @param AppFetcher $appFetcher
*/
public function __construct($appName,
/** @var IFactory */
protected $l10nFactory;

/** @var IUserSession */
protected $userSession;

/** @var string */
protected $language;

public function __construct(string $appName,
IRequest $request,
IConfig $config,
IAppManager $appManager,
AppFetcher $appFetcher) {
AppFetcher $appFetcher,
IFactory $l10nFactory,
IUserSession $userSession) {
parent::__construct($appName, $request);

$this->config = $config;
$this->appManager = $appManager;
$this->appFetcher = $appFetcher;
$this->l10nFactory = $l10nFactory;
$this->userSession = $userSession;
}

/**
Expand Down Expand Up @@ -97,7 +105,7 @@ public function getAppList(string $newVersion): DataResponse {
$this->appFetcher->setVersion($newVersion, 'future-apps.json', false);

// Apps available on the app store for that version
$availableApps = array_map(function (array $app) {
$availableApps = array_map(static function (array $app) {
return $app['id'];
}, $this->appFetcher->get());

Expand All @@ -108,6 +116,8 @@ public function getAppList(string $newVersion): DataResponse {
], Http::STATUS_NOT_FOUND);
}

$this->language = $this->l10nFactory->getUserLanguage($this->userSession->getUser());

$missing = array_diff($installedApps, $availableApps);
$missing = array_map([$this, 'getAppDetails'], $missing);
sort($missing);
Expand All @@ -128,8 +138,8 @@ public function getAppList(string $newVersion): DataResponse {
* @param string $appId
* @return string[]
*/
protected function getAppDetails($appId): array {
$app = $this->appManager->getAppInfo($appId);
protected function getAppDetails(string $appId): array {
$app = $this->appManager->getAppInfo($appId, false, $this->language);
return [
'appId' => $appId,
'appName' => $app['name'] ?? $appId,
Expand Down
6 changes: 3 additions & 3 deletions apps/updatenotification/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function prepare(INotification $notification, string $languageCode): INot
$notification->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index', ['section' => 'overview']) . '#version');
}
} else {
$appInfo = $this->getAppInfo($notification->getObjectType());
$appInfo = $this->getAppInfo($notification->getObjectType(), $languageCode);
$appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];

if (isset($this->appVersions[$notification->getObjectType()])) {
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function getAppVersions(): array {
return \OC_App::getAppVersions();
}

protected function getAppInfo($appId) {
return \OC_App::getAppInfo($appId);
protected function getAppInfo($appId, $languageCode) {
return \OC_App::getAppInfo($appId, false, $languageCode);
}
}
6 changes: 2 additions & 4 deletions lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ public function installApp(string $appId, bool $forceEnable = false): string {
throw new \Exception('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
}

$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);

$l = \OC::$server->getL10N('core');
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true, $l->getLanguageCode());

if (!is_array($info)) {
throw new \Exception(
Expand Down Expand Up @@ -163,8 +162,7 @@ public function installApp(string $appId, bool $forceEnable = false): string {
//run appinfo/install.php
self::includeAppScript($basedir . '/appinfo/install.php');

$appData = OC_App::getAppInfo($appId);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 6y old, the getAppInfo in line 117 is 5y old. I don't see much sense in it. Either they read the same info.xml anyway or we read data from 2 different sources and then either we run old repair-steps and save new remote/public handlers afterwards or the other way around.

OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
OC_App::executeRepairSteps($appId, $info['repair-steps']['install']);

//set the installed version
\OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false));
Expand Down
5 changes: 3 additions & 2 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,14 @@ public static function updateApp(string $appId): bool {
}

\OC::$server->getAppManager()->clearAppsCache();
$appData = self::getAppInfo($appId);
$l = \OC::$server->getL10N('core');
$appData = self::getAppInfo($appId, false, $l->getLanguageCode());

$ignoreMaxApps = \OC::$server->getConfig()->getSystemValue('app_install_overwrite', []);
$ignoreMax = in_array($appId, $ignoreMaxApps, true);
\OC_App::checkAppDependencies(
\OC::$server->getConfig(),
\OC::$server->getL10N('core'),
$l,
$appData,
$ignoreMax
);
Expand Down