OC_App::loadApps now only accepts an array as type list

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-02-17 15:22:00 +01:00
parent 2a2833e30f
commit edee243b27
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 9 additions and 12 deletions

View File

@ -96,7 +96,7 @@ class ExceptionOnLostConnection {
*/
public function setUp() {
require_once __DIR__ . '/../../../../lib/base.php';
\OC_App::loadApps('user_ldap');
\OC_App::loadApps(['user_ldap']);
$ch = $this->getCurl();
$proxyInfoJson = curl_exec($ch);

View File

@ -250,7 +250,7 @@ class Updater extends BasicEmitter {
$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
// install new shipped apps on upgrade
OC_App::loadApps('authentication');
OC_App::loadApps(['authentication']);
$errors = Installer::installShippedApps(true);
foreach ($errors as $appId => $exception) {
/** @var \Exception $exception */
@ -346,7 +346,7 @@ class Updater extends BasicEmitter {
if(!isset($stacks[$type])) {
$stacks[$type] = array();
}
if (\OC_App::isType($appId, $type)) {
if (\OC_App::isType($appId, [$type])) {
$stacks[$type][] = $appId;
$priorityType = true;
break;

View File

@ -93,16 +93,16 @@ class OC_App {
/**
* loads all apps
*
* @param string[] | string | null $types
* @param string[] $types
* @return bool
*
* This function walks through the ownCloud directory and loads all apps
* it can find. A directory contains an app if the file /appinfo/info.xml
* exists.
*
* if $types is set, only apps of those types will be loaded
* if $types is set to non-empty array, only apps of those types will be loaded
*/
public static function loadApps($types = null) {
public static function loadApps(array $types = []): bool {
if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
return false;
}
@ -120,7 +120,7 @@ class OC_App {
// prevent app.php from printing output
ob_start();
foreach ($apps as $app) {
if ((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
if (($types === [] or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
self::loadApp($app);
}
}
@ -268,13 +268,10 @@ class OC_App {
* check if an app is of a specific type
*
* @param string $app
* @param string|array $types
* @param array $types
* @return bool
*/
public static function isType($app, $types) {
if (is_string($types)) {
$types = array($types);
}
public static function isType(string $app, array $types): bool {
$appTypes = self::getAppTypes($app);
foreach ($types as $type) {
if (array_search($type, $appTypes) !== false) {