summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php51
-rw-r--r--lib/composer/composer/autoload_classmap.php8
-rw-r--r--lib/composer/composer/autoload_static.php8
-rw-r--r--lib/l10n/es_419.js2
-rw-r--r--lib/l10n/es_419.json2
-rw-r--r--lib/l10n/es_AR.js1
-rw-r--r--lib/l10n/es_AR.json1
-rw-r--r--lib/l10n/es_CL.js2
-rw-r--r--lib/l10n/es_CL.json2
-rw-r--r--lib/l10n/es_CO.js2
-rw-r--r--lib/l10n/es_CO.json2
-rw-r--r--lib/l10n/es_CR.js2
-rw-r--r--lib/l10n/es_CR.json2
-rw-r--r--lib/l10n/es_DO.js2
-rw-r--r--lib/l10n/es_DO.json2
-rw-r--r--lib/l10n/es_EC.js2
-rw-r--r--lib/l10n/es_EC.json2
-rw-r--r--lib/l10n/es_GT.js2
-rw-r--r--lib/l10n/es_GT.json2
-rw-r--r--lib/l10n/es_HN.js2
-rw-r--r--lib/l10n/es_HN.json2
-rw-r--r--lib/l10n/es_NI.js2
-rw-r--r--lib/l10n/es_NI.json2
-rw-r--r--lib/l10n/es_PA.js2
-rw-r--r--lib/l10n/es_PA.json2
-rw-r--r--lib/l10n/es_PE.js2
-rw-r--r--lib/l10n/es_PE.json2
-rw-r--r--lib/l10n/es_PR.js2
-rw-r--r--lib/l10n/es_PR.json2
-rw-r--r--lib/l10n/es_PY.js2
-rw-r--r--lib/l10n/es_PY.json2
-rw-r--r--lib/l10n/es_SV.js2
-rw-r--r--lib/l10n/es_SV.json2
-rw-r--r--lib/l10n/es_UY.js2
-rw-r--r--lib/l10n/es_UY.json2
-rw-r--r--lib/private/AllConfig.php10
-rw-r--r--lib/private/App/AppManager.php8
-rw-r--r--lib/private/App/CodeChecker/DeprecationCheck.php4
-rw-r--r--lib/private/AppConfig.php5
-rw-r--r--lib/private/AppFramework/Http/Request.php5
-rw-r--r--lib/private/Avatar.php19
-rw-r--r--lib/private/AvatarManager.php14
-rw-r--r--lib/private/Collaboration/Collaborators/Search.php9
-rw-r--r--lib/private/Collaboration/Collaborators/UserPlugin.php11
-rw-r--r--lib/private/Comments/Comment.php4
-rw-r--r--lib/private/Console/Application.php2
-rw-r--r--lib/private/DB/MigrationService.php6
-rw-r--r--lib/private/DB/SchemaWrapper.php33
-rw-r--r--lib/private/Federation/CloudId.php11
-rw-r--r--lib/private/Federation/CloudIdManager.php11
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php14
-rw-r--r--lib/private/Http/Client/Client.php28
-rw-r--r--lib/private/Http/Client/ClientService.php4
-rw-r--r--lib/private/Http/Client/Response.php11
-rw-r--r--lib/private/Installer.php2
-rw-r--r--lib/private/L10N/Factory.php2
-rw-r--r--lib/private/Lock/AbstractLockingProvider.php12
-rw-r--r--lib/private/Lock/DBLockingProvider.php20
-rw-r--r--lib/private/Lock/MemcacheLockingProvider.php13
-rw-r--r--lib/private/Lock/NoopLockingProvider.php23
-rw-r--r--lib/private/Log/File.php5
-rw-r--r--lib/private/Memcache/APCu.php4
-rw-r--r--lib/private/Memcache/Factory.php33
-rw-r--r--lib/private/OCS/DiscoveryService.php24
-rw-r--r--lib/private/Preview/Generator.php20
-rw-r--r--lib/private/Preview/GeneratorHelper.php6
-rw-r--r--lib/private/Preview/TXT.php5
-rw-r--r--lib/private/PreviewManager.php4
-rw-r--r--lib/private/Repair.php21
-rw-r--r--lib/private/Repair/NC11/CleanPreviews.php73
-rw-r--r--lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php132
-rw-r--r--lib/private/Repair/NC11/MoveAvatars.php73
-rw-r--r--lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php146
-rw-r--r--lib/private/Repair/NC12/InstallCoreBundle.php80
-rw-r--r--lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php112
-rw-r--r--lib/private/Repair/NC12/UpdateLanguageCodes.php91
-rw-r--r--lib/private/Security/Crypto.php7
-rw-r--r--lib/private/Security/Hasher.php17
-rw-r--r--lib/private/Server.php10
-rw-r--r--lib/private/Share/Share.php121
-rw-r--r--lib/private/Updater.php41
-rw-r--r--lib/private/legacy/app.php14
-rw-r--r--lib/private/legacy/image.php48
-rw-r--r--lib/private/legacy/json.php2
-rw-r--r--lib/private/legacy/user.php76
-rw-r--r--lib/private/legacy/util.php7
-rw-r--r--lib/public/DB/ISchemaWrapper.php92
-rw-r--r--lib/public/Federation/ICloudId.php9
-rw-r--r--lib/public/Federation/ICloudIdManager.php7
-rw-r--r--lib/public/Http/Client/IClient.php13
-rw-r--r--lib/public/Http/Client/IClientService.php3
-rw-r--r--lib/public/Http/Client/IResponse.php9
-rw-r--r--lib/public/IAppConfig.php60
-rw-r--r--lib/public/IAvatarManager.php7
-rw-r--r--lib/public/ICacheFactory.php19
-rw-r--r--lib/public/IImage.php4
-rw-r--r--lib/public/Lock/ILockingProvider.php9
-rw-r--r--lib/public/Lock/LockedException.php5
-rw-r--r--lib/public/Migration/BigIntMigration.php8
-rw-r--r--lib/public/Migration/IMigrationStep.php10
-rw-r--r--lib/public/Migration/SimpleMigrationStep.php10
-rw-r--r--lib/public/OCS/IDiscoveryService.php3
-rw-r--r--lib/public/Security/ICrypto.php5
-rw-r--r--lib/public/Security/IHasher.php5
-rw-r--r--lib/public/Security/StringUtils.php3
-rw-r--r--lib/public/User.php29
106 files changed, 508 insertions, 1384 deletions
diff --git a/lib/base.php b/lib/base.php
index f763ee634f3..99651479dfa 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -236,7 +236,7 @@ class OC {
// Check if config is writable
$configFileWritable = is_writable($configFilePath);
if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled()
- || !$configFileWritable && self::checkUpgrade(false)) {
+ || !$configFileWritable && \OCP\Util::needUpgrade()) {
$urlGenerator = \OC::$server->getURLGenerator();
@@ -290,37 +290,15 @@ class OC {
}
/**
- * Checks if the version requires an update and shows
- * @param bool $showTemplate Whether an update screen should get shown
- * @return bool|void
- */
- public static function checkUpgrade($showTemplate = true) {
- if (\OCP\Util::needUpgrade()) {
- if (function_exists('opcache_reset')) {
- opcache_reset();
- }
- $systemConfig = \OC::$server->getSystemConfig();
- if ($showTemplate && !$systemConfig->getValue('maintenance', false)) {
- self::printUpgradePage();
- exit();
- } else {
- return true;
- }
- }
- return false;
- }
-
- /**
* Prints the upgrade page
+ *
+ * @param \OC\SystemConfig $systemConfig
*/
- private static function printUpgradePage() {
- $systemConfig = \OC::$server->getSystemConfig();
-
+ private static function printUpgradePage(\OC\SystemConfig $systemConfig) {
$disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false);
$tooBig = false;
if (!$disableWebUpdater) {
$apps = \OC::$server->getAppManager();
- $tooBig = false;
if ($apps->isInstalled('user_ldap')) {
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
@@ -724,7 +702,7 @@ class OC {
);
//setup extra user backends
- if (!self::checkUpgrade(false)) {
+ if (!\OCP\Util::needUpgrade()) {
OC_User::setupBackends();
} else {
// Run upgrades in incognito mode
@@ -807,7 +785,7 @@ class OC {
*/
public static function registerCleanupHooks() {
//don't try to do this before we are properly setup
- if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) {
+ if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
// NOTE: This will be replaced to use OCP
$userSession = self::$server->getUserSession();
@@ -925,7 +903,7 @@ class OC {
if (!$systemConfig->getValue('installed', false)) {
\OC::$server->getSession()->clear();
$setupHelper = new OC\Setup(
- \OC::$server->getSystemConfig(),
+ $systemConfig,
\OC::$server->getIniWrapper(),
\OC::$server->getL10N('lib'),
\OC::$server->query(\OCP\Defaults::class),
@@ -945,7 +923,16 @@ class OC {
}
if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade
self::checkMaintenanceMode();
- self::checkUpgrade();
+
+ if (\OCP\Util::needUpgrade()) {
+ if (function_exists('opcache_reset')) {
+ opcache_reset();
+ }
+ if (!$systemConfig->getValue('maintenance', false)) {
+ self::printUpgradePage($systemConfig);
+ exit();
+ }
+ }
}
// emergency app disabling
@@ -968,7 +955,7 @@ class OC {
OC_App::loadApps(['authentication']);
// Load minimum set of apps
- if (!self::checkUpgrade(false)
+ if (!\OCP\Util::needUpgrade()
&& !$systemConfig->getValue('maintenance', false)) {
// For logged-in users: Load everything
if(\OC::$server->getUserSession()->isLoggedIn()) {
@@ -982,7 +969,7 @@ class OC {
if (!self::$CLI) {
try {
- if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) {
+ if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
OC_App::loadApps(array('filesystem', 'logging'));
OC_App::loadApps();
}
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index ad42e6ca02f..f29b9334fca 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -97,6 +97,7 @@ return array(
'OCP\\Contacts\\ContactsMenu\\IProvider' => $baseDir . '/lib/public/Contacts/ContactsMenu/IProvider.php',
'OCP\\Contacts\\IManager' => $baseDir . '/lib/public/Contacts/IManager.php',
'OCP\\DB' => $baseDir . '/lib/public/DB.php',
+ 'OCP\\DB\\ISchemaWrapper' => $baseDir . '/lib/public/DB/ISchemaWrapper.php',
'OCP\\DB\\QueryBuilder\\ICompositeExpression' => $baseDir . '/lib/public/DB/QueryBuilder/ICompositeExpression.php',
'OCP\\DB\\QueryBuilder\\IExpressionBuilder' => $baseDir . '/lib/public/DB/QueryBuilder/IExpressionBuilder.php',
'OCP\\DB\\QueryBuilder\\IFunctionBuilder' => $baseDir . '/lib/public/DB/QueryBuilder/IFunctionBuilder.php',
@@ -802,14 +803,7 @@ return array(
'OC\\Repair\\CleanTags' => $baseDir . '/lib/private/Repair/CleanTags.php',
'OC\\Repair\\Collation' => $baseDir . '/lib/private/Repair/Collation.php',
'OC\\Repair\\MoveUpdaterStepFile' => $baseDir . '/lib/private/Repair/MoveUpdaterStepFile.php',
- 'OC\\Repair\\NC11\\CleanPreviews' => $baseDir . '/lib/private/Repair/NC11/CleanPreviews.php',
- 'OC\\Repair\\NC11\\CleanPreviewsBackgroundJob' => $baseDir . '/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php',
'OC\\Repair\\NC11\\FixMountStorages' => $baseDir . '/lib/private/Repair/NC11/FixMountStorages.php',
- 'OC\\Repair\\NC11\\MoveAvatars' => $baseDir . '/lib/private/Repair/NC11/MoveAvatars.php',
- 'OC\\Repair\\NC11\\MoveAvatarsBackgroundJob' => $baseDir . '/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php',
- 'OC\\Repair\\NC12\\InstallCoreBundle' => $baseDir . '/lib/private/Repair/NC12/InstallCoreBundle.php',
- 'OC\\Repair\\NC12\\RepairIdentityProofKeyFolders' => $baseDir . '/lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php',
- 'OC\\Repair\\NC12\\UpdateLanguageCodes' => $baseDir . '/lib/private/Repair/NC12/UpdateLanguageCodes.php',
'OC\\Repair\\NC13\\AddLogRotateJob' => $baseDir . '/lib/private/Repair/NC13/AddLogRotateJob.php',
'OC\\Repair\\NC13\\RepairInvalidPaths' => $baseDir . '/lib/private/Repair/NC13/RepairInvalidPaths.php',
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 8adb289e626..def8abd8c55 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -127,6 +127,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Contacts\\ContactsMenu\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IProvider.php',
'OCP\\Contacts\\IManager' => __DIR__ . '/../../..' . '/lib/public/Contacts/IManager.php',
'OCP\\DB' => __DIR__ . '/../../..' . '/lib/public/DB.php',
+ 'OCP\\DB\\ISchemaWrapper' => __DIR__ . '/../../..' . '/lib/public/DB/ISchemaWrapper.php',
'OCP\\DB\\QueryBuilder\\ICompositeExpression' => __DIR__ . '/../../..' . '/lib/public/DB/QueryBuilder/ICompositeExpression.php',
'OCP\\DB\\QueryBuilder\\IExpressionBuilder' => __DIR__ . '/../../..' . '/lib/public/DB/QueryBuilder/IExpressionBuilder.php',
'OCP\\DB\\QueryBuilder\\IFunctionBuilder' => __DIR__ . '/../../..' . '/lib/public/DB/QueryBuilder/IFunctionBuilder.php',
@@ -832,14 +833,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Repair\\CleanTags' => __DIR__ . '/../../..' . '/lib/private/Repair/CleanTags.php',
'OC\\Repair\\Collation' => __DIR__ . '/../../..' . '/lib/private/Repair/Collation.php',
'OC\\Repair\\MoveUpdaterStepFile' => __DIR__ . '/../../..' . '/lib/private/Repair/MoveUpdaterStepFile.php',
- 'OC\\Repair\\NC11\\CleanPreviews' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/CleanPreviews.php',
- 'OC\\Repair\\NC11\\CleanPreviewsBackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php',
'OC\\Repair\\NC11\\FixMountStorages' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/FixMountStorages.php',
- 'OC\\Repair\\NC11\\MoveAvatars' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/MoveAvatars.php',
- 'OC\\Repair\\NC11\\MoveAvatarsBackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php',
- 'OC\\Repair\\NC12\\InstallCoreBundle' => __DIR__ . '/../../..' . '/lib/private/Repair/NC12/InstallCoreBundle.php',
- 'OC\\Repair\\NC12\\RepairIdentityProofKeyFolders' => __DIR__ . '/../../..' . '/lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php',
- 'OC\\Repair\\NC12\\UpdateLanguageCodes' => __DIR__ . '/../../..' . '/lib/private/Repair/NC12/UpdateLanguageCodes.php',
'OC\\Repair\\NC13\\AddLogRotateJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/AddLogRotateJob.php',
'OC\\Repair\\NC13\\RepairInvalidPaths' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/RepairInvalidPaths.php',
'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php',
diff --git a/lib/l10n/es_419.js b/lib/l10n/es_419.js
index c3504fda2e4..e411731e983 100644
--- a/lib/l10n/es_419.js
+++ b/lib/l10n/es_419.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Latin America)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_419.json b/lib/l10n/es_419.json
index 6d906b69458..99efb0dd215 100644
--- a/lib/l10n/es_419.json
+++ b/lib/l10n/es_419.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Latin America)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_AR.js b/lib/l10n/es_AR.js
index 476786a647f..ffb3ebe977e 100644
--- a/lib/l10n/es_AR.js
+++ b/lib/l10n/es_AR.js
@@ -61,6 +61,7 @@ OC.L10N.register(
"Encryption" : "Encripción",
"Additional settings" : "Configuraciones adicionales",
"Tips & tricks" : "Consejos y trucos",
+ "__language_name__" : "Español (Argentina)",
"%s enter the database username and name." : "%s ingrese el nombre del usuario y nombre de la base de datos",
"%s enter the database username." : "%s ingresar el nombre de usuario de la base de datos.",
"%s enter the database name." : "%s ingresar el nombre de la base de datos",
diff --git a/lib/l10n/es_AR.json b/lib/l10n/es_AR.json
index 76d5dad0332..03eb5ad4770 100644
--- a/lib/l10n/es_AR.json
+++ b/lib/l10n/es_AR.json
@@ -59,6 +59,7 @@
"Encryption" : "Encripción",
"Additional settings" : "Configuraciones adicionales",
"Tips & tricks" : "Consejos y trucos",
+ "__language_name__" : "Español (Argentina)",
"%s enter the database username and name." : "%s ingrese el nombre del usuario y nombre de la base de datos",
"%s enter the database username." : "%s ingresar el nombre de usuario de la base de datos.",
"%s enter the database name." : "%s ingresar el nombre de la base de datos",
diff --git a/lib/l10n/es_CL.js b/lib/l10n/es_CL.js
index c3504fda2e4..5feb169790e 100644
--- a/lib/l10n/es_CL.js
+++ b/lib/l10n/es_CL.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Chile)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_CL.json b/lib/l10n/es_CL.json
index 6d906b69458..51e3014cf1d 100644
--- a/lib/l10n/es_CL.json
+++ b/lib/l10n/es_CL.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Chile)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_CO.js b/lib/l10n/es_CO.js
index c3504fda2e4..1d08eb3dfca 100644
--- a/lib/l10n/es_CO.js
+++ b/lib/l10n/es_CO.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Colombia)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_CO.json b/lib/l10n/es_CO.json
index 6d906b69458..e65bf00def9 100644
--- a/lib/l10n/es_CO.json
+++ b/lib/l10n/es_CO.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Colombia)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_CR.js b/lib/l10n/es_CR.js
index c3504fda2e4..e7beef5b863 100644
--- a/lib/l10n/es_CR.js
+++ b/lib/l10n/es_CR.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Costa Rica)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_CR.json b/lib/l10n/es_CR.json
index 6d906b69458..2ee98c7ff3e 100644
--- a/lib/l10n/es_CR.json
+++ b/lib/l10n/es_CR.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Costa Rica)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_DO.js b/lib/l10n/es_DO.js
index c3504fda2e4..3f4a41410d9 100644
--- a/lib/l10n/es_DO.js
+++ b/lib/l10n/es_DO.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Dominican Republic)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_DO.json b/lib/l10n/es_DO.json
index 6d906b69458..6344dea931a 100644
--- a/lib/l10n/es_DO.json
+++ b/lib/l10n/es_DO.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Dominican Republic)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_EC.js b/lib/l10n/es_EC.js
index c3504fda2e4..5743caacee5 100644
--- a/lib/l10n/es_EC.js
+++ b/lib/l10n/es_EC.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Ecuador)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_EC.json b/lib/l10n/es_EC.json
index 6d906b69458..b8c002dd6d7 100644
--- a/lib/l10n/es_EC.json
+++ b/lib/l10n/es_EC.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Ecuador)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_GT.js b/lib/l10n/es_GT.js
index c3504fda2e4..645b677e6e8 100644
--- a/lib/l10n/es_GT.js
+++ b/lib/l10n/es_GT.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Guatemala)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_GT.json b/lib/l10n/es_GT.json
index 6d906b69458..7f993a6d4ed 100644
--- a/lib/l10n/es_GT.json
+++ b/lib/l10n/es_GT.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Guatemala)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_HN.js b/lib/l10n/es_HN.js
index c3504fda2e4..4c3d0ec62ba 100644
--- a/lib/l10n/es_HN.js
+++ b/lib/l10n/es_HN.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Honduras)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_HN.json b/lib/l10n/es_HN.json
index 6d906b69458..979a4d26ebf 100644
--- a/lib/l10n/es_HN.json
+++ b/lib/l10n/es_HN.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Honduras)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_NI.js b/lib/l10n/es_NI.js
index c3504fda2e4..55fdbf10030 100644
--- a/lib/l10n/es_NI.js
+++ b/lib/l10n/es_NI.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Nicaragua)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_NI.json b/lib/l10n/es_NI.json
index 6d906b69458..b32c358cbcf 100644
--- a/lib/l10n/es_NI.json
+++ b/lib/l10n/es_NI.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Nicaragua)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PA.js b/lib/l10n/es_PA.js
index c3504fda2e4..ab5766d018e 100644
--- a/lib/l10n/es_PA.js
+++ b/lib/l10n/es_PA.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Panama)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PA.json b/lib/l10n/es_PA.json
index 6d906b69458..5cf43264fd8 100644
--- a/lib/l10n/es_PA.json
+++ b/lib/l10n/es_PA.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Panama)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PE.js b/lib/l10n/es_PE.js
index c3504fda2e4..47c19e43ba1 100644
--- a/lib/l10n/es_PE.js
+++ b/lib/l10n/es_PE.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Peru)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PE.json b/lib/l10n/es_PE.json
index 6d906b69458..642f0ba1321 100644
--- a/lib/l10n/es_PE.json
+++ b/lib/l10n/es_PE.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Peru)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PR.js b/lib/l10n/es_PR.js
index c3504fda2e4..c1b1e804373 100644
--- a/lib/l10n/es_PR.js
+++ b/lib/l10n/es_PR.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Puerto Rico)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PR.json b/lib/l10n/es_PR.json
index 6d906b69458..9b06e739966 100644
--- a/lib/l10n/es_PR.json
+++ b/lib/l10n/es_PR.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Puerto Rico)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PY.js b/lib/l10n/es_PY.js
index c3504fda2e4..5ed54944e3b 100644
--- a/lib/l10n/es_PY.js
+++ b/lib/l10n/es_PY.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Paraguay)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_PY.json b/lib/l10n/es_PY.json
index 6d906b69458..33878723759 100644
--- a/lib/l10n/es_PY.json
+++ b/lib/l10n/es_PY.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Paraguay)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_SV.js b/lib/l10n/es_SV.js
index c3504fda2e4..bccb8a1aac1 100644
--- a/lib/l10n/es_SV.js
+++ b/lib/l10n/es_SV.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (El Salvador)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_SV.json b/lib/l10n/es_SV.json
index 6d906b69458..e4f28af7fb4 100644
--- a/lib/l10n/es_SV.json
+++ b/lib/l10n/es_SV.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (El Salvador)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_UY.js b/lib/l10n/es_UY.js
index c3504fda2e4..c0535ba322b 100644
--- a/lib/l10n/es_UY.js
+++ b/lib/l10n/es_UY.js
@@ -75,7 +75,7 @@ OC.L10N.register(
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Uruguay)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/l10n/es_UY.json b/lib/l10n/es_UY.json
index 6d906b69458..c298c7ed8d3 100644
--- a/lib/l10n/es_UY.json
+++ b/lib/l10n/es_UY.json
@@ -73,7 +73,7 @@
"Personal info" : "Información personal",
"Sync clients" : "Sincronizar clientes",
"Unlimited" : "Ilimitado",
- "__language_name__" : "Español (México)",
+ "__language_name__" : "Español (Uruguay)",
"Verifying" : "Verficando",
"Verifying …" : "Verficando ...",
"Verify" : "Verificar",
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index f74a2f943d5..745bab367d3 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -152,7 +152,7 @@ class AllConfig implements \OCP\IConfig {
* @return string[] the keys stored for the app
*/
public function getAppKeys($appName) {
- return \OC::$server->getAppConfig()->getKeys($appName);
+ return \OC::$server->query(\OC\AppConfig::class)->getKeys($appName);
}
/**
@@ -163,7 +163,7 @@ class AllConfig implements \OCP\IConfig {
* @param string|float|int $value the value that should be stored
*/
public function setAppValue($appName, $key, $value) {
- \OC::$server->getAppConfig()->setValue($appName, $key, $value);
+ \OC::$server->query(\OC\AppConfig::class)->setValue($appName, $key, $value);
}
/**
@@ -175,7 +175,7 @@ class AllConfig implements \OCP\IConfig {
* @return string the saved value
*/
public function getAppValue($appName, $key, $default = '') {
- return \OC::$server->getAppConfig()->getValue($appName, $key, $default);
+ return \OC::$server->query(\OC\AppConfig::class)->getValue($appName, $key, $default);
}
/**
@@ -185,7 +185,7 @@ class AllConfig implements \OCP\IConfig {
* @param string $key the key of the value, under which it was saved
*/
public function deleteAppValue($appName, $key) {
- \OC::$server->getAppConfig()->deleteKey($appName, $key);
+ \OC::$server->query(\OC\AppConfig::class)->deleteKey($appName, $key);
}
/**
@@ -194,7 +194,7 @@ class AllConfig implements \OCP\IConfig {
* @param string $appName the appName the configs are stored under
*/
public function deleteAppValues($appName) {
- \OC::$server->getAppConfig()->deleteApp($appName);
+ \OC::$server->query(\OC\AppConfig::class)->deleteApp($appName);
}
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index e7d4668931c..f2b396b29d0 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -32,10 +32,10 @@
namespace OC\App;
+use OC\AppConfig;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\App\ManagerEvent;
-use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IUser;
@@ -59,7 +59,7 @@ class AppManager implements IAppManager {
/** @var IUserSession */
private $userSession;
- /** @var IAppConfig */
+ /** @var AppConfig */
private $appConfig;
/** @var IGroupManager */
@@ -82,13 +82,13 @@ class AppManager implements IAppManager {
/**
* @param IUserSession $userSession
- * @param IAppConfig $appConfig
+ * @param AppConfig $appConfig
* @param IGroupManager $groupManager
* @param ICacheFactory $memCacheFactory
* @param EventDispatcherInterface $dispatcher
*/
public function __construct(IUserSession $userSession,
- IAppConfig $appConfig,
+ AppConfig $appConfig,
IGroupManager $groupManager,
ICacheFactory $memCacheFactory,
EventDispatcherInterface $dispatcher) {
diff --git a/lib/private/App/CodeChecker/DeprecationCheck.php b/lib/private/App/CodeChecker/DeprecationCheck.php
index c8b8d639f46..95d0762e093 100644
--- a/lib/private/App/CodeChecker/DeprecationCheck.php
+++ b/lib/private/App/CodeChecker/DeprecationCheck.php
@@ -44,6 +44,7 @@ class DeprecationCheck extends AbstractCheck implements ICheck {
'OCP\JSON' => '8.1.0',
'OCP\Response' => '8.1.0',
'OCP\AppFramework\IApi' => '8.0.0',
+ 'OCP\User' => '13.0.0',
];
}
@@ -141,6 +142,9 @@ class DeprecationCheck extends AbstractCheck implements ICheck {
'OCP\User::userExists' => '8.1.0',
'OCP\User::logout' => '8.1.0',
'OCP\User::checkPassword' => '8.1.0',
+ 'OCP\User::isLoggedIn' => '13.0.0',
+ 'OCP\User::checkAdminUser' => '13.0.0',
+ 'OCP\User::checkLoggedIn' => '13.0.0',
'OCP\Util::encryptedFiles' => '8.1.0',
'OCP\Util::formatDate' => '8.0.0',
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index 4e102522550..59a340cb491 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -101,7 +101,6 @@ class AppConfig implements IAppConfig {
*
* @param string $app the app we are looking for
* @return array an array of key names
- * @deprecated 8.0.0 use method getAppKeys of \OCP\IConfig
*
* This function gets all keys of an app. Please note that the values are
* not returned.
@@ -129,7 +128,6 @@ class AppConfig implements IAppConfig {
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @return string the value or $default
- * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig
*
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
@@ -164,7 +162,6 @@ class AppConfig implements IAppConfig {
* @param string $key key
* @param string|float|int $value value
* @return bool True if the value was inserted or updated, false if the value was the same
- * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
*/
public function setValue($app, $key, $value) {
if (!$this->hasKey($app, $key)) {
@@ -220,7 +217,6 @@ class AppConfig implements IAppConfig {
* @param string $app app
* @param string $key key
* @return boolean
- * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig
*/
public function deleteKey($app, $key) {
$this->loadConfigValues();
@@ -242,7 +238,6 @@ class AppConfig implements IAppConfig {
*
* @param string $app app
* @return boolean
- * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig
*
* Removes all keys in appconfig belonging to the app.
*/
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php
index 77ecb02165b..975c4255d5a 100644
--- a/lib/private/AppFramework/Http/Request.php
+++ b/lib/private/AppFramework/Http/Request.php
@@ -324,7 +324,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
}
- return null;
+ return '';
}
/**
@@ -404,8 +404,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
protected function getContent() {
// If the content can't be parsed into an array then return a stream resource.
if ($this->method === 'PUT'
- && $this->getHeader('Content-Length') !== 0
- && $this->getHeader('Content-Length') !== null
+ && $this->getHeader('Content-Length') !== '0'
&& $this->getHeader('Content-Length') !== ''
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index afa9118c509..ce3fcff396e 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -117,7 +117,24 @@ class Avatar implements IAvatar {
$img = $data;
$data = $img->data();
} else {
- $img = new OC_Image($data);
+ $img = new OC_Image();
+ if (is_resource($data) && get_resource_type($data) === "gd") {
+ $img->setResource($data);
+ } elseif(is_resource($data)) {
+ $img->loadFromFileHandle($data);
+ } else {
+ try {
+ // detect if it is a path or maybe the images as string
+ $result = @realpath($data);
+ if ($result === false || $result === null) {
+ $img->loadFromData($data);
+ } else {
+ $img->loadFromFile($data);
+ }
+ } catch (\Error $e) {
+ $img->loadFromData($data);
+ }
+ }
}
$type = substr($img->mimeType(), -3);
if ($type === 'peg') {
diff --git a/lib/private/AvatarManager.php b/lib/private/AvatarManager.php
index b8c6c2a1eb6..eb455642101 100644
--- a/lib/private/AvatarManager.php
+++ b/lib/private/AvatarManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -27,12 +28,13 @@
namespace OC;
+use OC\User\Manager;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
+use OCP\IAvatar;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\ILogger;
-use OCP\IUserManager;
use OCP\IL10N;
/**
@@ -40,7 +42,7 @@ use OCP\IL10N;
*/
class AvatarManager implements IAvatarManager {
- /** @var IUserManager */
+ /** @var Manager */
private $userManager;
/** @var IAppData */
@@ -58,14 +60,14 @@ class AvatarManager implements IAvatarManager {
/**
* AvatarManager constructor.
*
- * @param IUserManager $userManager
+ * @param Manager $userManager
* @param IAppData $appData
* @param IL10N $l
* @param ILogger $logger
* @param IConfig $config
*/
public function __construct(
- IUserManager $userManager,
+ Manager $userManager,
IAppData $appData,
IL10N $l,
ILogger $logger,
@@ -85,9 +87,9 @@ class AvatarManager implements IAvatarManager {
* @throws \Exception In case the username is potentially dangerous
* @throws NotFoundException In case there is no user folder yet
*/
- public function getAvatar($userId) {
+ public function getAvatar(string $userId) : IAvatar {
$user = $this->userManager->get($userId);
- if (is_null($user)) {
+ if ($user === null) {
throw new \Exception('user does not exist');
}
diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php
index e9b15dd1201..bb1bd6d1711 100644
--- a/lib/private/Collaboration/Collaborators/Search.php
+++ b/lib/private/Collaboration/Collaborators/Search.php
@@ -40,6 +40,15 @@ class Search implements ISearch {
$this->c = $c;
}
+ /**
+ * @param string $search
+ * @param array $shareTypes
+ * @param bool $lookup
+ * @param int|null $limit
+ * @param int|null $offset
+ * @return array
+ * @throws \OCP\AppFramework\QueryException
+ */
public function search($search, array $shareTypes, $lookup, $limit, $offset) {
$hasMoreResults = false;
diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php
index 86a55aa428f..ad677703547 100644
--- a/lib/private/Collaboration/Collaborators/UserPlugin.php
+++ b/lib/private/Collaboration/Collaborators/UserPlugin.php
@@ -83,6 +83,8 @@ class UserPlugin implements ISearchPlugin {
}
}
+ $this->takeOutCurrentUser($users);
+
if (!$this->shareeEnumeration || sizeof($users) < $limit) {
$hasMoreResults = true;
}
@@ -146,4 +148,13 @@ class UserPlugin implements ISearchPlugin {
return $hasMoreResults;
}
+
+ public function takeOutCurrentUser(array &$users) {
+ $currentUser = $this->userSession->getUser();
+ if(!is_null($currentUser)) {
+ if (isset($users[$currentUser->getUID()])) {
+ unset($users[$currentUser->getUID()]);
+ }
+ }
+ }
}
diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php
index acfebd32028..dd790c2e50a 100644
--- a/lib/private/Comments/Comment.php
+++ b/lib/private/Comments/Comment.php
@@ -232,10 +232,6 @@ class Comment implements IComment {
$uids = array_unique($mentions[0]);
$result = [];
foreach ($uids as $uid) {
- // exclude author, no self-mentioning
- if($uid === '@' . $this->getActorId()) {
- continue;
- }
$result[] = ['type' => 'user', 'id' => substr($uid, 1)];
}
return $result;
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php
index 0a05b2ac0f3..c85b67217b4 100644
--- a/lib/private/Console/Application.php
+++ b/lib/private/Console/Application.php
@@ -127,7 +127,7 @@ class Application {
}
}
}
- } else if ($input->getArgument('command') !== '_completion') {
+ } else if ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
$output->writeln("Nextcloud is not installed - only a limited number of commands are available");
}
} catch(NeedsUpdateException $e) {
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index cbe5bd9b957..89a8d42f08a 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -129,7 +129,7 @@ class MigrationService {
}
// Drop the table, when it didn't match our expectations.
- $this->connection->dropTable($this->connection->getPrefix() . 'migrations');
+ $this->connection->dropTable('migrations');
} catch (SchemaException $e) {
// Table not found, no need to panic, we will create it.
}
@@ -423,7 +423,7 @@ class MigrationService {
}
$instance->preSchemaChange($this->output, function() {
- return $this->connection->createSchema();
+ return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
$toSchema = $instance->changeSchema($this->output, function() {
@@ -436,7 +436,7 @@ class MigrationService {
}
$instance->postSchemaChange($this->output, function() {
- return $this->connection->createSchema();
+ return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
$this->markAsExecuted($version);
diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php
index 2a0660b2a88..4f05b7b00ef 100644
--- a/lib/private/DB/SchemaWrapper.php
+++ b/lib/private/DB/SchemaWrapper.php
@@ -25,9 +25,10 @@ namespace OC\DB;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
+use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
-class SchemaWrapper {
+class SchemaWrapper implements ISchemaWrapper {
/** @var IDBConnection|Connection */
protected $connection;
@@ -76,6 +77,13 @@ class SchemaWrapper {
// Overwritten methods
/**
+ * @return array
+ */
+ public function getTableNames() {
+ return $this->schema->getTableNames();
+ }
+
+ /**
* @param string $tableName
*
* @return \Doctrine\DBAL\Schema\Table
@@ -107,19 +115,6 @@ class SchemaWrapper {
}
/**
- * Renames a table.
- *
- * @param string $oldTableName
- * @param string $newTableName
- *
- * @return \Doctrine\DBAL\Schema\Schema
- * @throws DBALException
- */
- public function renameTable($oldTableName, $newTableName) {
- throw new DBALException('Renaming tables is not supported. Please create and drop the tables manually.');
- }
-
- /**
* Drops a table from the schema.
*
* @param string $tableName
@@ -131,11 +126,11 @@ class SchemaWrapper {
}
/**
- * @param string $name
- * @param array $arguments
- * @return mixed
+ * Gets all tables of this schema.
+ *
+ * @return \Doctrine\DBAL\Schema\Table[]
*/
- public function __call($name, $arguments) {
- return call_user_func_array([$this->schema, $name], $arguments);
+ public function getTables() {
+ return $this->schema->getTables();
}
}
diff --git a/lib/private/Federation/CloudId.php b/lib/private/Federation/CloudId.php
index f1d08f0687d..4c93650e0fc 100644
--- a/lib/private/Federation/CloudId.php
+++ b/lib/private/Federation/CloudId.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017, Robin Appelman <robin@icewind.nl>
*
@@ -40,7 +41,7 @@ class CloudId implements ICloudId {
* @param string $user
* @param string $remote
*/
- public function __construct($id, $user, $remote) {
+ public function __construct(string $id, string $user, string $remote) {
$this->id = $id;
$this->user = $user;
$this->remote = $remote;
@@ -51,11 +52,11 @@ class CloudId implements ICloudId {
*
* @return string
*/
- public function getId() {
+ public function getId(): string {
return $this->id;
}
- public function getDisplayId() {
+ public function getDisplayId(): string {
return str_replace('https://', '', str_replace('http://', '', $this->getId()));
}
@@ -64,7 +65,7 @@ class CloudId implements ICloudId {
*
* @return string
*/
- public function getUser() {
+ public function getUser(): string {
return $this->user;
}
@@ -73,7 +74,7 @@ class CloudId implements ICloudId {
*
* @return string
*/
- public function getRemote() {
+ public function getRemote(): string {
return $this->remote;
}
}
diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php
index 3b7aaae5392..0beb6cf6d29 100644
--- a/lib/private/Federation/CloudIdManager.php
+++ b/lib/private/Federation/CloudIdManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017, Robin Appelman <robin@icewind.nl>
*
@@ -33,7 +34,7 @@ class CloudIdManager implements ICloudIdManager {
* @return ICloudId
* @throws \InvalidArgumentException
*/
- public function resolveCloudId($cloudId) {
+ public function resolveCloudId(string $cloudId): ICloudId {
// TODO magic here to get the url and user instead of just splitting on @
if (!$this->isValidCloudId($cloudId)) {
@@ -46,7 +47,7 @@ class CloudIdManager implements ICloudIdManager {
$posColon = strpos($id, ':');
if ($posSlash === false && $posColon === false) {
- $invalidPos = strlen($id);
+ $invalidPos = \strlen($id);
} else if ($posSlash === false) {
$invalidPos = $posColon;
} else if ($posColon === false) {
@@ -77,7 +78,7 @@ class CloudIdManager implements ICloudIdManager {
* @param string $remote
* @return CloudId
*/
- public function getCloudId($user, $remote) {
+ public function getCloudId(string $user, string $remote): ICloudId {
// TODO check what the correct url is for remote (asking the remote)
return new CloudId($user. '@' . $remote, $user, $remote);
}
@@ -94,7 +95,7 @@ class CloudIdManager implements ICloudIdManager {
* @param string $remote
* @return string
*/
- protected function fixRemoteURL($remote) {
+ protected function fixRemoteURL(string $remote): string {
$remote = str_replace('\\', '/', $remote);
if ($fileNamePosition = strpos($remote, '/index.php')) {
$remote = substr($remote, 0, $fileNamePosition);
@@ -108,7 +109,7 @@ class CloudIdManager implements ICloudIdManager {
* @param string $cloudId
* @return bool
*/
- public function isValidCloudId($cloudId) {
+ public function isValidCloudId(string $cloudId): bool {
return strpos($cloudId, '@') !== false;
}
}
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index 51ecb12a06a..ac64ba5c592 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -83,6 +83,16 @@ class QuerySearchHelper {
return false;
}
+ /**
+ * @param IQueryBuilder $builder
+ * @param ISearchOperator $operator
+ */
+ public function searchOperatorArrayToDBExprArray(IQueryBuilder $builder, array $operators) {
+ return array_map(function ($operator) use ($builder) {
+ return $this->searchOperatorToDBExpr($builder, $operator);
+ }, $operators);
+ }
+
public function searchOperatorToDBExpr(IQueryBuilder $builder, ISearchOperator $operator) {
$expr = $builder->expr();
if ($operator instanceof ISearchBinaryOperator) {
@@ -95,9 +105,9 @@ class QuerySearchHelper {
throw new \InvalidArgumentException('Binary operators inside "not" is not supported');
}
case ISearchBinaryOperator::OPERATOR_AND:
- return $expr->andX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ return call_user_func_array([$expr, 'andX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments()));
case ISearchBinaryOperator::OPERATOR_OR:
- return $expr->orX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ return call_user_func_array([$expr, 'orX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments()));
default:
throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType());
}
diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php
index 4697f2e038c..4e6843d7b9f 100644
--- a/lib/private/Http/Client/Client.php
+++ b/lib/private/Http/Client/Client.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -25,6 +26,7 @@ namespace OC\Http\Client;
use GuzzleHttp\Client as GuzzleClient;
use OCP\Http\Client\IClient;
+use OCP\Http\Client\IResponse;
use OCP\ICertificateManager;
use OCP\IConfig;
@@ -89,7 +91,7 @@ class Client implements IClient {
*
* @return string
*/
- private function getProxyUri() {
+ private function getProxyUri(): string {
$proxyHost = $this->config->getSystemValue('proxy', null);
$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null);
$proxyUri = '';
@@ -130,10 +132,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function get($uri, array $options = []) {
+ public function get(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->get($uri, $options);
$isStream = isset($options['stream']) && $options['stream'];
@@ -161,10 +163,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function head($uri, $options = []) {
+ public function head(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->head($uri, $options);
return new Response($response);
@@ -196,10 +198,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function post($uri, array $options = []) {
+ public function post(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->post($uri, $options);
return new Response($response);
@@ -231,10 +233,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function put($uri, array $options = []) {
+ public function put(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->put($uri, $options);
return new Response($response);
@@ -266,10 +268,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function delete($uri, array $options = []) {
+ public function delete(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->delete($uri, $options);
return new Response($response);
@@ -302,10 +304,10 @@ class Client implements IClient {
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
- * @return Response
+ * @return IResponse
* @throws \Exception If the request could not get completed
*/
- public function options($uri, array $options = []) {
+ public function options(string $uri, array $options = []): IResponse {
$this->setDefaultOptions();
$response = $this->client->options($uri, $options);
return new Response($response);
diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php
index 108ffa709cf..1df54010a2d 100644
--- a/lib/private/Http/Client/ClientService.php
+++ b/lib/private/Http/Client/ClientService.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -23,6 +24,7 @@
namespace OC\Http\Client;
use GuzzleHttp\Client as GuzzleClient;
+use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\ICertificateManager;
use OCP\IConfig;
@@ -51,7 +53,7 @@ class ClientService implements IClientService {
/**
* @return Client
*/
- public function newClient() {
+ public function newClient(): IClient {
return new Client($this->config, $this->certificateManager, new GuzzleClient());
}
}
diff --git a/lib/private/Http/Client/Response.php b/lib/private/Http/Client/Response.php
index 48885de9f3a..0ce6cc98e0d 100644
--- a/lib/private/Http/Client/Response.php
+++ b/lib/private/Http/Client/Response.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -24,7 +25,7 @@
namespace OC\Http\Client;
use OCP\Http\Client\IResponse;
-use GuzzleHttp\Message\Response as GuzzleResponse;
+use GuzzleHttp\Message\ResponseInterface as GuzzleResponse;
/**
* Class Response
@@ -61,22 +62,22 @@ class Response implements IResponse {
/**
* @return int
*/
- public function getStatusCode() {
+ public function getStatusCode(): int {
return $this->response->getStatusCode();
}
/**
- * @param $key
+ * @param string $key
* @return string
*/
- public function getHeader($key) {
+ public function getHeader(string $key): string {
return $this->response->getHeader($key);
}
/**
* @return array
*/
- public function getHeaders() {
+ public function getHeaders(): array {
return $this->response->getHeaders();
}
}
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index 4dcf5a8dad9..1c6c3915b41 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -133,7 +133,7 @@ class Installer {
//install the database
if(is_file($basedir.'/appinfo/database.xml')) {
- if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
+ if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) {
OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
} else {
OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml');
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index e277a00e653..8268be05d4b 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -247,7 +247,7 @@ class Factory implements IFactory {
*/
private function getLanguageFromRequest($app) {
$header = $this->request->getHeader('ACCEPT_LANGUAGE');
- if ($header) {
+ if ($header !== '') {
$available = $this->findAvailableLanguages($app);
// E.g. make sure that 'de' is before 'de_DE'.
diff --git a/lib/private/Lock/AbstractLockingProvider.php b/lib/private/Lock/AbstractLockingProvider.php
index 6ad1dd7ca1b..f7f0ee34a12 100644
--- a/lib/private/Lock/AbstractLockingProvider.php
+++ b/lib/private/Lock/AbstractLockingProvider.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -29,6 +30,7 @@ use OCP\Lock\ILockingProvider;
* to release any left over locks at the end of the request
*/
abstract class AbstractLockingProvider implements ILockingProvider {
+ /** @var int $ttl */
protected $ttl; // how long until we clear stray locks in seconds
protected $acquiredLocks = [
@@ -43,7 +45,7 @@ abstract class AbstractLockingProvider implements ILockingProvider {
* @param int $type
* @return bool
*/
- protected function hasAcquiredLock($path, $type) {
+ protected function hasAcquiredLock(string $path, int $type): bool {
if ($type === self::LOCK_SHARED) {
return isset($this->acquiredLocks['shared'][$path]) && $this->acquiredLocks['shared'][$path] > 0;
} else {
@@ -57,7 +59,7 @@ abstract class AbstractLockingProvider implements ILockingProvider {
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- protected function markAcquire($path, $type) {
+ protected function markAcquire(string $path, int $type) {
if ($type === self::LOCK_SHARED) {
if (!isset($this->acquiredLocks['shared'][$path])) {
$this->acquiredLocks['shared'][$path] = 0;
@@ -74,7 +76,7 @@ abstract class AbstractLockingProvider implements ILockingProvider {
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- protected function markRelease($path, $type) {
+ protected function markRelease(string $path, int $type) {
if ($type === self::LOCK_SHARED) {
if (isset($this->acquiredLocks['shared'][$path]) and $this->acquiredLocks['shared'][$path] > 0) {
$this->acquiredLocks['shared'][$path]--;
@@ -93,7 +95,7 @@ abstract class AbstractLockingProvider implements ILockingProvider {
* @param string $path
* @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- protected function markChange($path, $targetType) {
+ protected function markChange(string $path, int $targetType) {
if ($targetType === self::LOCK_SHARED) {
unset($this->acquiredLocks['exclusive'][$path]);
if (!isset($this->acquiredLocks['shared'][$path])) {
@@ -121,7 +123,7 @@ abstract class AbstractLockingProvider implements ILockingProvider {
}
}
- protected function getOwnSharedLockCount($path) {
+ protected function getOwnSharedLockCount(string $path) {
return isset($this->acquiredLocks['shared'][$path]) ? $this->acquiredLocks['shared'][$path] : 0;
}
}
diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php
index 9de1098a466..016be64c097 100644
--- a/lib/private/Lock/DBLockingProvider.php
+++ b/lib/private/Lock/DBLockingProvider.php
@@ -61,7 +61,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param string $path
* @return bool
*/
- protected function isLocallyLocked($path) {
+ protected function isLocallyLocked(string $path): bool {
return isset($this->sharedLocks[$path]) && $this->sharedLocks[$path];
}
@@ -71,7 +71,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- protected function markAcquire($path, $type) {
+ protected function markAcquire(string $path, int $type) {
parent::markAcquire($path, $type);
if ($type === self::LOCK_SHARED) {
$this->sharedLocks[$path] = true;
@@ -84,7 +84,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param string $path
* @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- protected function markChange($path, $targetType) {
+ protected function markChange(string $path, int $targetType) {
parent::markChange($path, $targetType);
if ($targetType === self::LOCK_SHARED) {
$this->sharedLocks[$path] = true;
@@ -99,7 +99,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory
* @param int $ttl
*/
- public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory, $ttl = 3600) {
+ public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory, int $ttl = 3600) {
$this->connection = $connection;
$this->logger = $logger;
$this->timeFactory = $timeFactory;
@@ -114,7 +114,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @return int number of inserted rows
*/
- protected function initLockField($path, $lock = 0) {
+ protected function initLockField(string $path, int $lock = 0): int {
$expire = $this->getExpireTime();
return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']);
}
@@ -122,7 +122,7 @@ class DBLockingProvider extends AbstractLockingProvider {
/**
* @return int
*/
- protected function getExpireTime() {
+ protected function getExpireTime(): int {
return $this->timeFactory->getTime() + $this->ttl;
}
@@ -131,7 +131,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @return bool
*/
- public function isLocked($path, $type) {
+ public function isLocked(string $path, int $type): bool {
if ($this->hasAcquiredLock($path, $type)) {
return true;
}
@@ -157,7 +157,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
- public function acquireLock($path, $type) {
+ public function acquireLock(string $path, int $type) {
$expire = $this->getExpireTime();
if ($type === self::LOCK_SHARED) {
if (!$this->isLocallyLocked($path)) {
@@ -194,7 +194,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- public function releaseLock($path, $type) {
+ public function releaseLock(string $path, int $type) {
$this->markRelease($path, $type);
// we keep shared locks till the end of the request so we can re-use them
@@ -213,7 +213,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
- public function changeLock($path, $targetType) {
+ public function changeLock(string $path, int $targetType) {
$expire = $this->getExpireTime();
if ($targetType === self::LOCK_SHARED) {
$result = $this->connection->executeUpdate(
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php
index c4b1469b50f..70ad972b46d 100644
--- a/lib/private/Lock/MemcacheLockingProvider.php
+++ b/lib/private/Lock/MemcacheLockingProvider.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -36,12 +37,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
* @param \OCP\IMemcache $memcache
* @param int $ttl
*/
- public function __construct(IMemcache $memcache, $ttl = 3600) {
+ public function __construct(IMemcache $memcache, int $ttl = 3600) {
$this->memcache = $memcache;
$this->ttl = $ttl;
}
- private function setTTL($path) {
+ private function setTTL(string $path) {
if ($this->memcache instanceof IMemcacheTTL) {
$this->memcache->setTTL($path, $this->ttl);
}
@@ -52,7 +53,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @return bool
*/
- public function isLocked($path, $type) {
+ public function isLocked(string $path, int $type): bool {
$lockValue = $this->memcache->get($path);
if ($type === self::LOCK_SHARED) {
return $lockValue > 0;
@@ -68,7 +69,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
- public function acquireLock($path, $type) {
+ public function acquireLock(string $path, int $type) {
if ($type === self::LOCK_SHARED) {
if (!$this->memcache->inc($path)) {
throw new LockedException($path);
@@ -87,7 +88,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
- public function releaseLock($path, $type) {
+ public function releaseLock(string $path, int $type) {
if ($type === self::LOCK_SHARED) {
if ($this->getOwnSharedLockCount($path) === 1) {
$removed = $this->memcache->cad($path, 1); // if we're the only one having a shared lock we can remove it in one go
@@ -111,7 +112,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
* @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
- public function changeLock($path, $targetType) {
+ public function changeLock(string $path, int $targetType) {
if ($targetType === self::LOCK_SHARED) {
if (!$this->memcache->cas($path, 'exclusive', 1)) {
throw new LockedException($path);
diff --git a/lib/private/Lock/NoopLockingProvider.php b/lib/private/Lock/NoopLockingProvider.php
index 6dfbd8ccb44..9133f818033 100644
--- a/lib/private/Lock/NoopLockingProvider.php
+++ b/lib/private/Lock/NoopLockingProvider.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -32,24 +33,24 @@ use OCP\Lock\ILockingProvider;
*/
class NoopLockingProvider implements ILockingProvider {
- /**
- * {@inheritdoc}
- */
- public function isLocked($path, $type) {
+ /**
+ * {@inheritdoc}
+ */
+ public function isLocked(string $path, int $type): bool {
return false;
}
- /**
- * {@inheritdoc}
- */
- public function acquireLock($path, $type) {
+ /**
+ * {@inheritdoc}
+ */
+ public function acquireLock(string $path, int $type) {
// do nothing
}
/**
- * {@inheritdoc}
+ * {@inheritdoc}
*/
- public function releaseLock($path, $type) {
+ public function releaseLock(string $path, int $type) {
// do nothing
}
@@ -63,7 +64,7 @@ class NoopLockingProvider implements ILockingProvider {
/**
* {@inheritdoc}
*/
- public function changeLock($path, $targetType) {
+ public function changeLock(string $path, int $targetType) {
// do nothing
}
}
diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php
index b6a208ad68a..290f7897c9d 100644
--- a/lib/private/Log/File.php
+++ b/lib/private/Log/File.php
@@ -105,7 +105,10 @@ class File {
} else {
$user = '--';
}
- $userAgent = $request->getHeader('User-Agent') ?: '--';
+ $userAgent = $request->getHeader('User-Agent');
+ if ($userAgent === '') {
+ $userAgent = '--';
+ }
$version = $config->getValue('version', '');
$entry = compact(
'reqId',
diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php
index 70f0d73d2d4..3e96acdecb7 100644
--- a/lib/private/Memcache/APCu.php
+++ b/lib/private/Memcache/APCu.php
@@ -158,8 +158,8 @@ class APCu extends Cache implements IMemcache {
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
return false;
} elseif (
- version_compare(phpversion('apc'), '4.0.6') === -1 &&
- version_compare(phpversion('apcu'), '5.1.0') === -1
+ version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 &&
+ version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1
) {
return false;
} else {
diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php
index ff539e55420..b79f17ba8ea 100644
--- a/lib/private/Memcache/Factory.php
+++ b/lib/private/Memcache/Factory.php
@@ -31,8 +31,10 @@
namespace OC\Memcache;
-use \OCP\ICacheFactory;
-use \OCP\ILogger;
+use OCP\ICache;
+use OCP\ICacheFactory;
+use OCP\ILogger;
+use OCP\IMemcache;
class Factory implements ICacheFactory {
const NULL_CACHE = '\\OC\\Memcache\\NullCache';
@@ -69,7 +71,7 @@ class Factory implements ICacheFactory {
* @param string|null $distributedCacheClass
* @param string|null $lockingCacheClass
*/
- public function __construct($globalPrefix, ILogger $logger,
+ public function __construct(string $globalPrefix, ILogger $logger,
$localCacheClass = null, $distributedCacheClass = null, $lockingCacheClass = null)
{
$this->logger = $logger;
@@ -128,9 +130,9 @@ class Factory implements ICacheFactory {
* create a cache instance for storing locks
*
* @param string $prefix
- * @return \OCP\IMemcache
+ * @return IMemcache
*/
- public function createLocking($prefix = '') {
+ public function createLocking(string $prefix = ''): IMemcache {
return new $this->lockingCacheClass($this->globalPrefix . '/' . $prefix);
}
@@ -138,9 +140,9 @@ class Factory implements ICacheFactory {
* create a distributed cache instance
*
* @param string $prefix
- * @return \OC\Memcache\Cache
+ * @return ICache
*/
- public function createDistributed($prefix = '') {
+ public function createDistributed(string $prefix = ''): ICache {
return new $this->distributedCacheClass($this->globalPrefix . '/' . $prefix);
}
@@ -148,18 +150,19 @@ class Factory implements ICacheFactory {
* create a local cache instance
*
* @param string $prefix
- * @return \OC\Memcache\Cache
+ * @return ICache
*/
- public function createLocal($prefix = '') {
+ public function createLocal(string $prefix = ''): ICache {
return new $this->localCacheClass($this->globalPrefix . '/' . $prefix);
}
/**
* @see \OC\Memcache\Factory::createDistributed()
* @param string $prefix
- * @return \OC\Memcache\Cache
+ * @return ICache
+ * @deprecated 13.0.0 Use either createLocking, createDistributed or createLocal
*/
- public function create($prefix = '') {
+ public function create(string $prefix = ''): ICache {
return $this->createDistributed($prefix);
}
@@ -168,16 +171,16 @@ class Factory implements ICacheFactory {
*
* @return bool
*/
- public function isAvailable() {
+ public function isAvailable(): bool {
return ($this->distributedCacheClass !== self::NULL_CACHE);
}
/**
* @see \OC\Memcache\Factory::createLocal()
* @param string $prefix
- * @return Cache
+ * @return ICache
*/
- public function createLowLatency($prefix = '') {
+ public function createLowLatency(string $prefix = ''): ICache {
return $this->createLocal($prefix);
}
@@ -186,7 +189,7 @@ class Factory implements ICacheFactory {
*
* @return bool
*/
- public function isAvailableLowLatency() {
+ public function isAvailableLowLatency(): bool {
return ($this->localCacheClass !== self::NULL_CACHE);
}
}
diff --git a/lib/private/OCS/DiscoveryService.php b/lib/private/OCS/DiscoveryService.php
index 4425947c55d..016331e908f 100644
--- a/lib/private/OCS/DiscoveryService.php
+++ b/lib/private/OCS/DiscoveryService.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
*
@@ -60,11 +61,14 @@ class DiscoveryService implements IDiscoveryService {
* @param string $service the service you want to discover
* @return array
*/
- public function discover($remote, $service) {
+ public function discover(string $remote, string $service): array {
// Check the cache first
$cacheData = $this->cache->get($remote . '#' . $service);
if($cacheData) {
- return json_decode($cacheData, true);
+ $data = json_decode($cacheData, true);
+ if (\is_array($data)) {
+ return $data;
+ }
}
$discoveredServices = [];
@@ -77,7 +81,9 @@ class DiscoveryService implements IDiscoveryService {
]);
if($response->getStatusCode() === Http::STATUS_OK) {
$decodedServices = json_decode($response->getBody(), true);
- $discoveredServices = $this->getEndpoints($decodedServices, $service);
+ if (\is_array($decodedServices)) {
+ $discoveredServices = $this->getEndpoints($decodedServices, $service);
+ }
}
} catch (\Exception $e) {
// if we couldn't discover the service or any end-points we return a empty array
@@ -91,17 +97,15 @@ class DiscoveryService implements IDiscoveryService {
/**
* get requested end-points from the requested service
*
- * @param $decodedServices
- * @param $service
+ * @param array $decodedServices
+ * @param string $service
* @return array
*/
- protected function getEndpoints($decodedServices, $service) {
+ protected function getEndpoints(array $decodedServices, string $service): array {
$discoveredServices = [];
- if(is_array($decodedServices) &&
- isset($decodedServices['services'][$service]['endpoints'])
- ) {
+ if(isset($decodedServices['services'][$service]['endpoints'])) {
foreach ($decodedServices['services'][$service]['endpoints'] as $endpoint => $url) {
if($this->isSafeUrl($url)) {
$discoveredServices[$endpoint] = $url;
@@ -119,7 +123,7 @@ class DiscoveryService implements IDiscoveryService {
* @param string $url
* @return bool
*/
- protected function isSafeUrl($url) {
+ protected function isSafeUrl(string $url): bool {
return (bool)preg_match('/^[\/\.\-A-Za-z0-9]+$/', $url);
}
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 448a7a57580..08f6b604eca 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -110,6 +110,11 @@ class Generator {
// Get the max preview and infer the max preview sizes from that
$maxPreview = $this->getMaxPreview($previewFolder, $file, $mimeType);
+ if ($maxPreview->getSize() === 0) {
+ $maxPreview->delete();
+ throw new NotFoundException('Max preview size 0, invalid!');
+ }
+
list($maxWidth, $maxHeight) = $this->getPreviewSize($maxPreview);
// If both width and heigth are -1 we just want the max preview
@@ -129,15 +134,20 @@ class Generator {
// Try to get a cached preview. Else generate (and store) one
try {
try {
- $file = $this->getCachedPreview($previewFolder, $width, $height, $crop, $maxPreview->getMimeType());
+ $preview = $this->getCachedPreview($previewFolder, $width, $height, $crop, $maxPreview->getMimeType());
} catch (NotFoundException $e) {
- $file = $this->generatePreview($previewFolder, $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight);
+ $preview = $this->generatePreview($previewFolder, $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight);
}
} catch (\InvalidArgumentException $e) {
throw new NotFoundException();
}
- return $file;
+ if ($preview->getSize() === 0) {
+ $preview->delete();
+ throw new NotFoundException('Cached preview size 0, invalid!');
+ }
+
+ return $preview;
}
/**
@@ -345,9 +355,9 @@ class Generator {
$scaleH = $maxHeight / $widthR;
$scaleW = $width;
}
- $preview->preciseResize(round($scaleW), round($scaleH));
+ $preview->preciseResize((int)round($scaleW), (int)round($scaleH));
}
- $cropX = floor(abs($width - $preview->width()) * 0.5);
+ $cropX = (int)floor(abs($width - $preview->width()) * 0.5);
$cropY = 0;
$preview->crop($cropX, $cropY, $width, $height);
} else {
diff --git a/lib/private/Preview/GeneratorHelper.php b/lib/private/Preview/GeneratorHelper.php
index 6535fde058b..587f8174b02 100644
--- a/lib/private/Preview/GeneratorHelper.php
+++ b/lib/private/Preview/GeneratorHelper.php
@@ -27,7 +27,7 @@ use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IImage;
-use OCP\Image as img;
+use OCP\Image as OCPImage;
use OCP\Preview\IProvider;
/**
@@ -79,7 +79,9 @@ class GeneratorHelper {
* @return IImage
*/
public function getImage(ISimpleFile $maxPreview) {
- return new img($maxPreview->getContent());
+ $image = new OCPImage();
+ $image->loadFromData($maxPreview->getContent());
+ return $image;
}
/**
diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php
index a4b7ec769c0..88c6e87f38e 100644
--- a/lib/private/Preview/TXT.php
+++ b/lib/private/Preview/TXT.php
@@ -91,8 +91,9 @@ class TXT extends Provider {
}
}
- $image = new \OC_Image($image);
+ $imageObject = new \OC_Image();
+ $imageObject->setResource($image);
- return $image->valid() ? $image : false;
+ return $imageObject->valid() ? $imageObject : false;
}
}
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php
index db575a8cbe0..46ef8862e6b 100644
--- a/lib/private/PreviewManager.php
+++ b/lib/private/PreviewManager.php
@@ -166,7 +166,9 @@ class PreviewManager implements IPreview {
return new \OC_Image();
}
- return new \OC_Image($preview->getContent());
+ $previewImage = new \OC_Image();
+ $previewImage->loadFromData($preview->getContent());
+ return $previewImage;
}
/**
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index 8562465aad3..2b671662f99 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -35,12 +35,7 @@ use OC\Files\AppData\Factory;
use OC\Repair\CleanTags;
use OC\Repair\Collation;
use OC\Repair\MoveUpdaterStepFile;
-use OC\Repair\NC11\CleanPreviews;
use OC\Repair\NC11\FixMountStorages;
-use OC\Repair\NC11\MoveAvatars;
-use OC\Repair\NC12\InstallCoreBundle;
-use OC\Repair\NC12\UpdateLanguageCodes;
-use OC\Repair\NC12\RepairIdentityProofKeyFolders;
use OC\Repair\NC13\AddLogRotateJob;
use OC\Repair\OldGroupMembershipShares;
use OC\Repair\Owncloud\DropAccountTermsTable;
@@ -133,24 +128,8 @@ class Repair implements IOutput{
new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
new MoveUpdaterStepFile(\OC::$server->getConfig()),
- new MoveAvatars(
- \OC::$server->getJobList(),
- \OC::$server->getConfig()
- ),
- new CleanPreviews(
- \OC::$server->getJobList(),
- \OC::$server->getUserManager(),
- \OC::$server->getConfig()
- ),
new FixMountStorages(\OC::$server->getDatabaseConnection()),
- new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
- new InstallCoreBundle(
- \OC::$server->query(BundleFetcher::class),
- \OC::$server->getConfig(),
- \OC::$server->query(Installer::class)
- ),
new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
- new RepairIdentityProofKeyFolders(\OC::$server->getConfig(), \OC::$server->query(Factory::class), \OC::$server->getRootFolder()),
new AddLogRotateJob(\OC::$server->getJobList()),
];
}
diff --git a/lib/private/Repair/NC11/CleanPreviews.php b/lib/private/Repair/NC11/CleanPreviews.php
deleted file mode 100644
index 94f5d19b795..00000000000
--- a/lib/private/Repair/NC11/CleanPreviews.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OC\Repair\NC11;
-
-use OCP\BackgroundJob\IJobList;
-use OCP\IConfig;
-use OCP\IUser;
-use OCP\IUserManager;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class CleanPreviews implements IRepairStep {
-
- /** @var IJobList */
- private $jobList;
-
- /** @var IUserManager */
- private $userManager;
-
- /** @var IConfig */
- private $config;
-
- /**
- * MoveAvatars constructor.
- *
- * @param IJobList $jobList
- * @param IUserManager $userManager
- * @param IConfig $config
- */
- public function __construct(IJobList $jobList,
- IUserManager $userManager,
- IConfig $config) {
- $this->jobList = $jobList;
- $this->userManager = $userManager;
- $this->config = $config;
- }
-
- /**
- * @return string
- */
- public function getName() {
- return 'Add preview cleanup background jobs';
- }
-
- public function run(IOutput $output) {
- if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) {
- $this->userManager->callForSeenUsers(function (IUser $user) {
- $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
- });
- $this->config->setAppValue('core', 'previewsCleanedUp', 1);
- }
- }
-}
diff --git a/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php b/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
deleted file mode 100644
index e713f4dc63a..00000000000
--- a/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OC\Repair\NC11;
-
-use OC\BackgroundJob\QueuedJob;
-use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJobList;
-use OCP\Files\Folder;
-use OCP\Files\IRootFolder;
-use OCP\Files\NotFoundException;
-use OCP\Files\NotPermittedException;
-use OCP\ILogger;
-use OCP\IUserManager;
-
-class CleanPreviewsBackgroundJob extends QueuedJob {
- /** @var IRootFolder */
- private $rootFolder;
-
- /** @var ILogger */
- private $logger;
-
- /** @var IJobList */
- private $jobList;
-
- /** @var ITimeFactory */
- private $timeFactory;
-
- /** @var IUserManager */
- private $userManager;
-
- /**
- * CleanPreviewsBackgroundJob constructor.
- *
- * @param IRootFolder $rootFolder
- * @param ILogger $logger
- * @param IJobList $jobList
- * @param ITimeFactory $timeFactory
- * @param IUserManager $userManager
- */
- public function __construct(IRootFolder $rootFolder,
- ILogger $logger,
- IJobList $jobList,
- ITimeFactory $timeFactory,
- IUserManager $userManager) {
- $this->rootFolder = $rootFolder;
- $this->logger = $logger;
- $this->jobList = $jobList;
- $this->timeFactory = $timeFactory;
- $this->userManager = $userManager;
- }
-
- public function run($arguments) {
- $uid = $arguments['uid'];
- if (!$this->userManager->userExists($uid)) {
- $this->logger->info('User no longer exists, skip user ' . $uid);
- return;
- }
- $this->logger->info('Started preview cleanup for ' . $uid);
- $empty = $this->cleanupPreviews($uid);
-
- if (!$empty) {
- $this->jobList->add(self::class, ['uid' => $uid]);
- $this->logger->info('New preview cleanup scheduled for ' . $uid);
- } else {
- $this->logger->info('Preview cleanup done for ' . $uid);
- }
- }
-
- /**
- * @param $uid
- * @return bool
- */
- private function cleanupPreviews($uid) {
- try {
- $userFolder = $this->rootFolder->getUserFolder($uid);
- } catch (NotFoundException $e) {
- return true;
- }
-
- $userRoot = $userFolder->getParent();
-
- try {
- /** @var Folder $thumbnailFolder */
- $thumbnailFolder = $userRoot->get('thumbnails');
- } catch (NotFoundException $e) {
- return true;
- }
-
- $thumbnails = $thumbnailFolder->getDirectoryListing();
-
- $start = $this->timeFactory->getTime();
- foreach ($thumbnails as $thumbnail) {
- try {
- $thumbnail->delete();
- } catch (NotPermittedException $e) {
- // Ignore
- }
-
- if (($this->timeFactory->getTime() - $start) > 15) {
- return false;
- }
- }
-
- try {
- $thumbnailFolder->delete();
- } catch (NotPermittedException $e) {
- // Ignore
- }
-
- return true;
- }
-}
diff --git a/lib/private/Repair/NC11/MoveAvatars.php b/lib/private/Repair/NC11/MoveAvatars.php
deleted file mode 100644
index cff591904f1..00000000000
--- a/lib/private/Repair/NC11/MoveAvatars.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OC\Repair\NC11;
-
-use OCP\BackgroundJob\IJobList;
-use OCP\IConfig;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class MoveAvatars implements IRepairStep {
-
- /** @var IJobList */
- private $jobList;
-
- /** @var IConfig */
- private $config;
-
- /**
- * MoveAvatars constructor.
- *
- * @param IJobList $jobList
- * @param IConfig $config
- */
- public function __construct(IJobList $jobList,
- IConfig $config) {
- $this->jobList = $jobList;
- $this->config = $config;
- }
-
- /**
- * @return string
- */
- public function getName() {
- return 'Add move avatar background job';
- }
-
- public function run(IOutput $output) {
- // only run once
- if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
- $output->info('Repair step already executed');
- return;
- }
- if ($this->config->getSystemValue('enable_avatars', true) === false) {
- $output->info('Avatars are disabled');
- } else {
- $output->info('Add background job');
- $this->jobList->add(MoveAvatarsBackgroundJob::class);
- // if all were done, no need to redo the repair during next upgrade
- $this->config->setAppValue('core', 'moveavatarsdone', 'yes');
- }
- }
-}
diff --git a/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php b/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php
deleted file mode 100644
index 81f375e1b41..00000000000
--- a/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OC\Repair\NC11;
-
-use OC\BackgroundJob\QueuedJob;
-use OCP\Files\File;
-use OCP\Files\Folder;
-use OCP\Files\IAppData;
-use OCP\Files\IRootFolder;
-use OCP\Files\NotFoundException;
-use OCP\Files\SimpleFS\ISimpleFolder;
-use OCP\ILogger;
-use OCP\IUser;
-use OCP\IUserManager;
-
-class MoveAvatarsBackgroundJob extends QueuedJob {
-
- /** @var IUserManager */
- private $userManager;
-
- /** @var IRootFolder */
- private $rootFolder;
-
- /** @var IAppData */
- private $appData;
-
- /** @var ILogger */
- private $logger;
-
- /**
- * MoveAvatars constructor.
- */
- public function __construct() {
- $this->userManager = \OC::$server->getUserManager();
- $this->rootFolder = \OC::$server->getRootFolder();
- $this->logger = \OC::$server->getLogger();
- $this->appData = \OC::$server->getAppDataDir('avatar');
- }
-
- public function run($arguments) {
- $this->logger->info('Started migrating avatars to AppData folder');
- $this->moveAvatars();
- $this->logger->info('All avatars migrated to AppData folder');
- }
-
- private function moveAvatars() {
- try {
- $ownCloudAvatars = $this->rootFolder->get('avatars');
- } catch (NotFoundException $e) {
- $ownCloudAvatars = null;
- }
-
- $counter = 0;
- $this->userManager->callForSeenUsers(function (IUser $user) use ($counter, $ownCloudAvatars) {
- $uid = $user->getUID();
-
- \OC\Files\Filesystem::initMountPoints($uid);
- /** @var Folder $userFolder */
- $userFolder = $this->rootFolder->get($uid);
-
- try {
- $userData = $this->appData->getFolder($uid);
- } catch (NotFoundException $e) {
- $userData = $this->appData->newFolder($uid);
- }
-
- $foundAvatars = $this->copyAvatarsFromFolder($userFolder, $userData);
-
- // ownCloud migration?
- if ($foundAvatars === 0 && $ownCloudAvatars instanceof Folder) {
- $parts = $this->buildOwnCloudAvatarPath($uid);
- $userOwnCloudAvatar = $ownCloudAvatars;
- foreach ($parts as $part) {
- try {
- $userOwnCloudAvatar = $userOwnCloudAvatar->get($part);
- } catch (NotFoundException $e) {
- return;
- }
- }
-
- $this->copyAvatarsFromFolder($userOwnCloudAvatar, $userData);
- }
-
- $counter++;
- if ($counter % 100 === 0) {
- $this->logger->info('{amount} avatars migrated', ['amount' => $counter]);
- }
- });
- }
-
- /**
- * @param Folder $source
- * @param ISimpleFolder $target
- * @return int
- * @throws \OCP\Files\NotPermittedException
- * @throws NotFoundException
- */
- protected function copyAvatarsFromFolder(Folder $source, ISimpleFolder $target) {
- $foundAvatars = 0;
- $avatars = $source->getDirectoryListing();
- $regex = '/^avatar\.([0-9]+\.)?(jpg|png)$/';
-
- foreach ($avatars as $avatar) {
- /** @var File $avatar */
- if (preg_match($regex, $avatar->getName())) {
- /*
- * This is not the most effective but it is the most abstract way
- * to handle this. Avatars should be small anyways.
- */
- $newAvatar = $target->newFile($avatar->getName());
- $newAvatar->putContent($avatar->getContent());
- $avatar->delete();
- $foundAvatars++;
- }
- }
-
- return $foundAvatars;
- }
-
- protected function buildOwnCloudAvatarPath($userId) {
- $avatar = substr_replace(substr_replace(md5($userId), '/', 4, 0), '/', 2, 0);
- return explode('/', $avatar);
- }
-}
diff --git a/lib/private/Repair/NC12/InstallCoreBundle.php b/lib/private/Repair/NC12/InstallCoreBundle.php
deleted file mode 100644
index f7a2b07dec0..00000000000
--- a/lib/private/Repair/NC12/InstallCoreBundle.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OC\Repair\NC12;
-
-use OC\App\AppStore\Bundles\BundleFetcher;
-use OC\Installer;
-use OCP\IConfig;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class InstallCoreBundle implements IRepairStep {
- /** @var BundleFetcher */
- private $bundleFetcher;
- /** @var IConfig */
- private $config;
- /** @var Installer */
- private $installer;
-
- /**
- * @param BundleFetcher $bundleFetcher
- * @param IConfig $config
- * @param Installer $installer
- */
- public function __construct(BundleFetcher $bundleFetcher,
- IConfig $config,
- Installer $installer) {
- $this->bundleFetcher = $bundleFetcher;
- $this->config = $config;
- $this->installer = $installer;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName() {
- return 'Install new core bundle components';
- }
-
- /**
- * {@inheritdoc}
- */
- public function run(IOutput $output) {
- $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
-
- if (version_compare($versionFromBeforeUpdate, '12.0.0.14', '>')) {
- return;
- }
-
- $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle();
- foreach($defaultBundle as $bundle) {
- try {
- $this->installer->installAppBundle($bundle);
- $output->info('Successfully installed core app bundle.');
- } catch (\Exception $e) {
- $output->warning('Could not install core app bundle: ' . $e->getMessage());
- }
- }
- }
-}
diff --git a/lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php b/lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php
deleted file mode 100644
index f8b8b8bdc28..00000000000
--- a/lib/private/Repair/NC12/RepairIdentityProofKeyFolders.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OC\Repair\NC12;
-
-
-use OC\Files\AppData\Factory;
-use OCP\Files\IRootFolder;
-use OCP\Files\SimpleFS\ISimpleFolder;
-use OCP\IConfig;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class RepairIdentityProofKeyFolders implements IRepairStep {
-
- /** @var IConfig */
- private $config;
-
- /** @var \OC\Files\AppData\AppData */
- private $appDataIdentityProof;
-
- /** @var IRootFolder */
- private $rootFolder;
-
- /** @var string */
- private $identityProofDir;
-
- /**
- * RepairIdentityProofKeyFolders constructor.
- *
- * @param IConfig $config
- * @param Factory $appDataFactory
- * @param IRootFolder $rootFolder
- */
- public function __construct(IConfig $config, Factory $appDataFactory, IRootFolder $rootFolder) {
- $this->config = $config;
- $this->appDataIdentityProof = $appDataFactory->get('identityproof');
- $this->rootFolder = $rootFolder;
-
- $instanceId = $this->config->getSystemValue('instanceid', null);
- if ($instanceId === null) {
- throw new \RuntimeException('no instance id!');
- }
- $this->identityProofDir = 'appdata_' . $instanceId . '/identityproof/';
- }
-
- /**
- * Returns the step's name
- *
- * @return string
- * @since 9.1.0
- */
- public function getName() {
- return "Rename folder with user specific keys";
- }
-
- /**
- * Run repair step.
- * Must throw exception on error.
- *
- * @param IOutput $output
- * @throws \Exception in case of failure
- * @since 9.1.0
- */
- public function run(IOutput $output) {
- $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
- if (version_compare($versionFromBeforeUpdate, '12.0.1.5', '<=')) {
- $count = $this->repair();
- $output->info('Repaired ' . $count . ' folders');
- }
- }
-
- /**
- * rename all dirs with user specific keys to 'user-uid'
- *
- * @return int
- */
- private function repair() {
- $count = 0;
- $dirListing = $this->appDataIdentityProof->getDirectoryListing();
- /** @var ISimpleFolder $folder */
- foreach ($dirListing as $folder) {
- $name = $folder->getName();
- $node = $this->rootFolder->get($this->identityProofDir . $name);
- $node->move($this->identityProofDir . 'user-' . $name);
- $count++;
- }
-
- return $count;
- }
-}
diff --git a/lib/private/Repair/NC12/UpdateLanguageCodes.php b/lib/private/Repair/NC12/UpdateLanguageCodes.php
deleted file mode 100644
index a8522449d56..00000000000
--- a/lib/private/Repair/NC12/UpdateLanguageCodes.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OC\Repair\NC12;
-
-use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\IConfig;
-use OCP\IDBConnection;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class UpdateLanguageCodes implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- /** @var IConfig */
- private $config;
-
- /**
- * @param IDBConnection $connection
- * @param IConfig $config
- */
- public function __construct(IDBConnection $connection,
- IConfig $config) {
- $this->connection = $connection;
- $this->config = $config;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName() {
- return 'Repair language codes';
- }
-
- /**
- * {@inheritdoc}
- */
- public function run(IOutput $output) {
-
- $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
-
- if (version_compare($versionFromBeforeUpdate, '12.0.0.13', '>')) {
- return;
- }
-
- $languages = [
- 'bg_BG' => 'bg',
- 'cs_CZ' => 'cs',
- 'fi_FI' => 'fi',
- 'hu_HU' => 'hu',
- 'nb_NO' => 'nb',
- 'sk_SK' => 'sk',
- 'th_TH' => 'th',
- ];
-
- foreach ($languages as $oldCode => $newCode) {
- $qb = $this->connection->getQueryBuilder();
-
- $affectedRows = $qb->update('preferences')
- ->set('configvalue', $qb->createNamedParameter($newCode))
- ->where($qb->expr()->eq('appid', $qb->createNamedParameter('core')))
- ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lang')))
- ->andWhere($qb->expr()->eq('configvalue', $qb->createNamedParameter($oldCode), IQueryBuilder::PARAM_STR))
- ->execute();
-
- $output->info('Changed ' . $affectedRows . ' setting(s) from "' . $oldCode . '" to "' . $newCode . '" in preferences table.');
- }
- }
-}
diff --git a/lib/private/Security/Crypto.php b/lib/private/Security/Crypto.php
index d2be1484279..04d618bf373 100644
--- a/lib/private/Security/Crypto.php
+++ b/lib/private/Security/Crypto.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -67,7 +68,7 @@ class Crypto implements ICrypto {
* @param string $password Password to use (defaults to `secret` in config.php)
* @return string Calculated HMAC
*/
- public function calculateHMAC($message, $password = '') {
+ public function calculateHMAC(string $message, string $password = ''): string {
if($password === '') {
$password = $this->config->getSystemValue('secret');
}
@@ -86,7 +87,7 @@ class Crypto implements ICrypto {
* @param string $password Password to encrypt, if not specified the secret from config.php will be taken
* @return string Authenticated ciphertext
*/
- public function encrypt($plaintext, $password = '') {
+ public function encrypt(string $plaintext, string $password = ''): string {
if($password === '') {
$password = $this->config->getSystemValue('secret');
}
@@ -115,7 +116,7 @@ class Crypto implements ICrypto {
$this->cipher->setPassword($password);
$parts = explode('|', $authenticatedCiphertext);
- if(count($parts) !== 3) {
+ if(\count($parts) !== 3) {
throw new \Exception('Authenticated ciphertext could not be decoded.');
}
diff --git a/lib/private/Security/Hasher.php b/lib/private/Security/Hasher.php
index 1ba6d7059eb..c6c9109b336 100644
--- a/lib/private/Security/Hasher.php
+++ b/lib/private/Security/Hasher.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -63,7 +64,7 @@ class Hasher implements IHasher {
$this->config = $config;
$hashingCost = $this->config->getSystemValue('hashingCost', null);
- if(!is_null($hashingCost)) {
+ if(!\is_null($hashingCost)) {
$this->options['cost'] = $hashingCost;
}
}
@@ -76,7 +77,7 @@ class Hasher implements IHasher {
* @param string $message Message to generate hash from
* @return string Hash of the message with appended version parameter
*/
- public function hash($message) {
+ public function hash(string $message): string {
return $this->currentVersion . '|' . password_hash($message, PASSWORD_DEFAULT, $this->options);
}
@@ -85,9 +86,9 @@ class Hasher implements IHasher {
* @param string $prefixedHash
* @return null|array Null if the hash is not prefixed, otherwise array('version' => 1, 'hash' => 'foo')
*/
- protected function splitHash($prefixedHash) {
+ protected function splitHash(string $prefixedHash) {
$explodedString = explode('|', $prefixedHash, 2);
- if(count($explodedString) === 2) {
+ if(\count($explodedString) === 2) {
if((int)$explodedString[0] > 0) {
return array('version' => (int)$explodedString[0], 'hash' => $explodedString[1]);
}
@@ -103,13 +104,13 @@ class Hasher implements IHasher {
* @param null|string &$newHash Reference will contain the updated hash
* @return bool Whether $hash is a valid hash of $message
*/
- protected function legacyHashVerify($message, $hash, &$newHash = null) {
+ protected function legacyHashVerify($message, $hash, &$newHash = null): bool {
if(empty($this->legacySalt)) {
$this->legacySalt = $this->config->getSystemValue('passwordsalt', '');
}
// Verify whether it matches a legacy PHPass or SHA1 string
- $hashLength = strlen($hash);
+ $hashLength = \strlen($hash);
if($hashLength === 60 && password_verify($message.$this->legacySalt, $hash) ||
$hashLength === 40 && hash_equals($hash, sha1($message))) {
$newHash = $this->hash($message);
@@ -126,7 +127,7 @@ class Hasher implements IHasher {
* @param null|string &$newHash Reference will contain the updated hash if necessary. Update the existing hash with this one.
* @return bool Whether $hash is a valid hash of $message
*/
- protected function verifyHashV1($message, $hash, &$newHash = null) {
+ protected function verifyHashV1(string $message, string $hash, &$newHash = null): bool {
if(password_verify($message, $hash)) {
if(password_needs_rehash($hash, PASSWORD_DEFAULT, $this->options)) {
$newHash = $this->hash($message);
@@ -143,7 +144,7 @@ class Hasher implements IHasher {
* @param null|string &$newHash Reference will contain the updated hash if necessary. Update the existing hash with this one.
* @return bool Whether $hash is a valid hash of $message
*/
- public function verify($message, $hash, &$newHash = null) {
+ public function verify(string $message, string $hash, &$newHash = null): bool {
$splittedHash = $this->splitHash($hash);
if(isset($splittedHash['version'])) {
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 4a851d67226..90072f8b63b 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -92,7 +92,6 @@ use OC\Notification\Manager;
use OC\OCS\DiscoveryService;
use OC\Remote\Api\ApiFactory;
use OC\Remote\InstanceFactory;
-use OC\Repair\NC11\CleanPreviewsBackgroundJob;
use OC\RichObjectStrings\Validator;
use OC\Security\Bruteforce\Throttler;
use OC\Security\CertificateManager;
@@ -284,11 +283,12 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
- $this->registerService(\OCP\IUserManager::class, function (Server $c) {
+ $this->registerService(\OC\User\Manager::class, function (Server $c) {
$config = $c->getConfig();
return new \OC\User\Manager($config);
});
- $this->registerAlias('UserManager', \OCP\IUserManager::class);
+ $this->registerAlias('UserManager', \OC\User\Manager::class);
+ $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
@@ -523,7 +523,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
return new AvatarManager(
- $c->getUserManager(),
+ $c->query(\OC\User\Manager::class),
$c->getAppDataDir('avatar'),
$c->getL10N('lib'),
$c->getLogger(),
@@ -676,7 +676,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(AppManager::class, function (Server $c) {
return new \OC\App\AppManager(
$c->getUserSession(),
- $c->getAppConfig(),
+ $c->query(\OC\AppConfig::class),
$c->getGroupManager(),
$c->getMemCacheFactory(),
$c->getEventDispatcher()
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index 193e0c1a27e..8812399c812 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -81,7 +81,7 @@ class Share extends Constants {
* @return boolean true if backend is registered or false if error
*/
public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
- if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes') == 'yes') {
+ if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') == 'yes') {
if (!isset(self::$backendTypes[$itemType])) {
self::$backendTypes[$itemType] = array(
'class' => $class,
@@ -439,7 +439,7 @@ class Share extends Constants {
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
throw new \Exception($message_t);
}
- if (!\OC_User::userExists($shareWith)) {
+ if (!\OC::$server->getUserManager()->userExists($shareWith)) {
$message = 'Sharing %s failed, because the user %s does not exist';
$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
@@ -540,7 +540,7 @@ class Share extends Constants {
$shareWith['users'] = array_diff($userIds, array($uidOwner));
} else if ($shareType === self::SHARE_TYPE_LINK) {
$updateExistingShare = false;
- if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
+ if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
// IF the password is changed via the old ajax endpoint verify it before deleting the old share
if ($passwordChanged === true) {
@@ -784,81 +784,6 @@ class Share extends Constants {
}
/**
- * Retrieve the owner of a connection
- *
- * @param IDBConnection $connection
- * @param int $shareId
- * @throws \Exception
- * @return string uid of share owner
- */
- private static function getShareOwner(IDBConnection $connection, $shareId) {
- $qb = $connection->getQueryBuilder();
-
- $qb->select('uid_owner')
- ->from('share')
- ->where($qb->expr()->eq('id', $qb->createParameter('shareId')))
- ->setParameter(':shareId', $shareId);
- $dbResult = $qb->execute();
- $result = $dbResult->fetch();
- $dbResult->closeCursor();
-
- if (empty($result)) {
- throw new \Exception('Share not found');
- }
-
- return $result['uid_owner'];
- }
-
- /**
- * Set password for a public link share
- *
- * @param IUserSession $userSession
- * @param IDBConnection $connection
- * @param IConfig $config
- * @param int $shareId
- * @param string $password
- * @throws \Exception
- * @return boolean
- */
- public static function setPassword(IUserSession $userSession,
- IDBConnection $connection,
- IConfig $config,
- $shareId, $password) {
- $user = $userSession->getUser();
- if (is_null($user)) {
- throw new \Exception("User not logged in");
- }
-
- $uid = self::getShareOwner($connection, $shareId);
-
- if ($uid !== $user->getUID()) {
- throw new \Exception('Cannot update share of a different user');
- }
-
- if ($password === '') {
- $password = null;
- }
-
- //If passwords are enforced the password can't be null
- if (self::enforcePassword($config) && is_null($password)) {
- throw new \Exception('Cannot remove password');
- }
-
- self::verifyPassword($password);
-
- $qb = $connection->getQueryBuilder();
- $qb->update('share')
- ->set('share_with', $qb->createParameter('pass'))
- ->where($qb->expr()->eq('id', $qb->createParameter('shareId')))
- ->setParameter(':pass', is_null($password) ? null : \OC::$server->getHasher()->hash($password))
- ->setParameter(':shareId', $shareId);
-
- $qb->execute();
-
- return true;
- }
-
- /**
* Checks whether a share has expired, calls unshareItem() if yes.
* @param array $item Share data (usually database row)
* @return boolean True if item was expired, false otherwise.
@@ -977,7 +902,7 @@ class Share extends Constants {
*/
public static function isResharingAllowed() {
if (!isset(self::$isResharingAllowed)) {
- if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
+ if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
self::$isResharingAllowed = true;
} else {
self::$isResharingAllowed = false;
@@ -1082,7 +1007,7 @@ class Share extends Constants {
public static function getItems($itemType, $item = null, $shareType = null, $shareWith = null,
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
$includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) {
- if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes') != 'yes') {
+ if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') != 'yes') {
return array();
}
$backend = self::getBackend($itemType);
@@ -1121,7 +1046,7 @@ class Share extends Constants {
$queryArgs = array($itemType);
}
}
- if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
+ if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
$where .= ' AND `share_type` != ?';
$queryArgs[] = self::SHARE_TYPE_LINK;
}
@@ -2144,7 +2069,7 @@ class Share extends Constants {
* @return bool
*/
public static function shareWithGroupMembersOnly() {
- $value = \OC::$server->getAppConfig()->getValue('core', 'shareapi_only_share_with_group_members', 'no');
+ $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no');
return ($value === 'yes') ? true : false;
}
@@ -2157,14 +2082,6 @@ class Share extends Constants {
}
/**
- * @return bool
- */
- public static function enforceDefaultExpireDate() {
- $enforceDefaultExpireDate = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
- return ($enforceDefaultExpireDate === "yes") ? true : false;
- }
-
- /**
* @return int
*/
public static function getExpireInterval() {
@@ -2206,30 +2123,6 @@ class Share extends Constants {
}
/**
- * Get all share entries, including non-unique group items
- *
- * @param string $owner
- * @return array
- */
- public static function getAllSharesForOwner($owner) {
- $query = 'SELECT * FROM `*PREFIX*share` WHERE `uid_owner` = ?';
- $result = \OC::$server->getDatabaseConnection()->executeQuery($query, [$owner]);
- return $result->fetchAll();
- }
-
- /**
- * Get all share entries, including non-unique group items for a file
- *
- * @param int $id
- * @return array
- */
- public static function getAllSharesForFileId($id) {
- $query = 'SELECT * FROM `*PREFIX*share` WHERE `file_source` = ?';
- $result = \OC::$server->getDatabaseConnection()->executeQuery($query, [$id]);
- return $result->fetchAll();
- }
-
- /**
* @param string $password
* @throws \Exception
*/
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 996163daacc..43096e7c1f8 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -66,9 +66,6 @@ class Updater extends BasicEmitter {
/** @var Installer */
private $installer;
- /** @var bool */
- private $skip3rdPartyAppsDisable;
-
private $logLevelNames = [
0 => 'Debug',
1 => 'Info',
@@ -91,22 +88,6 @@ class Updater extends BasicEmitter {
$this->config = $config;
$this->checker = $checker;
$this->installer = $installer;
-
- // If at least PHP 7.0.0 is used we don't need to disable apps as we catch
- // fatal errors and exceptions and disable the app just instead.
- if(version_compare(phpversion(), '7.0.0', '>=')) {
- $this->skip3rdPartyAppsDisable = true;
- }
- }
-
- /**
- * Sets whether the update disables 3rd party apps.
- * This can be set to true to skip the disable.
- *
- * @param bool $flag false to not disable, true otherwise
- */
- public function setSkip3rdPartyAppsDisable($flag) {
- $this->skip3rdPartyAppsDisable = $flag;
}
/**
@@ -201,16 +182,8 @@ class Updater extends BasicEmitter {
$currentVendor = $this->config->getAppValue('core', 'vendor', '');
// Vendor was not set correctly on install, so we have to white-list known versions
- if ($currentVendor === '') {
- if (in_array($oldVersion, [
- '11.0.2.7',
- '11.0.1.2',
- '11.0.0.10',
- ], true)) {
- $currentVendor = 'nextcloud';
- } else if (isset($allowedPreviousVersions['owncloud'][$oldVersion])) {
- $currentVendor = 'owncloud';
- }
+ if ($currentVendor === '' && isset($allowedPreviousVersions['owncloud'][$oldVersion])) {
+ $currentVendor = 'owncloud';
}
if ($currentVendor === 'nextcloud') {
@@ -437,13 +410,6 @@ class Updater extends BasicEmitter {
if (OC_App::isType($app, ['session', 'authentication'])) {
continue;
}
-
- // disable any other 3rd party apps if not overriden
- if(!$this->skip3rdPartyAppsDisable) {
- \OC_App::disable($app);
- $disabledApps[]= $app;
- $this->emit('\OC\Updater', 'thirdPartyAppDisabled', array($app));
- };
}
return $disabledApps;
}
@@ -597,9 +563,6 @@ class Updater extends BasicEmitter {
$this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
$log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
});
- $this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) {
- $log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']);
- });
$this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) {
$log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
});
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 8114895416b..ea44ac8a144 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -236,8 +236,8 @@ class OC_App {
require_once $app . '/appinfo/app.php';
} catch (Error $ex) {
\OC::$server->getLogger()->logException($ex);
- $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
- if (!in_array($app, $blacklist)) {
+ if (!\OC::$server->getAppManager()->isShipped($app)) {
+ // Only disable apps which are not shipped
self::disable($app);
}
}
@@ -298,12 +298,12 @@ class OC_App {
$appData['types'] = [];
}
- \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
+ \OC::$server->getConfig()->setAppValue($app, 'types', $appTypes);
if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
- $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes');
+ $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'yes');
if ($enabled !== 'yes' && $enabled !== 'no') {
- \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
+ \OC::$server->getConfig()->setAppValue($app, 'enabled', 'yes');
}
}
}
@@ -803,7 +803,7 @@ class OC_App {
continue;
}
- $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no');
+ $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no');
$info['groups'] = null;
if ($enabled === 'yes') {
$active = true;
@@ -1075,7 +1075,7 @@ class OC_App {
self::setAppTypes($appId);
$version = \OC_App::getAppVersion($appId);
- \OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);
+ \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version);
\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
ManagerEvent::EVENT_APP_UPDATE, $appId
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index a0159b927f9..6ad9426a717 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -69,6 +69,7 @@ class OC_Image implements \OCP\IImage {
* an imagecreate* function.
* @param \OCP\ILogger $logger
* @param \OCP\IConfig $config
+ * @throws \InvalidArgumentException in case the $imageRef parameter is not null
*/
public function __construct($imageRef = null, \OCP\ILogger $logger = null, \OCP\IConfig $config = null) {
$this->logger = $logger;
@@ -85,7 +86,7 @@ class OC_Image implements \OCP\IImage {
}
if ($imageRef !== null) {
- $this->load($imageRef);
+ throw new \InvalidArgumentException('The first parameter in the constructor is not supported anymore. Please use any of the load* methods of the image object to load an image.');
}
}
@@ -298,6 +299,18 @@ class OC_Image implements \OCP\IImage {
}
/**
+ * @param resource Returns the image resource in any.
+ * @throws \InvalidArgumentException in case the supplied resource does not have the type "gd"
+ */
+ public function setResource($resource) {
+ if (get_resource_type($resource) === 'gd') {
+ $this->resource = $resource;
+ return;
+ }
+ throw new \InvalidArgumentException('Supplied resource is not of type "gd".');
+ }
+
+ /**
* @return resource Returns the image resource in any.
*/
public function resource() {
@@ -504,31 +517,6 @@ class OC_Image implements \OCP\IImage {
}
/**
- * Loads an image from a local file, a base64 encoded string or a resource created by an imagecreate* function.
- *
- * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by an imagecreate* function or a file resource (file handle ).
- * @return resource|false An image resource or false on error
- */
- public function load($imageRef) {
- if (is_resource($imageRef)) {
- if (get_resource_type($imageRef) === 'gd') {
- $this->resource = $imageRef;
- return $this->resource;
- } elseif (in_array(get_resource_type($imageRef), array('file', 'stream'))) {
- return $this->loadFromFileHandle($imageRef);
- }
- } elseif ($this->loadFromBase64($imageRef) !== false) {
- return $this->resource;
- } elseif ($this->loadFromFile($imageRef) !== false) {
- return $this->resource;
- } elseif ($this->loadFromData($imageRef) !== false) {
- return $this->resource;
- }
- $this->logger->debug(__METHOD__ . '(): could not load anything. Giving up!', array('app' => 'core'));
- return false;
- }
-
- /**
* Loads an image from an open file handle.
* It is the responsibility of the caller to position the pointer at the correct place and to close the handle again.
*
@@ -873,7 +861,7 @@ class OC_Image implements \OCP\IImage {
$newHeight = $maxSize;
}
- $this->preciseResize(round($newWidth), round($newHeight));
+ $this->preciseResize((int)round($newWidth), (int)round($newHeight));
return true;
}
@@ -882,7 +870,7 @@ class OC_Image implements \OCP\IImage {
* @param int $height
* @return bool
*/
- public function preciseResize($width, $height) {
+ public function preciseResize(int $width, int $height): bool {
if (!$this->valid()) {
$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
return false;
@@ -982,7 +970,7 @@ class OC_Image implements \OCP\IImage {
* @param int $h Height
* @return bool for success or failure
*/
- public function crop($x, $y, $w, $h) {
+ public function crop(int $x, int $y, int $w, int $h): bool {
if (!$this->valid()) {
$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
return false;
@@ -1033,7 +1021,7 @@ class OC_Image implements \OCP\IImage {
$newWidth = min($maxWidth, $ratio * $maxHeight);
$newHeight = min($maxHeight, $maxWidth / $ratio);
- $this->preciseResize(round($newWidth), round($newHeight));
+ $this->preciseResize((int)round($newWidth), (int)round($newHeight));
return true;
}
diff --git a/lib/private/legacy/json.php b/lib/private/legacy/json.php
index 7b3a1b6d9cd..7bfc815ab24 100644
--- a/lib/private/legacy/json.php
+++ b/lib/private/legacy/json.php
@@ -118,7 +118,7 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function checkUserExists($user) {
- if (!OCP\User::userExists($user)) {
+ if (!\OC::$server->getUserManager()->userExists($user)) {
$l = \OC::$server->getL10N('lib');
OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' )));
exit;
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 52ed1369c47..8f342281adb 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -58,13 +58,6 @@
*/
class OC_User {
- /**
- * @return \OC\User\Session
- */
- public static function getUserSession() {
- return OC::$server->getUserSession();
- }
-
private static $_usedBackends = array();
private static $_setupedBackends = array();
@@ -176,7 +169,7 @@ class OC_User {
if ($uid) {
if (self::getUser() !== $uid) {
self::setUserId($uid);
- $userSession = self::getUserSession();
+ $userSession = \OC::$server->getUserSession();
$userSession->setLoginName($uid);
$request = OC::$server->getRequest();
$userSession->createSessionToken($request, $uid, $uid);
@@ -210,7 +203,7 @@ class OC_User {
//setup extra user backends
self::setupBackends();
- self::getUserSession()->unsetMagicInCookie();
+ \OC::$server->getUserSession()->unsetMagicInCookie();
return self::loginWithApache($backend);
}
@@ -235,25 +228,6 @@ class OC_User {
}
/**
- * Sets user display name for session
- *
- * @param string $uid
- * @param string $displayName
- * @return bool Whether the display name could get set
- */
- public static function setDisplayName($uid, $displayName = null) {
- if (is_null($displayName)) {
- $displayName = $uid;
- }
- $user = \OC::$server->getUserManager()->get($uid);
- if ($user) {
- return $user->setDisplayName($displayName);
- } else {
- return false;
- }
- }
-
- /**
* Check if the user is logged in, considers also the HTTP basic credentials
*
* @deprecated use \OC::$server->getUserSession()->isLoggedIn()
@@ -348,7 +322,7 @@ class OC_User {
return $uid;
}
} else {
- $user = self::getUserSession()->getUser();
+ $user = \OC::$server->getUserSession()->getUser();
if ($user) {
return $user->getDisplayName();
} else {
@@ -377,25 +351,6 @@ class OC_User {
}
/**
- * Check if the password is correct
- *
- * @param string $uid The username
- * @param string $password The password
- * @return string|false user id a string on success, false otherwise
- *
- * Check if the password is correct without logging in the user
- * returns the user id or false
- */
- public static function checkPassword($uid, $password) {
- $manager = \OC::$server->getUserManager();
- $username = $manager->checkPassword($uid, $password);
- if ($username !== false) {
- return $username->getUID();
- }
- return false;
- }
-
- /**
* @param string $uid The username
* @return string
*
@@ -451,31 +406,6 @@ class OC_User {
}
/**
- * check if a user exists
- *
- * @param string $uid the username
- * @return boolean
- */
- public static function userExists($uid) {
- return \OC::$server->getUserManager()->userExists($uid);
- }
-
- /**
- * checks if a user is enabled
- *
- * @param string $uid
- * @return bool
- */
- public static function isEnabled($uid) {
- $user = \OC::$server->getUserManager()->get($uid);
- if ($user) {
- return $user->isEnabled();
- } else {
- return false;
- }
- }
-
- /**
* Returns the first active backend from self::$_usedBackends.
*
* @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index aaedd88a7ff..776a879e731 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -274,7 +274,7 @@ class OC_Util {
self::initLocalStorageRootFS();
}
- if ($user != '' && !OCP\User::userExists($user)) {
+ if ($user != '' && !\OC::$server->getUserManager()->userExists($user)) {
\OC::$server->getEventLogger()->end('setup_fs');
return false;
}
@@ -300,8 +300,7 @@ class OC_Util {
* @suppress PhanDeprecatedFunction
*/
public static function isPublicLinkPasswordRequired() {
- $appConfig = \OC::$server->getAppConfig();
- $enforcePassword = $appConfig->getValue('core', 'shareapi_enforce_links_password', 'no');
+ $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no');
return ($enforcePassword === 'yes') ? true : false;
}
@@ -1116,7 +1115,7 @@ class OC_Util {
if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
$location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
} else {
- $defaultPage = \OC::$server->getAppConfig()->getValue('core', 'defaultpage');
+ $defaultPage = \OC::$server->getConfig()->getAppValue('core', 'defaultpage');
if ($defaultPage) {
$location = $urlGenerator->getAbsoluteURL($defaultPage);
} else {
diff --git a/lib/public/DB/ISchemaWrapper.php b/lib/public/DB/ISchemaWrapper.php
new file mode 100644
index 00000000000..b29831dbc2e
--- /dev/null
+++ b/lib/public/DB/ISchemaWrapper.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\DB;
+
+/**
+ * Interface ISchemaWrapper
+ *
+ * @package OCP\DB
+ * @since 13.0.0
+ */
+interface ISchemaWrapper {
+
+ /**
+ * @param string $tableName
+ *
+ * @return \Doctrine\DBAL\Schema\Table
+ * @throws \Doctrine\DBAL\Schema\SchemaException
+ * @since 13.0.0
+ */
+ public function getTable($tableName);
+
+ /**
+ * Does this schema have a table with the given name?
+ *
+ * @param string $tableName Prefix is automatically prepended
+ *
+ * @return boolean
+ * @since 13.0.0
+ */
+ public function hasTable($tableName);
+
+ /**
+ * Creates a new table.
+ *
+ * @param string $tableName Prefix is automatically prepended
+ * @return \Doctrine\DBAL\Schema\Table
+ * @since 13.0.0
+ */
+ public function createTable($tableName);
+
+ /**
+ * Drops a table from the schema.
+ *
+ * @param string $tableName Prefix is automatically prepended
+ * @return \Doctrine\DBAL\Schema\Schema
+ * @since 13.0.0
+ */
+ public function dropTable($tableName);
+
+ /**
+ * Gets all tables of this schema.
+ *
+ * @return \Doctrine\DBAL\Schema\Table[]
+ * @since 13.0.0
+ */
+ public function getTables();
+
+ /**
+ * Gets all table names, prefixed with table prefix
+ *
+ * @return array
+ * @since 13.0.0
+ */
+ public function getTableNames();
+
+ /**
+ * Gets all table names
+ *
+ * @return array
+ * @since 13.0.0
+ */
+ public function getTableNamesWithoutPrefix();
+}
diff --git a/lib/public/Federation/ICloudId.php b/lib/public/Federation/ICloudId.php
index b03acb4f5f2..6cc17984f96 100644
--- a/lib/public/Federation/ICloudId.php
+++ b/lib/public/Federation/ICloudId.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017, Robin Appelman <robin@icewind.nl>
*
@@ -35,7 +36,7 @@ interface ICloudId {
* @return string
* @since 12.0.0
*/
- public function getId();
+ public function getId(): string;
/**
* Get a clean representation of the cloud id for display
@@ -43,7 +44,7 @@ interface ICloudId {
* @return string
* @since 12.0.0
*/
- public function getDisplayId();
+ public function getDisplayId(): string;
/**
* The username on the remote server
@@ -51,7 +52,7 @@ interface ICloudId {
* @return string
* @since 12.0.0
*/
- public function getUser();
+ public function getUser(): string;
/**
* The base address of the remote server
@@ -59,5 +60,5 @@ interface ICloudId {
* @return string
* @since 12.0.0
*/
- public function getRemote();
+ public function getRemote(): string;
}
diff --git a/lib/public/Federation/ICloudIdManager.php b/lib/public/Federation/ICloudIdManager.php
index b5b3436e6fc..c139cfda6cd 100644
--- a/lib/public/Federation/ICloudIdManager.php
+++ b/lib/public/Federation/ICloudIdManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017, Robin Appelman <robin@icewind.nl>
*
@@ -37,7 +38,7 @@ interface ICloudIdManager {
*
* @since 12.0.0
*/
- public function resolveCloudId($cloudId);
+ public function resolveCloudId(string $cloudId): ICloudId;
/**
* Get the cloud id for a remote user
@@ -48,7 +49,7 @@ interface ICloudIdManager {
*
* @since 12.0.0
*/
- public function getCloudId($user, $remote);
+ public function getCloudId(string $user, string $remote): ICloudId;
/**
* Check if the input is a correctly formatted cloud id
@@ -58,5 +59,5 @@ interface ICloudIdManager {
*
* @since 12.0.0
*/
- public function isValidCloudId($cloudId);
+ public function isValidCloudId(string $cloudId): bool;
}
diff --git a/lib/public/Http/Client/IClient.php b/lib/public/Http/Client/IClient.php
index 49e679a7ade..50addc230eb 100644
--- a/lib/public/Http/Client/IClient.php
+++ b/lib/public/Http/Client/IClient.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -59,7 +60,7 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function get($uri, array $options = []);
+ public function get(string $uri, array $options = []): IResponse;
/**
* Sends a HEAD request
@@ -84,7 +85,7 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function head($uri, $options = []);
+ public function head(string $uri, array $options = []): IResponse;
/**
* Sends a POST request
@@ -114,7 +115,7 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function post($uri, array $options = []);
+ public function post(string $uri, array $options = []): IResponse;
/**
* Sends a PUT request
@@ -144,7 +145,7 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function put($uri, array $options = []);
+ public function put(string $uri, array $options = []): IResponse;
/**
* Sends a DELETE request
@@ -174,7 +175,7 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function delete($uri, array $options = []);
+ public function delete(string $uri, array $options = []): IResponse;
/**
* Sends a options request
@@ -204,5 +205,5 @@ interface IClient {
* @throws \Exception If the request could not get completed
* @since 8.1.0
*/
- public function options($uri, array $options = []);
+ public function options(string $uri, array $options = []): IResponse;
}
diff --git a/lib/public/Http/Client/IClientService.php b/lib/public/Http/Client/IClientService.php
index 09a1f1f7b40..d34302744e1 100644
--- a/lib/public/Http/Client/IClientService.php
+++ b/lib/public/Http/Client/IClientService.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -34,5 +35,5 @@ interface IClientService {
* @return IClient
* @since 8.1.0
*/
- public function newClient();
+ public function newClient(): IClient;
}
diff --git a/lib/public/Http/Client/IResponse.php b/lib/public/Http/Client/IResponse.php
index 94817f012b3..e935067d8c2 100644
--- a/lib/public/Http/Client/IResponse.php
+++ b/lib/public/Http/Client/IResponse.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -41,18 +42,18 @@ interface IResponse {
* @return int
* @since 8.1.0
*/
- public function getStatusCode();
+ public function getStatusCode(): int;
/**
- * @param $key
+ * @param string $key
* @return string
* @since 8.1.0
*/
- public function getHeader($key);
+ public function getHeader(string $key): string;
/**
* @return array
* @since 8.1.0
*/
- public function getHeaders();
+ public function getHeaders(): array;
}
diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php
index 4a92a224840..2f268185e62 100644
--- a/lib/public/IAppConfig.php
+++ b/lib/public/IAppConfig.php
@@ -41,42 +41,6 @@ interface IAppConfig {
public function hasKey($app, $key);
/**
- * Gets the config value
- * @param string $app app
- * @param string $key key
- * @param string $default = null, default value if the key does not exist
- * @return string the value or $default
- * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig
- *
- * This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returned
- * @since 7.0.0
- */
- public function getValue($app, $key, $default = null);
-
- /**
- * Deletes a key
- * @param string $app app
- * @param string $key key
- * @return bool
- * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig
- * @since 7.0.0
- */
- public function deleteKey($app, $key);
-
- /**
- * Get the available keys for an app
- * @param string $app the app we are looking for
- * @return array an array of key names
- * @deprecated 8.0.0 use method getAppKeys of \OCP\IConfig
- *
- * This function gets all keys of an app. Please note that the values are
- * not returned.
- * @since 7.0.0
- */
- public function getKeys($app);
-
- /**
* get multiply values, either the app or key can be used as wildcard by setting it to false
*
* @param string|false $key
@@ -96,19 +60,6 @@ interface IAppConfig {
public function getFilteredValues($app);
/**
- * sets a value in the appconfig
- * @param string $app app
- * @param string $key key
- * @param string|float|int $value value
- * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
- *
- * Sets a value. If the key did not exist before it will be created.
- * @return void
- * @since 7.0.0
- */
- public function setValue($app, $key, $value);
-
- /**
* Get all apps using the config
* @return array an array of app ids
*
@@ -117,15 +68,4 @@ interface IAppConfig {
* @since 7.0.0
*/
public function getApps();
-
- /**
- * Remove app from appconfig
- * @param string $app app
- * @return bool
- * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig
- *
- * Removes all keys in appconfig belonging to the app.
- * @since 7.0.0
- */
- public function deleteApp($app);
}
diff --git a/lib/public/IAvatarManager.php b/lib/public/IAvatarManager.php
index 04f4cd00d0d..19e4b93503a 100644
--- a/lib/public/IAvatarManager.php
+++ b/lib/public/IAvatarManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -35,12 +36,12 @@ interface IAvatarManager {
/**
* return a user specific instance of \OCP\IAvatar
- * @see \OCP\IAvatar
+ * @see IAvatar
* @param string $user the ownCloud user id
- * @return \OCP\IAvatar
+ * @return IAvatar
* @throws \Exception In case the username is potentially dangerous
* @throws \OCP\Files\NotFoundException In case there is no user folder yet
* @since 6.0.0
*/
- public function getAvatar($user);
+ public function getAvatar(string $user) : IAvatar;
}
diff --git a/lib/public/ICacheFactory.php b/lib/public/ICacheFactory.php
index cc4d8fa3ec3..76145fe1f78 100644
--- a/lib/public/ICacheFactory.php
+++ b/lib/public/ICacheFactory.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -36,11 +37,11 @@ interface ICacheFactory{
* All entries added trough the cache instance will be namespaced by $prefix to prevent collisions between apps
*
* @param string $prefix
- * @return \OCP\ICache
+ * @return ICache
* @since 7.0.0
* @deprecated 13.0.0 Use either createLocking, createDistributed or createLocal
*/
- public function create($prefix = '');
+ public function create(string $prefix = ''): ICache;
/**
* Check if any memory cache backend is available
@@ -48,32 +49,32 @@ interface ICacheFactory{
* @return bool
* @since 7.0.0
*/
- public function isAvailable();
+ public function isAvailable(): bool;
/**
* create a cache instance for storing locks
*
* @param string $prefix
- * @return \OCP\IMemcache
+ * @return IMemcache
* @since 13.0.0
*/
- public function createLocking($prefix = '');
+ public function createLocking(string $prefix = ''): IMemcache;
/**
* create a distributed cache instance
*
* @param string $prefix
- * @return \OCP\ICache
+ * @return ICache
* @since 13.0.0
*/
- public function createDistributed($prefix = '');
+ public function createDistributed(string $prefix = ''): ICache;
/**
* create a local cache instance
*
* @param string $prefix
- * @return \OCP\ICache
+ * @return ICache
* @since 13.0.0
*/
- public function createLocal($prefix = '');
+ public function createLocal(string $prefix = ''): ICache;
}
diff --git a/lib/public/IImage.php b/lib/public/IImage.php
index 70e8b3cff75..4311f44f1bc 100644
--- a/lib/public/IImage.php
+++ b/lib/public/IImage.php
@@ -147,7 +147,7 @@ interface IImage {
* @return bool
* @since 8.1.0
*/
- public function preciseResize($width, $height);
+ public function preciseResize(int $width, int $height): bool;
/**
* Crops the image to the middle square. If the image is already square it just returns.
@@ -168,7 +168,7 @@ interface IImage {
* @return bool for success or failure
* @since 8.1.0
*/
- public function crop($x, $y, $w, $h);
+ public function crop(int $x, int $y, int $w, int $h): bool;
/**
* Resizes the image to fit within a boundary while preserving ratio.
diff --git a/lib/public/Lock/ILockingProvider.php b/lib/public/Lock/ILockingProvider.php
index 6fe9894b7b5..32e76c72531 100644
--- a/lib/public/Lock/ILockingProvider.php
+++ b/lib/public/Lock/ILockingProvider.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -45,7 +46,7 @@ interface ILockingProvider {
* @return bool
* @since 8.1.0
*/
- public function isLocked($path, $type);
+ public function isLocked(string $path, int $type): bool;
/**
* @param string $path
@@ -53,14 +54,14 @@ interface ILockingProvider {
* @throws \OCP\Lock\LockedException
* @since 8.1.0
*/
- public function acquireLock($path, $type);
+ public function acquireLock(string $path, int $type);
/**
* @param string $path
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
* @since 8.1.0
*/
- public function releaseLock($path, $type);
+ public function releaseLock(string $path, int $type);
/**
* Change the type of an existing lock
@@ -70,7 +71,7 @@ interface ILockingProvider {
* @throws \OCP\Lock\LockedException
* @since 8.1.0
*/
- public function changeLock($path, $targetType);
+ public function changeLock(string $path, int $targetType);
/**
* release all lock acquired by this instance
diff --git a/lib/public/Lock/LockedException.php b/lib/public/Lock/LockedException.php
index 5b5d88c18ca..1378f437c3a 100644
--- a/lib/public/Lock/LockedException.php
+++ b/lib/public/Lock/LockedException.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -48,7 +49,7 @@ class LockedException extends \Exception {
*
* @since 8.1.0
*/
- public function __construct($path, \Exception $previous = null) {
+ public function __construct(string $path, \Exception $previous = null) {
parent::__construct('"' . $path . '" is locked', 0, $previous);
$this->path = $path;
}
@@ -57,7 +58,7 @@ class LockedException extends \Exception {
* @return string
* @since 8.1.0
*/
- public function getPath() {
+ public function getPath(): string {
return $this->path;
}
}
diff --git a/lib/public/Migration/BigIntMigration.php b/lib/public/Migration/BigIntMigration.php
index 9e6003714e5..41c48f2181a 100644
--- a/lib/public/Migration/BigIntMigration.php
+++ b/lib/public/Migration/BigIntMigration.php
@@ -23,8 +23,8 @@
namespace OCP\Migration;
-use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
+use OCP\DB\ISchemaWrapper;
/**
* @since 13.0.0
@@ -40,13 +40,13 @@ abstract class BigIntMigration extends SimpleMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
- * @return null|Schema
+ * @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
- /** @var Schema $schema */
+ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$tables = $this->getColumnsByTable();
diff --git a/lib/public/Migration/IMigrationStep.php b/lib/public/Migration/IMigrationStep.php
index 11b92ecf0cf..e12d962683e 100644
--- a/lib/public/Migration/IMigrationStep.php
+++ b/lib/public/Migration/IMigrationStep.php
@@ -23,7 +23,7 @@
namespace OCP\Migration;
-use Doctrine\DBAL\Schema\Schema;
+use OCP\DB\ISchemaWrapper;
/**
* @since 13.0.0
@@ -32,7 +32,7 @@ interface IMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @since 13.0.0
*/
@@ -40,16 +40,16 @@ interface IMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
- * @return null|Schema
+ * @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options);
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @since 13.0.0
*/
diff --git a/lib/public/Migration/SimpleMigrationStep.php b/lib/public/Migration/SimpleMigrationStep.php
index 58c68064484..da46c687644 100644
--- a/lib/public/Migration/SimpleMigrationStep.php
+++ b/lib/public/Migration/SimpleMigrationStep.php
@@ -23,7 +23,7 @@
namespace OCP\Migration;
-use Doctrine\DBAL\Schema\Schema;
+use OCP\DB\ISchemaWrapper;
/**
* @since 13.0.0
@@ -32,7 +32,7 @@ abstract class SimpleMigrationStep implements IMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @since 13.0.0
*/
@@ -41,9 +41,9 @@ abstract class SimpleMigrationStep implements IMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
- * @return null|Schema
+ * @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
@@ -52,7 +52,7 @@ abstract class SimpleMigrationStep implements IMigrationStep {
/**
* @param IOutput $output
- * @param \Closure $schemaClosure The `\Closure` returns a `Schema`
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @since 13.0.0
*/
diff --git a/lib/public/OCS/IDiscoveryService.php b/lib/public/OCS/IDiscoveryService.php
index c9e67c3acab..9a86e2a4410 100644
--- a/lib/public/OCS/IDiscoveryService.php
+++ b/lib/public/OCS/IDiscoveryService.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
*
@@ -45,6 +46,6 @@ interface IDiscoveryService {
* @param string $service the service you want to discover
* @return array
*/
- public function discover($remote, $service);
+ public function discover(string $remote, string $service): array;
}
diff --git a/lib/public/Security/ICrypto.php b/lib/public/Security/ICrypto.php
index aa2b9eed2c0..ef5bd2bf7c9 100644
--- a/lib/public/Security/ICrypto.php
+++ b/lib/public/Security/ICrypto.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -42,7 +43,7 @@ interface ICrypto {
* @return string Calculated HMAC
* @since 8.0.0
*/
- public function calculateHMAC($message, $password = '');
+ public function calculateHMAC(string $message, string $password = ''): string;
/**
* Encrypts a value and adds an HMAC (Encrypt-Then-MAC)
@@ -51,7 +52,7 @@ interface ICrypto {
* @return string Authenticated ciphertext
* @since 8.0.0
*/
- public function encrypt($plaintext, $password = '');
+ public function encrypt(string $plaintext, string $password = ''): string;
/**
* Decrypts a value and verifies the HMAC (Encrypt-Then-Mac)
diff --git a/lib/public/Security/IHasher.php b/lib/public/Security/IHasher.php
index 11159cbc010..5942814802a 100644
--- a/lib/public/Security/IHasher.php
+++ b/lib/public/Security/IHasher.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -53,7 +54,7 @@ interface IHasher {
* @return string Hash of the message with appended version parameter
* @since 8.0.0
*/
- public function hash($message);
+ public function hash(string $message): string;
/**
* @param string $message Message to verify
@@ -62,5 +63,5 @@ interface IHasher {
* @return bool Whether $hash is a valid hash of $message
* @since 8.0.0
*/
- public function verify($message, $hash, &$newHash = null);
+ public function verify(string $message, string $hash, &$newHash = null): bool ;
}
diff --git a/lib/public/Security/StringUtils.php b/lib/public/Security/StringUtils.php
index 04b5028cbd2..4ee1f47e836 100644
--- a/lib/public/Security/StringUtils.php
+++ b/lib/public/Security/StringUtils.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -42,7 +43,7 @@ class StringUtils {
* @since 8.0.0
* @deprecated 9.0.0 Use hash_equals
*/
- public static function equals($expected, $input) {
+ public static function equals(string $expected, string $input): bool {
return hash_equals($expected, $input);
}
}
diff --git a/lib/public/User.php b/lib/public/User.php
index 40be50dd19c..2fdf540b958 100644
--- a/lib/public/User.php
+++ b/lib/public/User.php
@@ -44,6 +44,7 @@ namespace OCP;
* This class provides access to the user management. You can get information
* about the currently logged in user and the permissions for example
* @since 5.0.0
+ * @deprecated 13.0.0
*/
class User {
/**
@@ -99,6 +100,7 @@ class User {
* Check if the user is logged in
* @return boolean
* @since 5.0.0
+ * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
*/
public static function isLoggedIn() {
return \OC::$server->getUserSession()->isLoggedIn();
@@ -113,35 +115,13 @@ class User {
* @since 5.0.0
*/
public static function userExists($uid, $excludingBackend = null) {
- return \OC_User::userExists($uid);
- }
- /**
- * Logs the user out including all the session data
- * Logout, destroys session
- * @deprecated 8.0.0 Use \OC::$server->getUserSession()->logout();
- * @since 5.0.0
- */
- public static function logout() {
- \OC::$server->getUserSession()->logout();
- }
-
- /**
- * Check if the password is correct
- * @param string $uid The username
- * @param string $password The password
- * @return string|false username on success, false otherwise
- *
- * Check if the password is correct without logging in the user
- * @deprecated 8.0.0 Use \OC::$server->getUserManager()->checkPassword();
- * @since 5.0.0
- */
- public static function checkPassword( $uid, $password ) {
- return \OC_User::checkPassword( $uid, $password );
+ return \OC::$server->getUserManager()->userExists($uid);
}
/**
* Check if the user is a admin, redirects to home if not
* @since 5.0.0
+ * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
*/
public static function checkAdminUser() {
\OC_Util::checkAdminUser();
@@ -151,6 +131,7 @@ class User {
* Check if the user is logged in, redirects to home if not. With
* redirect URL parameter to the request URI.
* @since 5.0.0
+ * @deprecated 13.0.0 Use annotation based ACLs from the AppFramework instead
*/
public static function checkLoggedIn() {
\OC_Util::checkLoggedIn();