aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/l10n/es_MX.js1
-rw-r--r--lib/l10n/es_MX.json1
-rw-r--r--lib/l10n/hu.js5
-rw-r--r--lib/l10n/hu.json5
-rw-r--r--lib/private/App/AppManager.php7
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php4
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php2
-rw-r--r--lib/private/Collaboration/Collaborators/MailPlugin.php13
-rw-r--r--lib/private/DB/Connection.php2
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php14
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php6
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php4
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php4
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php10
-rw-r--r--lib/private/Encryption/Manager.php9
-rw-r--r--lib/private/Mail/Attachment.php9
-rw-r--r--lib/private/Mail/EMailTemplate.php35
-rw-r--r--lib/private/Mail/Mailer.php21
-rw-r--r--lib/private/Mail/Message.php45
-rw-r--r--lib/private/Security/CSP/ContentSecurityPolicy.php47
-rw-r--r--lib/private/Security/CSP/ContentSecurityPolicyManager.php11
-rw-r--r--lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php5
-rw-r--r--lib/private/Security/CSRF/CsrfToken.php11
-rw-r--r--lib/private/Security/CSRF/CsrfTokenGenerator.php3
-rw-r--r--lib/private/Security/CSRF/CsrfTokenManager.php9
-rw-r--r--lib/private/Security/CSRF/TokenStorage/SessionStorage.php7
-rw-r--r--lib/private/Security/IdentityProof/Key.php7
-rw-r--r--lib/private/Security/IdentityProof/Manager.php11
-rw-r--r--lib/private/Security/IdentityProof/Signer.php5
-rw-r--r--lib/private/Updater.php2
-rw-r--r--lib/private/User/Database.php79
-rw-r--r--lib/private/legacy/app.php39
-rw-r--r--lib/public/DB/QueryBuilder/IFunctionBuilder.php9
-rw-r--r--lib/public/Mail/IAttachment.php13
-rw-r--r--lib/public/Mail/IEMailTemplate.php25
-rw-r--r--lib/public/Mail/IMailer.php13
-rw-r--r--lib/public/Mail/IMessage.php29
40 files changed, 277 insertions, 249 deletions
diff --git a/lib/base.php b/lib/base.php
index c5eabe1910a..f0e139d92c8 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -949,7 +949,7 @@ class OC {
$appIds = (array)$request->getParam('appid');
foreach($appIds as $appId) {
$appId = \OC_App::cleanAppId($appId);
- \OC_App::disable($appId);
+ \OC::$server->getAppManager()->disableApp($appId);
}
\OC_JSON::success();
exit();
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 68be5e2d595..d0c52b96a66 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -883,7 +883,6 @@ return array(
'OC\\Settings\\Controller\\ChangePasswordController' => $baseDir . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => $baseDir . '/settings/Controller/CheckSetupController.php',
'OC\\Settings\\Controller\\CommonSettingsTrait' => $baseDir . '/settings/Controller/CommonSettingsTrait.php',
- 'OC\\Settings\\Controller\\EncryptionController' => $baseDir . '/settings/Controller/EncryptionController.php',
'OC\\Settings\\Controller\\GroupsController' => $baseDir . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => $baseDir . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => $baseDir . '/settings/Controller/MailSettingsController.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 81f21f31c21..bad67fbb03c 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -913,7 +913,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Controller\\ChangePasswordController' => __DIR__ . '/../../..' . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => __DIR__ . '/../../..' . '/settings/Controller/CheckSetupController.php',
'OC\\Settings\\Controller\\CommonSettingsTrait' => __DIR__ . '/../../..' . '/settings/Controller/CommonSettingsTrait.php',
- 'OC\\Settings\\Controller\\EncryptionController' => __DIR__ . '/../../..' . '/settings/Controller/EncryptionController.php',
'OC\\Settings\\Controller\\GroupsController' => __DIR__ . '/../../..' . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/MailSettingsController.php',
diff --git a/lib/l10n/es_MX.js b/lib/l10n/es_MX.js
index 344eb1bf312..03436b3c2cd 100644
--- a/lib/l10n/es_MX.js
+++ b/lib/l10n/es_MX.js
@@ -27,6 +27,7 @@ OC.L10N.register(
"Following platforms are supported: %s" : "Las siguientes plataformas están soportadas: %s",
"Server version %s or higher is required." : "Se requiere la versión del servidor %s o superior. ",
"Server version %s or lower is required." : "La versión del servidor %s o inferior es requerdia. ",
+ "Logged in user must be an admin" : "El usuario firmado debe ser un administrador",
"Unknown filetype" : "Tipo de archivo desconocido",
"Invalid image" : "Imagen inválida",
"Avatar image is not square" : "La imagen del avatar no es un cuadrado",
diff --git a/lib/l10n/es_MX.json b/lib/l10n/es_MX.json
index 088e85cf549..c944ba0153a 100644
--- a/lib/l10n/es_MX.json
+++ b/lib/l10n/es_MX.json
@@ -25,6 +25,7 @@
"Following platforms are supported: %s" : "Las siguientes plataformas están soportadas: %s",
"Server version %s or higher is required." : "Se requiere la versión del servidor %s o superior. ",
"Server version %s or lower is required." : "La versión del servidor %s o inferior es requerdia. ",
+ "Logged in user must be an admin" : "El usuario firmado debe ser un administrador",
"Unknown filetype" : "Tipo de archivo desconocido",
"Invalid image" : "Imagen inválida",
"Avatar image is not square" : "La imagen del avatar no es un cuadrado",
diff --git a/lib/l10n/hu.js b/lib/l10n/hu.js
index 2f3f5e8d9df..0384a02b158 100644
--- a/lib/l10n/hu.js
+++ b/lib/l10n/hu.js
@@ -27,6 +27,7 @@ OC.L10N.register(
"Following platforms are supported: %s" : "Ezek a platformok támogatottak: %s",
"Server version %s or higher is required." : "%s vagy újabb szerver verzió szükséges.",
"Server version %s or lower is required." : "%s vagy régebbi szerver verzió szükséges.",
+ "Logged in user must be an admin" : "Adminnak kell bejelentkeznie",
"Unknown filetype" : "Ismeretlen fájl típus",
"Invalid image" : "Hibás kép",
"Avatar image is not square" : "Az avatár kép nem négyzetes.",
@@ -66,6 +67,10 @@ OC.L10N.register(
"Unknown user" : "Ismeretlen felhasználó",
"APCu" : "APCu",
"Redis" : "Redis",
+ "Create" : "Létrehozás",
+ "Change" : "Változtatás",
+ "Delete" : "Törlés",
+ "Share" : "Megosztás",
"Basic settings" : "Alapvető beállítások",
"Sharing" : "Megosztás",
"Security" : "Biztonság",
diff --git a/lib/l10n/hu.json b/lib/l10n/hu.json
index 37e2d31362e..794d9eff0f2 100644
--- a/lib/l10n/hu.json
+++ b/lib/l10n/hu.json
@@ -25,6 +25,7 @@
"Following platforms are supported: %s" : "Ezek a platformok támogatottak: %s",
"Server version %s or higher is required." : "%s vagy újabb szerver verzió szükséges.",
"Server version %s or lower is required." : "%s vagy régebbi szerver verzió szükséges.",
+ "Logged in user must be an admin" : "Adminnak kell bejelentkeznie",
"Unknown filetype" : "Ismeretlen fájl típus",
"Invalid image" : "Hibás kép",
"Avatar image is not square" : "Az avatár kép nem négyzetes.",
@@ -64,6 +65,10 @@
"Unknown user" : "Ismeretlen felhasználó",
"APCu" : "APCu",
"Redis" : "Redis",
+ "Create" : "Létrehozás",
+ "Change" : "Változtatás",
+ "Delete" : "Törlés",
+ "Share" : "Megosztás",
"Basic settings" : "Alapvető beállítások",
"Sharing" : "Megosztás",
"Security" : "Biztonság",
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 4bf15c23fab..81f1369cb5e 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -287,6 +287,13 @@ class AppManager implements IAppManager {
}
unset($this->installedAppsCache[$appId]);
$this->appConfig->setValue($appId, 'enabled', 'no');
+
+ // run uninstall steps
+ $appData = $this->getAppInfo($appId);
+ if (!is_null($appData)) {
+ \OC_App::executeRepairSteps($appId, $appData['repair-steps']['uninstall']);
+ }
+
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent(
ManagerEvent::EVENT_APP_DISABLE, $appId
));
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 63121c079bd..a8fd9349343 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -133,9 +133,11 @@ class AppFetcher extends Fetcher {
/**
* @param string $version
+ * @param string $filename
*/
- public function setVersion($version) {
+ public function setVersion(string $version, string $fileName = 'apps.json') {
parent::setVersion($version);
+ $this->fileName = $fileName;
$this->setEndpoint();
}
}
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index 4dbc360c0c4..172584c522b 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -194,7 +194,7 @@ abstract class Fetcher {
* Set the current Nextcloud version
* @param string $version
*/
- public function setVersion($version) {
+ public function setVersion(string $version) {
$this->version = $version;
}
}
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php
index b4964825182..c3816161ce3 100644
--- a/lib/private/Collaboration/Collaborators/MailPlugin.php
+++ b/lib/private/Collaboration/Collaborators/MailPlugin.php
@@ -73,7 +73,7 @@ class MailPlugin implements ISearchPlugin {
* @since 13.0.0
*/
public function search($search, $limit, $offset, ISearchResult $searchResult) {
- $result = ['wide' => [], 'exact' => []];
+ $result = $userResults = ['wide' => [], 'exact' => []];
$userType = new SearchResultType('users');
$emailType = new SearchResultType('emails');
@@ -136,14 +136,13 @@ class MailPlugin implements ISearchPlugin {
}
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
- $singleResult = [[
+ $userResults['wide'][] = [
'label' => $contact['FN'] . " ($emailAddress)",
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $cloud->getUser(),
- ]],
+ ],
];
- $searchResult->addResultSet($userType, $singleResult, []);
}
}
continue;
@@ -175,10 +174,13 @@ class MailPlugin implements ISearchPlugin {
if (!$this->shareeEnumeration) {
$result['wide'] = [];
+ $userResults['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
+ $userResults['wide'] = array_slice($userResults['wide'], $offset, $limit);
}
+
if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {
$result['exact'][] = [
'label' => $search,
@@ -189,6 +191,9 @@ class MailPlugin implements ISearchPlugin {
];
}
+ if (!empty($userResults['wide'])) {
+ $searchResult->addResultSet($userType, $userResults['wide'], []);
+ }
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']);
return true;
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index b9ef447b74b..8a8a2f100ef 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -401,7 +401,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
}
/**
- * Espace a parameter to be used in a LIKE query
+ * Escape a parameter to be used in a LIKE query
*
* @param string $param
* @return string
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
index a32ae4a1827..154f2447c77 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
@@ -26,6 +26,7 @@ namespace OC\DB\QueryBuilder\ExpressionBuilder;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
use OC\DB\QueryBuilder\CompositeExpression;
+use OC\DB\QueryBuilder\FunctionBuilder\FunctionBuilder;
use OC\DB\QueryBuilder\Literal;
use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
@@ -45,15 +46,20 @@ class ExpressionBuilder implements IExpressionBuilder {
/** @var IDBConnection */
protected $connection;
+ /** @var FunctionBuilder */
+ protected $functionBuilder;
+
/**
* Initializes a new <tt>ExpressionBuilder</tt>.
*
- * @param \OCP\IDBConnection $connection
+ * @param IDBConnection $connection
+ * @param IQueryBuilder $queryBuilder
*/
- public function __construct(IDBConnection $connection) {
+ public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
$this->connection = $connection;
$this->helper = new QuoteHelper();
$this->expressionBuilder = new DoctrineExpressionBuilder($connection);
+ $this->functionBuilder = $queryBuilder->func();
}
/**
@@ -298,9 +304,7 @@ class ExpressionBuilder implements IExpressionBuilder {
* @since 9.0.0
*/
public function iLike($x, $y, $type = null) {
- $x = $this->helper->quoteColumnName($x);
- $y = $this->helper->quoteColumnName($y);
- return $this->expressionBuilder->comparison("LOWER($x)", 'LIKE', "LOWER($y)");
+ return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
}
/**
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
index 17f7fd5aa47..aa7ef8e70be 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
@@ -25,6 +25,7 @@ namespace OC\DB\QueryBuilder\ExpressionBuilder;
use OC\DB\Connection;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
class MySqlExpressionBuilder extends ExpressionBuilder {
@@ -34,9 +35,10 @@ class MySqlExpressionBuilder extends ExpressionBuilder {
/**
* @param \OCP\IDBConnection|Connection $connection
+ * @param IQueryBuilder $queryBuilder
*/
- public function __construct(IDBConnection $connection) {
- parent::__construct($connection);
+ public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
+ parent::__construct($connection, $queryBuilder);
$params = $connection->getParams();
$this->charset = isset($params['charset']) ? $params['charset'] : 'utf8';
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
index 14d8ad33e40..d9e8a1279cc 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
@@ -31,4 +31,8 @@ class SqliteExpressionBuilder extends ExpressionBuilder {
public function like($x, $y, $type = null) {
return parent::like($x, $y, $type) . " ESCAPE '\\'";
}
+
+ public function iLike($x, $y, $type = null) {
+ return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type);
+ }
}
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
index 2789b8cb356..1d745306351 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
@@ -59,4 +59,8 @@ class FunctionBuilder implements IFunctionBuilder {
public function sum($field) {
return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')');
}
+
+ public function lower($field) {
+ return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')');
+ }
}
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index 58be4b43255..d6f8bb48acd 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -112,15 +112,15 @@ class QueryBuilder implements IQueryBuilder {
*/
public function expr() {
if ($this->connection instanceof OracleConnection) {
- return new OCIExpressionBuilder($this->connection);
+ return new OCIExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
- return new PgSqlExpressionBuilder($this->connection);
+ return new PgSqlExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
- return new MySqlExpressionBuilder($this->connection);
+ return new MySqlExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
- return new SqliteExpressionBuilder($this->connection);
+ return new SqliteExpressionBuilder($this->connection, $this);
} else {
- return new ExpressionBuilder($this->connection);
+ return new ExpressionBuilder($this->connection, $this);
}
}
diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php
index fe34ef4555b..9bec1db73e3 100644
--- a/lib/private/Encryption/Manager.php
+++ b/lib/private/Encryption/Manager.php
@@ -101,15 +101,6 @@ class Manager implements IManager {
* @throws ServiceUnavailableException
*/
public function isReady() {
- // check if we are still in transit between the old and the new encryption
- $oldEncryption = $this->config->getAppValue('files_encryption', 'installed_version');
- if (!empty($oldEncryption)) {
- $warning = 'Installation is in transit between the old Encryption (ownCloud <= 8.0)
- and the new encryption. Please enable the "Default encryption module"
- and run \'occ encryption:migrate\'';
- $this->logger->warning($warning);
- return false;
- }
if ($this->isKeyStorageReady() === false) {
throw new ServiceUnavailableException('Key Storage is not ready');
diff --git a/lib/private/Mail/Attachment.php b/lib/private/Mail/Attachment.php
index 822fca5a24e..b696451e41c 100644
--- a/lib/private/Mail/Attachment.php
+++ b/lib/private/Mail/Attachment.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
@@ -45,7 +46,7 @@ class Attachment implements IAttachment {
* @return $this
* @since 13.0.0
*/
- public function setFilename($filename) {
+ public function setFilename(string $filename): IAttachment {
$this->swiftAttachment->setFilename($filename);
return $this;
}
@@ -55,7 +56,7 @@ class Attachment implements IAttachment {
* @return $this
* @since 13.0.0
*/
- public function setContentType($contentType) {
+ public function setContentType(string $contentType): IAttachment {
$this->swiftAttachment->setContentType($contentType);
return $this;
}
@@ -65,7 +66,7 @@ class Attachment implements IAttachment {
* @return $this
* @since 13.0.0
*/
- public function setBody($body) {
+ public function setBody(string $body): IAttachment {
$this->swiftAttachment->setBody($body);
return $this;
}
@@ -73,7 +74,7 @@ class Attachment implements IAttachment {
/**
* @return \Swift_Mime_Attachment
*/
- public function getSwiftAttachment() {
+ public function getSwiftAttachment(): \Swift_Mime_Attachment {
return $this->swiftAttachment;
}
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 38205af366e..0ba411d6926 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright 2017, Morris Jobke <hey@morrisjobke.de>
* @copyright 2017, Lukas Reschke <lukas@statuscode.ch>
@@ -367,7 +368,7 @@ EOF;
*
* @param string $subject
*/
- public function setSubject($subject) {
+ public function setSubject(string $subject) {
$this->subject = $subject;
}
@@ -391,7 +392,7 @@ EOF;
* @param string|bool $plainTitle Title that is used in the plain text email
* if empty the $title is used, if false none will be used
*/
- public function addHeading($title, $plainTitle = '') {
+ public function addHeading(string $title, $plainTitle = '') {
if ($this->footerAdded) {
return;
}
@@ -424,7 +425,7 @@ EOF;
* @param string|bool $plainText Text that is used in the plain text email
* if empty the $text is used, if false none will be used
*/
- public function addBodyText($text, $plainText = '') {
+ public function addBodyText(string $text, $plainText = '') {
if ($this->footerAdded) {
return;
}
@@ -447,13 +448,13 @@ EOF;
* @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
* @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
* @param string $icon Absolute path, must be 16*16 pixels
- * @param string $plainText Text that is used in the plain text email
+ * @param string|bool $plainText Text that is used in the plain text email
* if empty the $text is used, if false none will be used
- * @param string $plainMetaInfo Meta info that is used in the plain text email
+ * @param string|bool $plainMetaInfo Meta info that is used in the plain text email
* if empty the $metaInfo is used, if false none will be used
* @since 12.0.0
*/
- public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') {
+ public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '') {
$this->ensureBodyListOpened();
if ($plainText === '') {
@@ -513,12 +514,12 @@ EOF;
* @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
* @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
*/
- public function addBodyButtonGroup($textLeft,
- $urlLeft,
- $textRight,
- $urlRight,
- $plainTextLeft = '',
- $plainTextRight = '') {
+ public function addBodyButtonGroup(string $textLeft,
+ string $urlLeft,
+ string $textRight,
+ string $urlRight,
+ string $plainTextLeft = '',
+ string $plainTextRight = '') {
if ($this->footerAdded) {
return;
}
@@ -554,7 +555,7 @@ EOF;
*
* @since 12.0.0
*/
- public function addBodyButton($text, $url, $plainText = '') {
+ public function addBodyButton(string $text, string $url, $plainText = '') {
if ($this->footerAdded) {
return;
}
@@ -598,7 +599,7 @@ EOF;
*
* @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
*/
- public function addFooter($text = '') {
+ public function addFooter(string $text = '') {
if($text === '') {
$text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
}
@@ -621,7 +622,7 @@ EOF;
*
* @return string
*/
- public function renderSubject() {
+ public function renderSubject(): string {
return $this->subject;
}
@@ -630,7 +631,7 @@ EOF;
*
* @return string
*/
- public function renderHtml() {
+ public function renderHtml(): string {
if (!$this->footerAdded) {
$this->footerAdded = true;
$this->ensureBodyIsClosed();
@@ -644,7 +645,7 @@ EOF;
*
* @return string
*/
- public function renderText() {
+ public function renderText(): string {
if (!$this->footerAdded) {
$this->footerAdded = true;
$this->ensureBodyIsClosed();
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 3637bb1e27d..5a054d2efd2 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -91,7 +92,7 @@ class Mailer implements IMailer {
*
* @return IMessage
*/
- public function createMessage() {
+ public function createMessage(): IMessage {
return new Message(new \Swift_Message());
}
@@ -102,7 +103,7 @@ class Mailer implements IMailer {
* @return IAttachment
* @since 13.0.0
*/
- public function createAttachment($data = null, $filename = null, $contentType = null) {
+ public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
}
@@ -112,7 +113,7 @@ class Mailer implements IMailer {
* @return IAttachment
* @since 13.0.0
*/
- public function createAttachmentFromPath($path, $contentType = null) {
+ public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
}
@@ -124,7 +125,7 @@ class Mailer implements IMailer {
* @return IEMailTemplate
* @since 12.0.0
*/
- public function createEMailTemplate($emailId, array $data = []) {
+ public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
$class = $this->config->getSystemValue('mail_template_class', '');
if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
@@ -156,7 +157,7 @@ class Mailer implements IMailer {
* @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
* has been supplied.)
*/
- public function send(IMessage $message) {
+ public function send(IMessage $message): array {
$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
if (empty($message->getFrom())) {
@@ -191,7 +192,7 @@ class Mailer implements IMailer {
* @param string $email Email address to be validated
* @return bool True if the mail address is valid, false otherwise
*/
- public function validateMailAddress($email) {
+ public function validateMailAddress(string $email): bool {
return \Swift_Validate::email($this->convertEmail($email));
}
@@ -203,7 +204,7 @@ class Mailer implements IMailer {
* @param string $email
* @return string Converted mail address if `idn_to_ascii` exists
*/
- protected function convertEmail($email) {
+ protected function convertEmail(string $email): string {
if (!function_exists('idn_to_ascii') || strpos($email, '@') === false) {
return $email;
}
@@ -246,7 +247,7 @@ class Mailer implements IMailer {
*
* @return \Swift_SmtpTransport
*/
- protected function getSmtpInstance() {
+ protected function getSmtpInstance(): \Swift_SmtpTransport {
$transport = \Swift_SmtpTransport::newInstance();
$transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
$transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
@@ -269,7 +270,7 @@ class Mailer implements IMailer {
*
* @return \Swift_SendmailTransport
*/
- protected function getSendMailInstance() {
+ protected function getSendMailInstance(): \Swift_SendmailTransport {
switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
case 'qmail':
$binaryPath = '/var/qmail/bin/sendmail';
@@ -287,7 +288,7 @@ class Mailer implements IMailer {
*
* @return \Swift_MailTransport
*/
- protected function getMailInstance() {
+ protected function getMailInstance(): \Swift_MailTransport {
return \Swift_MailTransport::newInstance();
}
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index c695f0f4fb1..622c18a9116 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -51,7 +52,7 @@ class Message implements IMessage {
* @return $this
* @since 13.0.0
*/
- public function attach(IAttachment $attachment) {
+ public function attach(IAttachment $attachment): IMessage {
/** @var Attachment $attachment */
$this->swiftMessage->attach($attachment->getSwiftAttachment());
return $this;
@@ -64,12 +65,12 @@ class Message implements IMessage {
* @param array $addresses Array of mail addresses, key will get converted
* @return array Converted addresses if `idn_to_ascii` exists
*/
- protected function convertAddresses($addresses) {
+ protected function convertAddresses(array $addresses): array {
if (!function_exists('idn_to_ascii')) {
return $addresses;
}
- $convertedAddresses = array();
+ $convertedAddresses = [];
foreach($addresses as $email => $readableName) {
if(!is_numeric($email)) {
@@ -94,7 +95,7 @@ class Message implements IMessage {
* @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
- public function setFrom(array $addresses) {
+ public function setFrom(array $addresses): IMessage {
$addresses = $this->convertAddresses($addresses);
$this->swiftMessage->setFrom($addresses);
@@ -106,7 +107,7 @@ class Message implements IMessage {
*
* @return array
*/
- public function getFrom() {
+ public function getFrom(): array {
return $this->swiftMessage->getFrom();
}
@@ -116,7 +117,7 @@ class Message implements IMessage {
* @param array $addresses
* @return $this
*/
- public function setReplyTo(array $addresses) {
+ public function setReplyTo(array $addresses): IMessage {
$addresses = $this->convertAddresses($addresses);
$this->swiftMessage->setReplyTo($addresses);
@@ -126,9 +127,9 @@ class Message implements IMessage {
/**
* Returns the Reply-To address of this message
*
- * @return array
+ * @return string
*/
- public function getReplyTo() {
+ public function getReplyTo(): string {
return $this->swiftMessage->getReplyTo();
}
@@ -138,7 +139,7 @@ class Message implements IMessage {
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
- public function setTo(array $recipients) {
+ public function setTo(array $recipients): IMessage {
$recipients = $this->convertAddresses($recipients);
$this->swiftMessage->setTo($recipients);
@@ -150,7 +151,7 @@ class Message implements IMessage {
*
* @return array
*/
- public function getTo() {
+ public function getTo(): array {
return $this->swiftMessage->getTo();
}
@@ -160,7 +161,7 @@ class Message implements IMessage {
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
- public function setCc(array $recipients) {
+ public function setCc(array $recipients): IMessage {
$recipients = $this->convertAddresses($recipients);
$this->swiftMessage->setCc($recipients);
@@ -172,7 +173,7 @@ class Message implements IMessage {
*
* @return array
*/
- public function getCc() {
+ public function getCc(): array {
return $this->swiftMessage->getCc();
}
@@ -182,7 +183,7 @@ class Message implements IMessage {
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
- public function setBcc(array $recipients) {
+ public function setBcc(array $recipients): IMessage {
$recipients = $this->convertAddresses($recipients);
$this->swiftMessage->setBcc($recipients);
@@ -194,17 +195,17 @@ class Message implements IMessage {
*
* @return array
*/
- public function getBcc() {
+ public function getBcc(): array {
return $this->swiftMessage->getBcc();
}
/**
* Set the subject of this message.
*
- * @param $subject
- * @return $this
+ * @param string $subject
+ * @return IMessage
*/
- public function setSubject($subject) {
+ public function setSubject(string $subject): IMessage {
$this->swiftMessage->setSubject($subject);
return $this;
}
@@ -214,7 +215,7 @@ class Message implements IMessage {
*
* @return string
*/
- public function getSubject() {
+ public function getSubject(): string {
return $this->swiftMessage->getSubject();
}
@@ -224,7 +225,7 @@ class Message implements IMessage {
* @param string $body
* @return $this
*/
- public function setPlainBody($body) {
+ public function setPlainBody(string $body): IMessage {
$this->swiftMessage->setBody($body);
return $this;
}
@@ -234,7 +235,7 @@ class Message implements IMessage {
*
* @return string
*/
- public function getPlainBody() {
+ public function getPlainBody(): string {
return $this->swiftMessage->getBody();
}
@@ -253,7 +254,7 @@ class Message implements IMessage {
* Get's the underlying SwiftMessage
* @return Swift_Message
*/
- public function getSwiftMessage() {
+ public function getSwiftMessage(): Swift_Message {
return $this->swiftMessage;
}
@@ -271,7 +272,7 @@ class Message implements IMessage {
* @param IEMailTemplate $emailTemplate
* @return $this
*/
- public function useTemplate(IEMailTemplate $emailTemplate) {
+ public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
$this->setSubject($emailTemplate->renderSubject());
$this->setPlainBody($emailTemplate->renderText());
$this->setHtmlBody($emailTemplate->renderHtml());
diff --git a/lib/private/Security/CSP/ContentSecurityPolicy.php b/lib/private/Security/CSP/ContentSecurityPolicy.php
index 2adc3d3d12c..77e20dedf44 100644
--- a/lib/private/Security/CSP/ContentSecurityPolicy.php
+++ b/lib/private/Security/CSP/ContentSecurityPolicy.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -33,147 +34,147 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy
/**
* @return boolean
*/
- public function isInlineScriptAllowed() {
+ public function isInlineScriptAllowed(): bool {
return $this->inlineScriptAllowed;
}
/**
* @param boolean $inlineScriptAllowed
*/
- public function setInlineScriptAllowed($inlineScriptAllowed) {
+ public function setInlineScriptAllowed(bool $inlineScriptAllowed) {
$this->inlineScriptAllowed = $inlineScriptAllowed;
}
/**
* @return boolean
*/
- public function isEvalScriptAllowed() {
+ public function isEvalScriptAllowed(): bool {
return $this->evalScriptAllowed;
}
/**
* @param boolean $evalScriptAllowed
*/
- public function setEvalScriptAllowed($evalScriptAllowed) {
+ public function setEvalScriptAllowed(bool $evalScriptAllowed) {
$this->evalScriptAllowed = $evalScriptAllowed;
}
/**
* @return array
*/
- public function getAllowedScriptDomains() {
+ public function getAllowedScriptDomains(): array {
return $this->allowedScriptDomains;
}
/**
* @param array $allowedScriptDomains
*/
- public function setAllowedScriptDomains($allowedScriptDomains) {
+ public function setAllowedScriptDomains(array $allowedScriptDomains) {
$this->allowedScriptDomains = $allowedScriptDomains;
}
/**
* @return boolean
*/
- public function isInlineStyleAllowed() {
+ public function isInlineStyleAllowed(): bool {
return $this->inlineStyleAllowed;
}
/**
* @param boolean $inlineStyleAllowed
*/
- public function setInlineStyleAllowed($inlineStyleAllowed) {
+ public function setInlineStyleAllowed(bool $inlineStyleAllowed) {
$this->inlineStyleAllowed = $inlineStyleAllowed;
}
/**
* @return array
*/
- public function getAllowedStyleDomains() {
+ public function getAllowedStyleDomains(): array {
return $this->allowedStyleDomains;
}
/**
* @param array $allowedStyleDomains
*/
- public function setAllowedStyleDomains($allowedStyleDomains) {
+ public function setAllowedStyleDomains(array $allowedStyleDomains) {
$this->allowedStyleDomains = $allowedStyleDomains;
}
/**
* @return array
*/
- public function getAllowedImageDomains() {
+ public function getAllowedImageDomains(): array {
return $this->allowedImageDomains;
}
/**
* @param array $allowedImageDomains
*/
- public function setAllowedImageDomains($allowedImageDomains) {
+ public function setAllowedImageDomains(array $allowedImageDomains) {
$this->allowedImageDomains = $allowedImageDomains;
}
/**
* @return array
*/
- public function getAllowedConnectDomains() {
+ public function getAllowedConnectDomains(): array {
return $this->allowedConnectDomains;
}
/**
* @param array $allowedConnectDomains
*/
- public function setAllowedConnectDomains($allowedConnectDomains) {
+ public function setAllowedConnectDomains(array $allowedConnectDomains) {
$this->allowedConnectDomains = $allowedConnectDomains;
}
/**
* @return array
*/
- public function getAllowedMediaDomains() {
+ public function getAllowedMediaDomains(): array {
return $this->allowedMediaDomains;
}
/**
* @param array $allowedMediaDomains
*/
- public function setAllowedMediaDomains($allowedMediaDomains) {
+ public function setAllowedMediaDomains(array $allowedMediaDomains) {
$this->allowedMediaDomains = $allowedMediaDomains;
}
/**
* @return array
*/
- public function getAllowedObjectDomains() {
+ public function getAllowedObjectDomains(): array {
return $this->allowedObjectDomains;
}
/**
* @param array $allowedObjectDomains
*/
- public function setAllowedObjectDomains($allowedObjectDomains) {
+ public function setAllowedObjectDomains(array $allowedObjectDomains) {
$this->allowedObjectDomains = $allowedObjectDomains;
}
/**
* @return array
*/
- public function getAllowedFrameDomains() {
+ public function getAllowedFrameDomains(): array {
return $this->allowedFrameDomains;
}
/**
* @param array $allowedFrameDomains
*/
- public function setAllowedFrameDomains($allowedFrameDomains) {
+ public function setAllowedFrameDomains(array $allowedFrameDomains) {
$this->allowedFrameDomains = $allowedFrameDomains;
}
/**
* @return array
*/
- public function getAllowedFontDomains() {
+ public function getAllowedFontDomains(): array {
return $this->allowedFontDomains;
}
@@ -187,7 +188,7 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy
/**
* @return array
*/
- public function getAllowedChildSrcDomains() {
+ public function getAllowedChildSrcDomains(): array {
return $this->allowedChildSrcDomains;
}
@@ -201,7 +202,7 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy
/**
* @return array
*/
- public function getAllowedFrameAncestors() {
+ public function getAllowedFrameAncestors(): array {
return $this->allowedFrameAncestors;
}
diff --git a/lib/private/Security/CSP/ContentSecurityPolicyManager.php b/lib/private/Security/CSP/ContentSecurityPolicyManager.php
index 0e6f0ac6152..27a0524d3f3 100644
--- a/lib/private/Security/CSP/ContentSecurityPolicyManager.php
+++ b/lib/private/Security/CSP/ContentSecurityPolicyManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -41,7 +42,7 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager {
*
* @return ContentSecurityPolicy
*/
- public function getDefaultPolicy() {
+ public function getDefaultPolicy(): ContentSecurityPolicy {
$defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
foreach($this->policies as $policy) {
$defaultPolicy = $this->mergePolicies($defaultPolicy, $policy);
@@ -57,14 +58,14 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager {
* @return ContentSecurityPolicy
*/
public function mergePolicies(ContentSecurityPolicy $defaultPolicy,
- EmptyContentSecurityPolicy $originalPolicy) {
+ EmptyContentSecurityPolicy $originalPolicy): ContentSecurityPolicy {
foreach((object)(array)$originalPolicy as $name => $value) {
$setter = 'set'.ucfirst($name);
- if(is_array($value)) {
+ if(\is_array($value)) {
$getter = 'get'.ucfirst($name);
- $currentValues = is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : [];
+ $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : [];
$defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value))));
- } elseif (is_bool($value)) {
+ } elseif (\is_bool($value)) {
$defaultPolicy->$setter($value);
}
}
diff --git a/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php b/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php
index 266e5809c24..088fb2d859d 100644
--- a/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php
+++ b/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
@@ -55,7 +56,7 @@ class ContentSecurityPolicyNonceManager {
*
* @return string
*/
- public function getNonce() {
+ public function getNonce(): string {
if($this->nonce === '') {
$this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue());
}
@@ -68,7 +69,7 @@ class ContentSecurityPolicyNonceManager {
*
* @return bool
*/
- public function browserSupportsCspV3() {
+ public function browserSupportsCspV3(): bool {
$browserWhitelist = [
Request::USER_AGENT_CHROME,
// Firefox 45+
diff --git a/lib/private/Security/CSRF/CsrfToken.php b/lib/private/Security/CSRF/CsrfToken.php
index d9e27ff80e3..643e58e1d53 100644
--- a/lib/private/Security/CSRF/CsrfToken.php
+++ b/lib/private/Security/CSRF/CsrfToken.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -40,7 +41,7 @@ class CsrfToken {
/**
* @param string $value Value of the token. Can be encrypted or not encrypted.
*/
- public function __construct($value) {
+ public function __construct(string $value) {
$this->value = $value;
}
@@ -50,9 +51,9 @@ class CsrfToken {
*
* @return string
*/
- public function getEncryptedValue() {
+ public function getEncryptedValue(): string {
if($this->encryptedValue === '') {
- $sharedSecret = random_bytes(strlen($this->value));
+ $sharedSecret = random_bytes(\strlen($this->value));
$this->encryptedValue = base64_encode($this->value ^ $sharedSecret) . ':' . base64_encode($sharedSecret);
}
@@ -65,9 +66,9 @@ class CsrfToken {
*
* @return string
*/
- public function getDecryptedValue() {
+ public function getDecryptedValue(): string {
$token = explode(':', $this->value);
- if (count($token) !== 2) {
+ if (\count($token) !== 2) {
return '';
}
$obfuscatedToken = $token[0];
diff --git a/lib/private/Security/CSRF/CsrfTokenGenerator.php b/lib/private/Security/CSRF/CsrfTokenGenerator.php
index 85207956e1a..be628ea176c 100644
--- a/lib/private/Security/CSRF/CsrfTokenGenerator.php
+++ b/lib/private/Security/CSRF/CsrfTokenGenerator.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -47,7 +48,7 @@ class CsrfTokenGenerator {
* @param int $length Length of the token in characters.
* @return string
*/
- public function generateToken($length = 32) {
+ public function generateToken(int $length = 32): string {
return $this->random->generate($length);
}
}
diff --git a/lib/private/Security/CSRF/CsrfTokenManager.php b/lib/private/Security/CSRF/CsrfTokenManager.php
index b43ca3d3679..deacd1f512c 100644
--- a/lib/private/Security/CSRF/CsrfTokenManager.php
+++ b/lib/private/Security/CSRF/CsrfTokenManager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -52,8 +53,8 @@ class CsrfTokenManager {
*
* @return CsrfToken
*/
- public function getToken() {
- if(!is_null($this->csrfToken)) {
+ public function getToken(): CsrfToken {
+ if(!\is_null($this->csrfToken)) {
return $this->csrfToken;
}
@@ -73,7 +74,7 @@ class CsrfTokenManager {
*
* @return CsrfToken
*/
- public function refreshToken() {
+ public function refreshToken(): CsrfToken {
$value = $this->tokenGenerator->generateToken();
$this->sessionStorage->setToken($value);
$this->csrfToken = new CsrfToken($value);
@@ -94,7 +95,7 @@ class CsrfTokenManager {
* @param CsrfToken $token
* @return bool
*/
- public function isTokenValid(CsrfToken $token) {
+ public function isTokenValid(CsrfToken $token): bool {
if(!$this->sessionStorage->hasToken()) {
return false;
}
diff --git a/lib/private/Security/CSRF/TokenStorage/SessionStorage.php b/lib/private/Security/CSRF/TokenStorage/SessionStorage.php
index 946330b0c8c..b35e148c7ce 100644
--- a/lib/private/Security/CSRF/TokenStorage/SessionStorage.php
+++ b/lib/private/Security/CSRF/TokenStorage/SessionStorage.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -54,7 +55,7 @@ class SessionStorage {
* @return string
* @throws \Exception
*/
- public function getToken() {
+ public function getToken(): string {
$token = $this->session->get('requesttoken');
if(empty($token)) {
throw new \Exception('Session does not contain a requesttoken');
@@ -68,7 +69,7 @@ class SessionStorage {
*
* @param string $value
*/
- public function setToken($value) {
+ public function setToken(string $value) {
$this->session->set('requesttoken', $value);
}
@@ -83,7 +84,7 @@ class SessionStorage {
*
* @return bool
*/
- public function hasToken() {
+ public function hasToken(): bool {
return $this->session->exists('requesttoken');
}
}
diff --git a/lib/private/Security/IdentityProof/Key.php b/lib/private/Security/IdentityProof/Key.php
index b01a5c66bb8..4f79dee15db 100644
--- a/lib/private/Security/IdentityProof/Key.php
+++ b/lib/private/Security/IdentityProof/Key.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
@@ -33,16 +34,16 @@ class Key {
* @param string $publicKey
* @param string $privateKey
*/
- public function __construct($publicKey, $privateKey) {
+ public function __construct(string $publicKey, string $privateKey) {
$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
}
- public function getPrivate() {
+ public function getPrivate(): string {
return $this->privateKey;
}
- public function getPublic() {
+ public function getPublic(): string {
return $this->publicKey;
}
}
diff --git a/lib/private/Security/IdentityProof/Manager.php b/lib/private/Security/IdentityProof/Manager.php
index 7bfc139b94c..fb27f04d873 100644
--- a/lib/private/Security/IdentityProof/Manager.php
+++ b/lib/private/Security/IdentityProof/Manager.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
@@ -59,7 +60,7 @@ class Manager {
*
* @return array [$publicKey, $privateKey]
*/
- protected function generateKeyPair() {
+ protected function generateKeyPair(): array {
$config = [
'digest_alg' => 'sha512',
'private_key_bits' => 2048,
@@ -83,7 +84,7 @@ class Manager {
* @param string $id key id
* @return Key
*/
- protected function generateKey($id) {
+ protected function generateKey(string $id): Key {
list($publicKey, $privateKey) = $this->generateKeyPair();
// Write the private and public key to the disk
@@ -105,7 +106,7 @@ class Manager {
* @param string $id
* @return Key
*/
- protected function retrieveKey($id) {
+ protected function retrieveKey(string $id): Key {
try {
$folder = $this->appData->getFolder($id);
$privateKey = $this->crypto->decrypt(
@@ -124,7 +125,7 @@ class Manager {
* @param IUser $user
* @return Key
*/
- public function getKey(IUser $user) {
+ public function getKey(IUser $user): Key {
$uid = $user->getUID();
return $this->retrieveKey('user-' . $uid);
}
@@ -135,7 +136,7 @@ class Manager {
* @return Key
* @throws \RuntimeException
*/
- public function getSystemKey() {
+ public function getSystemKey(): Key {
$instanceId = $this->config->getSystemValue('instanceid', null);
if ($instanceId === null) {
throw new \RuntimeException('no instance id!');
diff --git a/lib/private/Security/IdentityProof/Signer.php b/lib/private/Security/IdentityProof/Signer.php
index ed2a38f99b8..95546876bdc 100644
--- a/lib/private/Security/IdentityProof/Signer.php
+++ b/lib/private/Security/IdentityProof/Signer.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
@@ -57,7 +58,7 @@ class Signer {
* @param IUser $user
* @return array ['message', 'signature']
*/
- public function sign($type, array $data, IUser $user) {
+ public function sign(string $type, array $data, IUser $user): array {
$privateKey = $this->keyManager->getKey($user)->getPrivate();
$data = [
'data' => $data,
@@ -79,7 +80,7 @@ class Signer {
* @param array $data
* @return bool
*/
- public function verify(array $data) {
+ public function verify(array $data): bool {
if(isset($data['message'])
&& isset($data['signature'])
&& isset($data['message']['signer'])
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index c70113e1c7d..4dc8edc0272 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -395,7 +395,7 @@ class Updater extends BasicEmitter {
if ($appManager->isShipped($app)) {
throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
}
- OC_App::disable($app);
+ \OC::$server->getAppManager()->disableApp($app);
$this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app));
}
// no need to disable any app in case this is a non-core upgrade
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index 471ff1f45ae..6e44c902286 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -40,6 +40,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
/*
*
* The following SQL statement is just a help for developers and will not be
@@ -56,6 +57,7 @@
namespace OC\User;
use OC\Cache\CappedMemoryCache;
+use OC\DB\QueryBuilder\Literal;
use OCP\IUserBackend;
use OCP\Util;
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -83,6 +85,7 @@ class Database extends Backend implements IUserBackend {
/**
* Create a new user
+ *
* @param string $uid The username of the user to create
* @param string $password The password of the new user
* @return bool
@@ -112,6 +115,7 @@ class Database extends Backend implements IUserBackend {
/**
* delete a user
+ *
* @param string $uid The username of the user to delete
* @return bool
*
@@ -131,6 +135,7 @@ class Database extends Backend implements IUserBackend {
/**
* Set password
+ *
* @param string $uid The username
* @param string $password The new password
* @return bool
@@ -152,6 +157,7 @@ class Database extends Backend implements IUserBackend {
/**
* Set display name
+ *
* @param string $uid The username
* @param string $displayName The new display name
* @return bool
@@ -172,6 +178,7 @@ class Database extends Backend implements IUserBackend {
/**
* get display name of the user
+ *
* @param string $uid user ID of the user
* @return string display name
*/
@@ -189,20 +196,29 @@ class Database extends Backend implements IUserBackend {
* @return array an array of all displayNames (value) and the corresponding uids (key)
*/
public function getDisplayNames($search = '', $limit = null, $offset = null) {
- $parameters = [];
- $searchLike = '';
- if ($search !== '') {
- $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
- $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
- $searchLike = ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
- . 'LOWER(`uid`) LIKE LOWER(?)';
- }
+ $connection = \OC::$server->getDatabaseConnection();
+
+ $query = $connection->getQueryBuilder();
+
+ $query->select('uid', 'displayname')
+ ->from('users', 'u')
+ ->leftJoin('u', 'preferences', 'p', $query->expr()->andX(
+ $query->expr()->eq('userid', 'uid')),
+ $query->expr()->eq('appid', new Literal('settings')),
+ $query->expr()->eq('configkey', new Literal('email'))
+ )
+ // sqlite doesn't like re-using a single named parameter here
+ ->where($query->expr()->iLike('uid', $query->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%')))
+ ->orWhere($query->expr()->iLike('displayname', $query->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%')))
+ ->orWhere($query->expr()->iLike('configvalue', $query->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%')))
+ ->orderBy($query->func()->lower('displayname'), 'ASC')
+ ->orderBy($query->func()->lower('uid'), 'ASC')
+ ->setMaxResults($limit)
+ ->setFirstResult($offset);
- $displayNames = array();
- $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
- . $searchLike .' ORDER BY LOWER(`displayname`), LOWER(`uid`) ASC', $limit, $offset);
- $result = $query->execute($parameters);
- while ($row = $result->fetchRow()) {
+ $result = $query->execute();
+ $displayNames = [];
+ while ($row = $result->fetch()) {
$displayNames[$row['uid']] = $row['displayname'];
}
@@ -211,6 +227,7 @@ class Database extends Backend implements IUserBackend {
/**
* Check if the password is correct
+ *
* @param string $uid The username
* @param string $password The password
* @return string
@@ -226,8 +243,8 @@ class Database extends Backend implements IUserBackend {
if ($row) {
$storedHash = $row['password'];
$newHash = '';
- if(\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
- if(!empty($newHash)) {
+ if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
+ if (!empty($newHash)) {
$this->setPassword($uid, $password);
}
return $row['uid'];
@@ -240,15 +257,16 @@ class Database extends Backend implements IUserBackend {
/**
* Load an user in the cache
+ *
* @param string $uid the username
* @return boolean true if user was found, false otherwise
*/
private function loadUser($uid) {
- $uid = (string) $uid;
+ $uid = (string)$uid;
if (!isset($this->cache[$uid])) {
//guests $uid could be NULL or ''
if ($uid === '') {
- $this->cache[$uid]=false;
+ $this->cache[$uid] = false;
return true;
}
@@ -285,26 +303,15 @@ class Database extends Backend implements IUserBackend {
* @return string[] an array of all uids
*/
public function getUsers($search = '', $limit = null, $offset = null) {
- $parameters = [];
- $searchLike = '';
- if ($search !== '') {
- $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
- $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
- $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
- $searchLike .= ' OR LOWER(`displayname`) LIKE LOWER(?)';
- }
-
- $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY LOWER(`uid`) ASC', $limit, $offset);
- $result = $query->execute($parameters);
- $users = array();
- while ($row = $result->fetchRow()) {
- $users[] = $row['uid'];
- }
- return $users;
+ $users = $this->getDisplayNames($search, $limit, $offset);
+ $userIds = array_keys($users);
+ sort($userIds, SORT_STRING | SORT_FLAG_CASE);
+ return $userIds;
}
/**
* check if a user exists
+ *
* @param string $uid the username
* @return boolean
*/
@@ -315,6 +322,7 @@ class Database extends Backend implements IUserBackend {
/**
* get the user's home directory
+ *
* @param string $uid the username
* @return string|false
*/
@@ -364,14 +372,15 @@ class Database extends Backend implements IUserBackend {
/**
* Backend name to be shown in user management
+ *
* @return string the name of the backend to be shown
*/
- public function getBackendName(){
+ public function getBackendName() {
return 'Database';
}
public static function preLoginNameUsedAsUserName($param) {
- if(!isset($param['uid'])) {
+ if (!isset($param['uid'])) {
throw new \Exception('key uid is expected to be set in $param');
}
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 16e57d43ebc..bc450ffa25d 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -154,16 +154,9 @@ class OC_App {
\OC::$server->getLogger()->logException($ex);
if (!\OC::$server->getAppManager()->isShipped($app)) {
// Only disable apps which are not shipped
- self::disable($app);
+ \OC::$server->getAppManager()->disableApp($app);
}
}
- if (self::isType($app, array('authentication'))) {
- // since authentication apps affect the "is app enabled for group" check,
- // the enabled apps cache needs to be cleared to make sure that the
- // next time getEnableApps() is called it will also include apps that were
- // enabled for groups
- self::$enabledAppsCache = [];
- }
\OC::$server->getEventLogger()->end('load_app_' . $app);
}
@@ -330,11 +323,6 @@ class OC_App {
}
/**
- * get all enabled apps
- */
- protected static $enabledAppsCache = [];
-
- /**
* Returns apps enabled for the current user.
*
* @param bool $forceRefresh whether to refresh the cache
@@ -393,7 +381,6 @@ class OC_App {
*/
public function enable(string $appId,
array $groups = []) {
- self::$enabledAppsCache = []; // flush
// Check if app is already downloaded
$installer = \OC::$server->query(Installer::class);
@@ -422,30 +409,6 @@ class OC_App {
}
/**
- * This function set an app as disabled in appconfig.
- *
- * @param string $app app
- * @throws Exception
- */
- public static function disable(string $app) {
- // flush
- self::$enabledAppsCache = [];
-
- // run uninstall steps
- $appData = OC_App::getAppInfo($app);
- if (!is_null($appData)) {
- OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']);
- }
-
- // emit disable hook - needed anymore ?
- \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
-
- // finally disable it
- $appManager = \OC::$server->getAppManager();
- $appManager->disableApp($app);
- }
-
- /**
* Get the path where to install apps
*
* @return string|false
diff --git a/lib/public/DB/QueryBuilder/IFunctionBuilder.php b/lib/public/DB/QueryBuilder/IFunctionBuilder.php
index 478fd879404..d867d9e5edb 100644
--- a/lib/public/DB/QueryBuilder/IFunctionBuilder.php
+++ b/lib/public/DB/QueryBuilder/IFunctionBuilder.php
@@ -71,4 +71,13 @@ interface IFunctionBuilder {
* @since 12.0.0
*/
public function sum($field);
+
+ /**
+ * Transforms a string field or value to lower case
+ *
+ * @param mixed $field
+ * @return IQueryFunction
+ * @since 14.0.0
+ */
+ public function lower($field);
}
diff --git a/lib/public/Mail/IAttachment.php b/lib/public/Mail/IAttachment.php
index 4b617d67f5e..71fa841b26c 100644
--- a/lib/public/Mail/IAttachment.php
+++ b/lib/public/Mail/IAttachment.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
@@ -33,23 +34,23 @@ interface IAttachment {
/**
* @param string $filename
- * @return $this
+ * @return IAttachment
* @since 13.0.0
*/
- public function setFilename($filename);
+ public function setFilename(string $filename): IAttachment;
/**
* @param string $contentType
- * @return $this
+ * @return IAttachment
* @since 13.0.0
*/
- public function setContentType($contentType);
+ public function setContentType(string $contentType): IAttachment;
/**
* @param string $body
- * @return $this
+ * @return IAttachment
* @since 13.0.0
*/
- public function setBody($body);
+ public function setBody(string $body): IAttachment;
}
diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php
index 6d37c21ada1..1c0ddbe54d4 100644
--- a/lib/public/Mail/IEMailTemplate.php
+++ b/lib/public/Mail/IEMailTemplate.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright 2017, Morris Jobke <hey@morrisjobke.de>
*
@@ -62,7 +63,7 @@ interface IEMailTemplate {
*
* @since 13.0.0
*/
- public function setSubject($subject);
+ public function setSubject(string $subject);
/**
* Adds a header to the email
@@ -80,7 +81,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function addHeading($title, $plainTitle = '');
+ public function addHeading(string $title, $plainTitle = '');
/**
* Adds a paragraph to the body of the email
@@ -91,7 +92,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function addBodyText($text, $plainText = '');
+ public function addBodyText(string $text, $plainText = '');
/**
* Adds a list item to the body of the email
@@ -99,13 +100,13 @@ interface IEMailTemplate {
* @param string $text; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
* @param string $metaInfo; Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
* @param string $icon Absolute path, must be 16*16 pixels
- * @param string $plainText Text that is used in the plain text email
+ * @param string|bool $plainText Text that is used in the plain text email
* if empty the $text is used, if false none will be used
- * @param string $plainMetaInfo Meta info that is used in the plain text email
+ * @param string|bool $plainMetaInfo Meta info that is used in the plain text email
* if empty the $metaInfo is used, if false none will be used
* @since 12.0.0
*/
- public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '');
+ public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '');
/**
* Adds a button group of two buttons to the body of the email
@@ -119,7 +120,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = '');
+ public function addBodyButtonGroup(string $textLeft, string $urlLeft, string $textRight, string $urlRight, string $plainTextLeft = '', string $plainTextRight = '');
/**
* Adds a button to the body of the email
@@ -131,7 +132,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function addBodyButton($text, $url, $plainText = '');
+ public function addBodyButton(string $text, string $url, $plainText = '');
/**
* Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
@@ -140,7 +141,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function addFooter($text = '');
+ public function addFooter(string $text = '');
/**
* Returns the rendered email subject as string
@@ -149,7 +150,7 @@ interface IEMailTemplate {
*
* @since 13.0.0
*/
- public function renderSubject();
+ public function renderSubject(): string;
/**
* Returns the rendered HTML email as string
@@ -158,7 +159,7 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function renderHtml();
+ public function renderHtml(): string;
/**
* Returns the rendered plain text email as string
@@ -167,5 +168,5 @@ interface IEMailTemplate {
*
* @since 12.0.0
*/
- public function renderText();
+ public function renderText(): string;
}
diff --git a/lib/public/Mail/IMailer.php b/lib/public/Mail/IMailer.php
index 10096548256..e8f5d6e7d03 100644
--- a/lib/public/Mail/IMailer.php
+++ b/lib/public/Mail/IMailer.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -51,7 +52,7 @@ interface IMailer {
* @return IMessage
* @since 8.1.0
*/
- public function createMessage();
+ public function createMessage(): IMessage;
/**
* @param string|null $data
@@ -60,7 +61,7 @@ interface IMailer {
* @return IAttachment
* @since 13.0.0
*/
- public function createAttachment($data = null, $filename = null, $contentType = null);
+ public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment;
/**
* @param string $path
@@ -68,7 +69,7 @@ interface IMailer {
* @return IAttachment
* @since 13.0.0
*/
- public function createAttachmentFromPath($path, $contentType = null);
+ public function createAttachmentFromPath(string $path, $contentType = null): IAttachment;
/**
* Creates a new email template object
@@ -78,7 +79,7 @@ interface IMailer {
* @return IEMailTemplate
* @since 12.0.0 Parameters added in 12.0.3
*/
- public function createEMailTemplate($emailId, array $data = []);
+ public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate;
/**
* Send the specified message. Also sets the from address to the value defined in config.php
@@ -91,7 +92,7 @@ interface IMailer {
* has been supplied.)
* @since 8.1.0
*/
- public function send(IMessage $message);
+ public function send(IMessage $message): array;
/**
* Checks if an e-mail address is valid
@@ -100,5 +101,5 @@ interface IMailer {
* @return bool True if the mail address is valid, false otherwise
* @since 8.1.0
*/
- public function validateMailAddress($email);
+ public function validateMailAddress(string $email): bool;
}
diff --git a/lib/public/Mail/IMessage.php b/lib/public/Mail/IMessage.php
index cec47adc19d..638fd9d103f 100644
--- a/lib/public/Mail/IMessage.php
+++ b/lib/public/Mail/IMessage.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
@@ -33,10 +34,10 @@ interface IMessage {
/**
* @param IAttachment $attachment
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function attach(IAttachment $attachment);
+ public function attach(IAttachment $attachment): IMessage;
/**
* Set the from address of this message.
@@ -44,51 +45,51 @@ interface IMessage {
* If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php
*
* @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name')
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function setFrom(array $addresses);
+ public function setFrom(array $addresses): IMessage;
/**
* Set the Reply-To address of this message
*
* @param array $addresses
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function setReplyTo(array $addresses);
+ public function setReplyTo(array $addresses): IMessage;
/**
* Set the to addresses of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function setTo(array $recipients);
+ public function setTo(array $recipients): IMessage;
/**
* Set the CC recipients of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function setCc(array $recipients);
+ public function setCc(array $recipients): IMessage;
/**
* Set the BCC recipients of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function setBcc(array $recipients);
+ public function setBcc(array $recipients): IMessage;
/**
* @param IEMailTemplate $emailTemplate
- * @return $this
+ * @return IMessage
* @since 13.0.0
*/
- public function useTemplate(IEMailTemplate $emailTemplate);
+ public function useTemplate(IEMailTemplate $emailTemplate): IMessage;
}