Skip to content

Commit

Permalink
No max version check for apps when using release channel git or daily
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Oct 30, 2018
1 parent c33d17a commit 176a3a4
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 63 deletions.
10 changes: 5 additions & 5 deletions lib/private/App/DependencyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ private function analyzeDatabases(array $dependencies) {
return $this->getValue($db);
}, $supportedDatabases);
$currentDatabase = $this->platform->getDatabase();
if (!\in_array($currentDatabase, $supportedDatabases)) {
$missing[] = (string)$this->l->t('Following databases are supported: %s', \join(', ', $supportedDatabases));
if (!\in_array($currentDatabase, $supportedDatabases, true)) {
$missing[] = (string)$this->l->t('Following databases are supported: %s', \implode(', ', $supportedDatabases));
}
return $missing;
}
Expand Down Expand Up @@ -279,8 +279,8 @@ private function analyzeOS(array $dependencies) {
$oss = [$oss];
}
$currentOS = $this->platform->getOS();
if (!\in_array($currentOS, $oss)) {
$missing[] = (string)$this->l->t('Following platforms are supported: %s', \join(', ', $oss));
if (!\in_array($currentOS, $oss, true)) {
$missing[] = (string)$this->l->t('Following platforms are supported: %s', \implode(', ', $oss));
}
return $missing;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ private function analyzeOC(array $dependencies, array $appInfo) {
$missing[] = (string)$this->l->t('ownCloud %s or higher is required.', $minVersion);
}
}
if ($maxVersion !== null) {
if ($maxVersion !== null && !\in_array($this->platform->getOcChannel(), ['git', 'daily'], true)) {
if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) {
$missing[] = (string)$this->l->t('ownCloud %s or lower is required.', $maxVersion);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/private/App/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ public function getLibraryVersion($name) {
$lib = $repo->findLibrary($name);
return $lib;
}

public function getOcChannel() {
return \OCP\Util::getChannel();
}
}
83 changes: 47 additions & 36 deletions lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public static function isAppLoaded($app) {
* exists.
*
* if $types is set, only apps of those types will be loaded
* @throws \OC\HintException
* @throws \OC\NeedsUpdateException
* @throws \OC\ServerNotAvailableException
*/
public static function loadApps($types = null) {
if (\is_array($types) && !\array_diff($types, self::$loadedTypes)) {
Expand All @@ -123,7 +126,7 @@ public static function loadApps($types = null) {
// prevent app.php from printing output
\ob_start();
foreach ($apps as $app) {
if (($types === null or self::isType($app, $types)) && !\in_array($app, self::$loadedApps)) {
if (($types === null or self::isType($app, $types)) && !\in_array($app, self::$loadedApps, true)) {
self::loadApp($app);
}
}
Expand Down Expand Up @@ -175,7 +178,9 @@ public static function loadApp($app, $checkUpgrade = true) {

/**
* Enables the app as a theme if it has the type "theme"
*
* @param string $app
* @throws \OCP\AppFramework\QueryException
*/
private static function enableThemeIfApplicable($app) {
if (self::isType($app, 'theme')) {
Expand Down Expand Up @@ -206,6 +211,7 @@ public static function registerAutoloading($app, $path) {
* Load app.php from the given app
*
* @param string $app app name
* @throws Exception
*/
private static function requireAppFile($app) {
try {
Expand Down Expand Up @@ -239,7 +245,7 @@ public static function isType($app, $types) {
}
$appTypes = self::getAppTypes($app);
foreach ($types as $type) {
if (\array_search($type, $appTypes) !== false) {
if (\array_search($type, $appTypes, true)) {
return true;
}
}
Expand All @@ -260,9 +266,9 @@ private static function getAppTypes($app) {

if (isset(self::$appTypes[$app])) {
return \explode(',', self::$appTypes[$app]);
} else {
return [];
}

return [];
}

/**
Expand Down Expand Up @@ -388,6 +394,7 @@ public static function enable($app, $groups = null) {
/**
* @param string $app
* @return bool
* @throws \OCP\App\AppAlreadyInstalledException
*/
public static function removeApp($app) {
if (self::isShipped($app)) {
Expand All @@ -413,9 +420,9 @@ public static function disable($app) {
self::$enabledAppsCache = [];

// run uninstall steps
$appData = OC_App::getAppInfo($app);
$appData = self::getAppInfo($app);
if ($appData !== null) {
OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']);
self::executeRepairSteps($app, $appData['repair-steps']['uninstall']);
}

// emit disable hook - needed anymore ?
Expand Down Expand Up @@ -445,11 +452,11 @@ public static function getSettingsNavigation() {
) {
$settings = [
[
"id" => "help",
"order" => 1000,
"href" => $urlGenerator->linkToRoute('settings_help'),
"name" => $l->t("Help"),
"icon" => $urlGenerator->imagePath("settings", "help.svg")
'id' => 'help',
'order' => 1000,
'href' => $urlGenerator->linkToRoute('settings_help'),
'name' => $l->t('Help'),
'icon' => $urlGenerator->imagePath('settings', 'help.svg')
]
];
}
Expand All @@ -458,11 +465,11 @@ public static function getSettingsNavigation() {
if (OC_User::isLoggedIn()) {
// personal menu
$settings[] = [
"id" => "settings",
"order" => 1,
"href" => $urlGenerator->linkToRoute('settings.SettingsPage.getPersonal'),
"name" => $l->t("Settings"),
"icon" => $urlGenerator->imagePath("settings", "admin.svg")
'id' => 'settings',
'order' => 1,
'href' => $urlGenerator->linkToRoute('settings.SettingsPage.getPersonal'),
'name' => $l->t('Settings'),
'icon' => $urlGenerator->imagePath('settings', 'admin.svg')
];
}

Expand All @@ -482,11 +489,11 @@ private static function proceedNavigation($list) {
unset($navEntry);

\usort($list, function ($a, $b) {
if ($a["order"] == $b["order"]) {
if ($a['order'] == $b['order']) {
return 0;
}

if ($a["order"] < $b["order"]) {
if ($a['order'] < $b['order']) {
return -1;
}

Expand Down Expand Up @@ -566,6 +573,7 @@ public static function getAppVersion($appId) {
*
* @param string $path
* @return string
* @throws Exception
*/
public static function getAppVersionByPath($path) {
$infoFile = $path . '/appinfo/info.xml';
Expand All @@ -579,6 +587,7 @@ public static function getAppVersionByPath($path) {
* @param string $appId id of the app or the path of the info.xml file
* @param boolean $path (optional)
* @return array|null
* @throws Exception
* @note all data is read from info.xml, not just pre-defined fields
*/
public static function getAppInfo($appId, $path = false) {
Expand All @@ -604,7 +613,7 @@ public static function getAppInfo($appId, $path = false) {
}

if (\is_array($data)) {
$data = OC_App::parseAppInfo($data);
$data = self::parseAppInfo($data);
}
if (isset($data['ocsid'])) {
$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
Expand Down Expand Up @@ -637,6 +646,7 @@ public static function getNavigation() {
* get the id of loaded app
*
* @return string
* @throws Exception
*/
public static function getCurrentApp() {
$request = \OC::$server->getRequest();
Expand All @@ -651,9 +661,9 @@ public static function getCurrentApp() {
if ($topFolder == 'apps') {
$length = \strlen($topFolder);
return \substr($script, $length + 1, \strpos($script, '/', $length + 1) - $length - 1);
} else {
return $topFolder;
}

return $topFolder;
}

/**
Expand Down Expand Up @@ -754,13 +764,11 @@ public static function getAllApps() {
/**
* List all apps, this is used in apps.php
*
* @param bool $onlyLocal
* @param bool $includeUpdateInfo Should we check whether there is an update
* in the app store?
* @return array
* @throws Exception
*/
public static function listAllApps() {
$installedApps = OC_App::getAllApps();
$installedApps = self::getAllApps();

//TODO which apps do we want to blacklist and how do we integrate
// blacklisting with the multi apps folder feature?
Expand All @@ -771,8 +779,8 @@ public static function listAllApps() {
$urlGenerator = \OC::$server->getURLGenerator();

foreach ($installedApps as $app) {
if (\array_search($app, $blacklist) === false) {
$info = OC_App::getAppInfo($app);
if (!\in_array($app, $blacklist)) {
$info = self::getAppInfo($app);
if (!\is_array($info)) {
\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
continue;
Expand Down Expand Up @@ -838,7 +846,7 @@ public static function listAllApps() {
}
}

$info['version'] = OC_App::getAppVersion($app);
$info['version'] = self::getAppVersion($app);
$appList[] = $info;
}
}
Expand All @@ -854,8 +862,8 @@ public static function listAllApps() {
public static function getInternalAppIdByOcs($ocsID) {
if (\is_numeric($ocsID)) {
$idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
if (\array_search($ocsID, $idArray)) {
return \array_search($ocsID, $idArray);
if (\array_search($ocsID, $idArray, true)) {
return \array_search($ocsID, $idArray, true);
}
}
return false;
Expand Down Expand Up @@ -936,6 +944,7 @@ public static function isAppCompatible($ocVersion, $appInfo) {
}

if (!empty($requireMax)
&& !\in_array(\OCP\Util::getChannel(), ['git', 'daily'], true)
&& \version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
) {
return false;
Expand All @@ -962,6 +971,7 @@ public static function getAppVersions() {
*
* @param string $appId
* @return bool
* @throws \OC\NeedsUpdateException
*/
public static function updateApp($appId) {
$appPath = self::getAppPath($appId);
Expand Down Expand Up @@ -1003,7 +1013,7 @@ public static function updateApp($appId) {

self::setAppTypes($appId);

$version = \OC_App::getAppVersion($appId);
$version = self::getAppVersion($appId);
\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);

return true;
Expand Down Expand Up @@ -1060,19 +1070,20 @@ private static function setupLiveMigrations($appId, array $steps) {
/**
* @param string $appId
* @return \OC\Files\View|false
* @throws Exception
*/
public static function getStorage($appId) {
if (OC_App::isEnabled($appId)) { //sanity check
if (self::isEnabled($appId)) { //sanity check
if (OC_User::isLoggedIn()) {
$view = new \OC\Files\View('/' . OC_User::getUser());
if (!$view->file_exists($appId)) {
$view->mkdir($appId);
}
return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
} else {
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
return false;
}

\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
return false;
} else {
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
return false;
Expand Down Expand Up @@ -1125,7 +1136,7 @@ protected static function checkAppDependencies($config, $l, $info) {
$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
$missing = $dependencyAnalyzer->analyze($info);
if (!empty($missing)) {
$missingMsg = \join(PHP_EOL, $missing);
$missingMsg = \implode(PHP_EOL, $missing);
throw new \Exception(
$l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s',
[$info['name'], $missingMsg]
Expand Down
Loading

0 comments on commit 176a3a4

Please sign in to comment.