summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 15:37:29 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 15:37:29 +0100
commite2805f02aa51c602c581bd4f09b99dd791a42df4 (patch)
tree4ea194f47aa315874c2aac31c30dbdb14110539b /lib/private
parent2b4b3b1986e58305c08941f77a693a80cc3d5b85 (diff)
parent52b679a2d6f6b273f46334b15534ab312f974a1a (diff)
downloadnextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.tar.gz
nextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.zip
Merge branch 'master' into autocomplete-gui
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php3
-rw-r--r--lib/private/AppFramework/Http.php2
-rw-r--r--lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php10
-rw-r--r--lib/private/Collaboration/Collaborators/SearchResult.php8
-rw-r--r--lib/private/Command/QueueBus.php2
-rw-r--r--lib/private/DB/MDB2SchemaManager.php2
-rw-r--r--lib/private/DB/NoCheckMigrator.php39
-rw-r--r--lib/private/DB/OracleMigrator.php148
-rw-r--r--lib/private/Files/FileInfo.php2
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php10
-rw-r--r--lib/private/Files/ObjectStore/S3ObjectTrait.php13
-rw-r--r--lib/private/Files/Storage/Local.php3
-rw-r--r--lib/private/Files/Type/Detection.php4
-rw-r--r--lib/private/Log.php6
-rw-r--r--lib/private/Mail/Attachment.php78
-rw-r--r--lib/private/Mail/Mailer.php22
-rw-r--r--lib/private/Mail/Message.php12
-rw-r--r--lib/private/Repair.php2
-rw-r--r--lib/private/Repair/NC13/AddLogRotateJob.php47
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/private/Setup.php5
-rw-r--r--lib/private/Share20/Manager.php2
-rw-r--r--lib/private/SystemConfig.php8
-rw-r--r--lib/private/Tags.php2
-rw-r--r--lib/private/legacy/app.php18
-rw-r--r--lib/private/legacy/image.php2
-rw-r--r--lib/private/legacy/json.php2
-rw-r--r--lib/private/legacy/template.php2
-rw-r--r--lib/private/legacy/template/functions.php2
29 files changed, 350 insertions, 110 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index 2290f0d0045..0ea7eed4ae2 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -230,7 +230,8 @@ class DIContainer extends SimpleContainer implements IAppContainer {
$app->isAdminUser(),
$server->getContentSecurityPolicyManager(),
$server->getCsrfTokenManager(),
- $server->getContentSecurityPolicyNonceManager()
+ $server->getContentSecurityPolicyNonceManager(),
+ $server->getAppManager()
);
});
diff --git a/lib/private/AppFramework/Http.php b/lib/private/AppFramework/Http.php
index 526509a4583..be1e178a05f 100644
--- a/lib/private/AppFramework/Http.php
+++ b/lib/private/AppFramework/Http.php
@@ -111,7 +111,7 @@ class Http extends BaseHttp {
/**
* Gets the correct header
- * @param Http::CONSTANT $status the constant from the Http class
+ * @param int Http::CONSTANT $status the constant from the Http class
* @param \DateTime $lastModified formatted last modified date
* @param string $ETag the etag
* @return string
diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
index 4e41c946432..52004987909 100644
--- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
@@ -39,6 +39,7 @@ use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Security\CSP\ContentSecurityPolicyManager;
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OC\Security\CSRF\CsrfTokenManager;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
@@ -87,6 +88,8 @@ class SecurityMiddleware extends Middleware {
private $csrfTokenManager;
/** @var ContentSecurityPolicyNonceManager */
private $cspNonceManager;
+ /** @var IAppManager */
+ private $appManager;
/**
* @param IRequest $request
@@ -101,6 +104,7 @@ class SecurityMiddleware extends Middleware {
* @param ContentSecurityPolicyManager $contentSecurityPolicyManager
* @param CSRFTokenManager $csrfTokenManager
* @param ContentSecurityPolicyNonceManager $cspNonceManager
+ * @param IAppManager $appManager
*/
public function __construct(IRequest $request,
ControllerMethodReflector $reflector,
@@ -113,7 +117,8 @@ class SecurityMiddleware extends Middleware {
$isAdminUser,
ContentSecurityPolicyManager $contentSecurityPolicyManager,
CsrfTokenManager $csrfTokenManager,
- ContentSecurityPolicyNonceManager $cspNonceManager) {
+ ContentSecurityPolicyNonceManager $cspNonceManager,
+ IAppManager $appManager) {
$this->navigationManager = $navigationManager;
$this->request = $request;
$this->reflector = $reflector;
@@ -126,6 +131,7 @@ class SecurityMiddleware extends Middleware {
$this->contentSecurityPolicyManager = $contentSecurityPolicyManager;
$this->csrfTokenManager = $csrfTokenManager;
$this->cspNonceManager = $cspNonceManager;
+ $this->appManager = $appManager;
}
/**
@@ -190,7 +196,7 @@ class SecurityMiddleware extends Middleware {
* The getAppPath() check is here since components such as settings also use the AppFramework and
* therefore won't pass this check.
*/
- if(\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) {
+ if(\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) {
throw new AppNotEnabledException();
}
diff --git a/lib/private/Collaboration/Collaborators/SearchResult.php b/lib/private/Collaboration/Collaborators/SearchResult.php
index 7b32b388203..184c1f69a1b 100644
--- a/lib/private/Collaboration/Collaborators/SearchResult.php
+++ b/lib/private/Collaboration/Collaborators/SearchResult.php
@@ -52,7 +52,7 @@ class SearchResult implements ISearchResult {
$this->exactIdMatches[$type->getLabel()] = 1;
}
- public function hasExactIdMatch(SearchResultType$type) {
+ public function hasExactIdMatch(SearchResultType $type) {
return isset($this->exactIdMatches[$type->getLabel()]);
}
@@ -64,8 +64,10 @@ class SearchResult implements ISearchResult {
$resultArrays = [$this->result['exact'][$type], $this->result[$type]];
foreach($resultArrays as $resultArray) {
- if ($resultArray['value']['shareWith'] === $collaboratorId) {
- return true;
+ foreach ($resultArray as $result) {
+ if ($result['value']['shareWith'] === $collaboratorId) {
+ return true;
+ }
}
}
diff --git a/lib/private/Command/QueueBus.php b/lib/private/Command/QueueBus.php
index 7f2fc88a703..30cdd7740a9 100644
--- a/lib/private/Command/QueueBus.php
+++ b/lib/private/Command/QueueBus.php
@@ -27,7 +27,7 @@ use OCP\Command\ICommand;
class QueueBus implements IBus {
/**
- * @var (ICommand|callable)[]
+ * @var ICommand[]|callable[]
*/
private $queue = [];
diff --git a/lib/private/DB/MDB2SchemaManager.php b/lib/private/DB/MDB2SchemaManager.php
index 89b0d153212..ad3f93a2643 100644
--- a/lib/private/DB/MDB2SchemaManager.php
+++ b/lib/private/DB/MDB2SchemaManager.php
@@ -89,7 +89,7 @@ class MDB2SchemaManager {
} else if ($platform instanceof PostgreSqlPlatform) {
return new PostgreSqlMigrator($this->conn, $random, $config, $dispatcher);
} else {
- return new NoCheckMigrator($this->conn, $random, $config, $dispatcher);
+ return new Migrator($this->conn, $random, $config, $dispatcher);
}
}
diff --git a/lib/private/DB/NoCheckMigrator.php b/lib/private/DB/NoCheckMigrator.php
deleted file mode 100644
index 723653511b9..00000000000
--- a/lib/private/DB/NoCheckMigrator.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OC\DB;
-
-use Doctrine\DBAL\Schema\Schema;
-
-/**
- * migrator for database platforms that don't support the upgrade check
- *
- * @package OC\DB
- */
-class NoCheckMigrator extends Migrator {
- /**
- * @param \Doctrine\DBAL\Schema\Schema $targetSchema
- * @throws \OC\DB\MigrationException
- */
- public function checkMigrate(Schema $targetSchema) {}
-}
diff --git a/lib/private/DB/OracleMigrator.php b/lib/private/DB/OracleMigrator.php
index 2735529b5e2..f5e06b50d99 100644
--- a/lib/private/DB/OracleMigrator.php
+++ b/lib/private/DB/OracleMigrator.php
@@ -30,8 +30,79 @@ use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+
+class OracleMigrator extends Migrator {
+
+ /**
+ * Quote a column's name but changing the name requires recreating
+ * the column instance and copying over all properties.
+ *
+ * @param Column $column old column
+ * @return Column new column instance with new name
+ */
+ protected function quoteColumn(Column $column) {
+ $newColumn = new Column(
+ $this->connection->quoteIdentifier($column->getName()),
+ $column->getType()
+ );
+ $newColumn->setAutoincrement($column->getAutoincrement());
+ $newColumn->setColumnDefinition($column->getColumnDefinition());
+ $newColumn->setComment($column->getComment());
+ $newColumn->setDefault($column->getDefault());
+ $newColumn->setFixed($column->getFixed());
+ $newColumn->setLength($column->getLength());
+ $newColumn->setNotnull($column->getNotnull());
+ $newColumn->setPrecision($column->getPrecision());
+ $newColumn->setScale($column->getScale());
+ $newColumn->setUnsigned($column->getUnsigned());
+ $newColumn->setPlatformOptions($column->getPlatformOptions());
+ $newColumn->setCustomSchemaOptions($column->getPlatformOptions());
+ return $newColumn;
+ }
+
+ /**
+ * Quote an index's name but changing the name requires recreating
+ * the index instance and copying over all properties.
+ *
+ * @param Index $index old index
+ * @return Index new index instance with new name
+ */
+ protected function quoteIndex($index) {
+ return new Index(
+ //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()),
+ $index->getName(),
+ array_map(function($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $index->getColumns()),
+ $index->isUnique(),
+ $index->isPrimary(),
+ $index->getFlags(),
+ $index->getOptions()
+ );
+ }
+
+ /**
+ * Quote an ForeignKeyConstraint's name but changing the name requires recreating
+ * the ForeignKeyConstraint instance and copying over all properties.
+ *
+ * @param ForeignKeyConstraint $fkc old fkc
+ * @return ForeignKeyConstraint new fkc instance with new name
+ */
+ protected function quoteForeignKeyConstraint($fkc) {
+ return new ForeignKeyConstraint(
+ array_map(function($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $fkc->getLocalColumns()),
+ $this->connection->quoteIdentifier($fkc->getForeignTableName()),
+ array_map(function($columnName) {
+ return $this->connection->quoteIdentifier($columnName);
+ }, $fkc->getForeignColumns()),
+ $fkc->getName(),
+ $fkc->getOptions()
+ );
+ }
-class OracleMigrator extends NoCheckMigrator {
/**
* @param Schema $targetSchema
* @param \Doctrine\DBAL\Connection $connection
@@ -46,37 +117,14 @@ class OracleMigrator extends NoCheckMigrator {
return new Table(
$this->connection->quoteIdentifier($table->getName()),
array_map(function(Column $column) {
- $newColumn = new Column(
- $this->connection->quoteIdentifier($column->getName()),
- $column->getType()
- );
- $newColumn->setAutoincrement($column->getAutoincrement());
- $newColumn->setColumnDefinition($column->getColumnDefinition());
- $newColumn->setComment($column->getComment());
- $newColumn->setDefault($column->getDefault());
- $newColumn->setFixed($column->getFixed());
- $newColumn->setLength($column->getLength());
- $newColumn->setNotnull($column->getNotnull());
- $newColumn->setPrecision($column->getPrecision());
- $newColumn->setScale($column->getScale());
- $newColumn->setUnsigned($column->getUnsigned());
- $newColumn->setPlatformOptions($column->getPlatformOptions());
- $newColumn->setCustomSchemaOptions($column->getPlatformOptions());
- return $newColumn;
+ return $this->quoteColumn($column);
}, $table->getColumns()),
array_map(function(Index $index) {
- return new Index(
- $this->connection->quoteIdentifier($index->getName()),
- array_map(function($columnName) {
- return $this->connection->quoteIdentifier($columnName);
- }, $index->getColumns()),
- $index->isUnique(),
- $index->isPrimary(),
- $index->getFlags(),
- $index->getOptions()
- );
+ return $this->quoteIndex($index);
}, $table->getIndexes()),
- $table->getForeignKeys(),
+ array_map(function(ForeignKeyConstraint $fck) {
+ return $this->quoteForeignKeyConstraint($fck);
+ }, $table->getForeignKeys()),
0,
$table->getOptions()
);
@@ -95,14 +143,56 @@ class OracleMigrator extends NoCheckMigrator {
foreach ($schemaDiff->changedTables as $tableDiff) {
$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
+
+ $tableDiff->addedColumns = array_map(function(Column $column) {
+ return $this->quoteColumn($column);
+ }, $tableDiff->addedColumns);
+
foreach ($tableDiff->changedColumns as $column) {
$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
// auto increment is not relevant for oracle and can anyhow not be applied on change
$column->changedProperties = array_diff($column->changedProperties, ['autoincrement', 'unsigned']);
}
+ // remove columns that no longer have changed (because autoincrement and unsigned are not supported)
$tableDiff->changedColumns = array_filter($tableDiff->changedColumns, function (ColumnDiff $column) {
return count($column->changedProperties) > 0;
});
+
+ $tableDiff->removedColumns = array_map(function(Column $column) {
+ return $this->quoteColumn($column);
+ }, $tableDiff->removedColumns);
+
+ $tableDiff->renamedColumns = array_map(function(Column $column) {
+ return $this->quoteColumn($column);
+ }, $tableDiff->renamedColumns);
+
+ $tableDiff->addedIndexes = array_map(function(Index $index) {
+ return $this->quoteIndex($index);
+ }, $tableDiff->addedIndexes);
+
+ $tableDiff->changedIndexes = array_map(function(Index $index) {
+ return $this->quoteIndex($index);
+ }, $tableDiff->changedIndexes);
+
+ $tableDiff->removedIndexes = array_map(function(Index $index) {
+ return $this->quoteIndex($index);
+ }, $tableDiff->removedIndexes);
+
+ $tableDiff->renamedIndexes = array_map(function(Index $index) {
+ return $this->quoteIndex($index);
+ }, $tableDiff->renamedIndexes);
+
+ $tableDiff->addedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) {
+ return $this->quoteForeignKeyConstraint($fkc);
+ }, $tableDiff->addedForeignKeys);
+
+ $tableDiff->changedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) {
+ return $this->quoteForeignKeyConstraint($fkc);
+ }, $tableDiff->changedForeignKeys);
+
+ $tableDiff->removedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) {
+ return $this->quoteForeignKeyConstraint($fkc);
+ }, $tableDiff->removedForeignKeys);
}
return $schemaDiff;
diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php
index f5a44ba02ea..7ac0c6e49d5 100644
--- a/lib/private/Files/FileInfo.php
+++ b/lib/private/Files/FileInfo.php
@@ -232,7 +232,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
}
/**
- * @return \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
+ * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
*/
public function getType() {
if (!isset($this->data['type'])) {
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index ded69e8079b..15df808684b 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -390,7 +390,15 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$stat['size'] = filesize($tmpFile);
$stat['mtime'] = $mTime;
$stat['storage_mtime'] = $mTime;
- $stat['mimetype'] = \OC::$server->getMimeTypeDetector()->detect($tmpFile);
+
+ // run path based detection first, to use file extension because $tmpFile is only a random string
+ $mimetypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimetype = $mimetypeDetector->detectPath($path);
+ if ($mimetype === 'application/octet-stream') {
+ $mimetype = $mimetypeDetector->detect($tmpFile);
+ }
+
+ $stat['mimetype'] = $mimetype;
$stat['etag'] = $this->getETag($path);
$fileId = $this->getCache()->put($path, $stat);
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php
index 6fb12265cb7..4bfa08a3e59 100644
--- a/lib/private/Files/ObjectStore/S3ObjectTrait.php
+++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php
@@ -49,12 +49,15 @@ trait S3ObjectTrait {
'Bucket' => $this->bucket,
'Key' => $urn
]);
- $command['@http']['stream'] = true;
- $result = $client->execute($command);
- /** @var StreamInterface $body */
- $body = $result['Body'];
+ $request = \Aws\serialize($command);
+ $opts = [
+ 'http' => [
+ 'header' => $request->getHeaders()
+ ]
+ ];
- return $body->detach();
+ $context = stream_context_create($opts);
+ return fopen($request->getUri(), 'r', false, $context);
}
/**
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 0577093712e..c9cb6f246d7 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -408,10 +408,11 @@ class Local extends \OC\Files\Storage\Common {
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
+ * @param bool $preserveMtime
* @return bool
*/
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
- if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) {
+ if ($sourceStorage->instanceOfStorage(Local::class)) {
if ($sourceStorage->instanceOfStorage(Jail::class)) {
/**
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index cd4ddc2f067..928c68251cf 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -173,6 +173,10 @@ class Detection implements IMimeTypeDetector {
// note: leading dot doesn't qualify as extension
if (strpos($fileName, '.') > 0) {
+
+ // remove versioning extension: name.v1508946057 and transfer extension: name.ocTransferId2057600214.part
+ $fileName = preg_replace('!((\.v\d+)|((.ocTransferId\d+)?.part))$!', '', $fileName);
+
//try to guess the type by the file extension
$extension = strtolower(strrchr($fileName, '.'));
$extension = substr($extension, 1); //remove leading .
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 39577d2387a..25ff26daffa 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -69,6 +69,8 @@ class Log implements ILogger {
'loginWithPassword',
'updatePrivateKeyPassword',
'validateUserPass',
+ 'loginWithToken',
+ '\{closure\}',
// TokenProvider
'getToken',
@@ -96,6 +98,10 @@ class Log implements ILogger {
'bind',
'areCredentialsValid',
'invokeLDAPMethod',
+
+ // Encryption
+ 'storeKeyPair',
+ 'setupUser',
];
/**
diff --git a/lib/private/Mail/Attachment.php b/lib/private/Mail/Attachment.php
new file mode 100644
index 00000000000..7b85ad1dbb9
--- /dev/null
+++ b/lib/private/Mail/Attachment.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 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 OC\Mail;
+
+use OCP\Mail\IAttachment;
+
+/**
+ * Class Attachment
+ *
+ * @package OC\Mail
+ * @since 13.0.0
+ */
+class Attachment implements IAttachment {
+
+ /** @var \Swift_Mime_Attachment */
+ protected $swiftAttachment;
+
+ public function __construct(\Swift_Mime_Attachment $attachment) {
+ $this->swiftAttachment = $attachment;
+ }
+
+ /**
+ * @param string $filename
+ * @return $this
+ * @since 13.0.0
+ */
+ public function setFilename($filename) {
+ $this->swiftAttachment->setFilename($filename);
+ return $this;
+ }
+
+ /**
+ * @param string $contentType
+ * @return $this
+ * @since 13.0.0
+ */
+ public function setContentType($contentType) {
+ $this->swiftAttachment->setContentType($contentType);
+ return $this;
+ }
+
+ /**
+ * @param string $body
+ * @return $this
+ * @since 13.0.0
+ */
+ public function setBody($body) {
+ $this->swiftAttachment->setBody($body);
+ return $this;
+ }
+
+ /**
+ * @return \Swift_Mime_Attachment
+ */
+ public function getSwiftAttachment() {
+ return $this->swiftAttachment;
+ }
+
+}
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 43fdb07b810..ad59d640b3e 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -26,6 +26,7 @@ use OCP\Defaults;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\ILogger;
@@ -92,6 +93,27 @@ class Mailer implements IMailer {
}
/**
+ * @param string|null $data
+ * @param string|null $filename
+ * @param string|null $contentType
+ * @return IAttachment
+ * @since 13.0.0
+ */
+ public function createAttachment($data = null, $filename = null, $contentType = null) {
+ return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
+ }
+
+ /**
+ * @param string $path
+ * @param string|null $contentType
+ * @return IAttachment
+ * @since 13.0.0
+ */
+ public function createAttachmentFromPath($path, $contentType = null) {
+ return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
+ }
+
+ /**
* Creates a new email template object
*
* @param string $emailId
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index b4d1e4dbe7a..dcd4a66e996 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -23,6 +23,7 @@
namespace OC\Mail;
+use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMessage;
use Swift_Message;
@@ -44,6 +45,17 @@ class Message implements IMessage {
}
/**
+ * @param IAttachment $attachment
+ * @return $this
+ * @since 13.0.0
+ */
+ public function attach(IAttachment $attachment) {
+ /** @var Attachment $attachment */
+ $this->swiftMessage->attach($attachment->getSwiftAttachment());
+ return $this;
+ }
+
+ /**
* SwiftMailer does currently not work with IDN domains, this function therefore converts the domains
* FIXME: Remove this once SwiftMailer supports IDN
*
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index 80cd3c7fd45..ac824095d53 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -41,6 +41,7 @@ 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;
use OC\Repair\Owncloud\SaveAccountsTableData;
@@ -150,6 +151,7 @@ class Repair implements IOutput{
),
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/NC13/AddLogRotateJob.php b/lib/private/Repair/NC13/AddLogRotateJob.php
new file mode 100644
index 00000000000..c65ea47f02b
--- /dev/null
+++ b/lib/private/Repair/NC13/AddLogRotateJob.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @copyright 2017, 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\NC13;
+
+use OC\Log\Rotate;
+use OCP\BackgroundJob\IJobList;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+
+class AddLogRotateJob implements IRepairStep {
+
+ /** @var IJobList */
+ private $jobList;
+
+ public function __construct(IJobList $jobList) {
+ $this->jobList = $jobList;
+ }
+
+ public function getName() {
+ return 'Add log rotate job';
+ }
+
+ public function run(IOutput $output) {
+ $this->jobList->add(Rotate::class);
+ }
+
+}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 1621a194693..c461d3842cd 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -533,8 +533,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
$cacheFactory = $c->getMemCacheFactory();
$logger = $c->getLogger();
- if ($cacheFactory->isAvailable()) {
- $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
+ if ($cacheFactory->isAvailableLowLatency()) {
+ $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
} else {
$router = new \OC\Route\Router($logger);
}
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 5228d52b05f..4e1e4ece62d 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -44,6 +44,7 @@ use Exception;
use OC\App\AppStore\Bundles\BundleFetcher;
use OC\Authentication\Token\DefaultTokenCleanupJob;
use OC\Authentication\Token\DefaultTokenProvider;
+use OC\Log\Rotate;
use OCP\Defaults;
use OCP\IL10N;
use OCP\ILogger;
@@ -426,7 +427,9 @@ class Setup {
}
public static function installBackgroundJobs() {
- \OC::$server->getJobList()->add(DefaultTokenCleanupJob::class);
+ $jobList = \OC::$server->getJobList();
+ $jobList->add(DefaultTokenCleanupJob::class);
+ $jobList->add(Rotate::class);
}
/**
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 9245b9d4f51..379d87633ab 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1395,7 +1395,7 @@ class Manager implements IManager {
/**
* Create a new share
- * @return \OCP\Share\IShare;
+ * @return \OCP\Share\IShare
*/
public function newShare() {
return new \OC\Share20\Share($this->rootFolder, $this->userManager);
diff --git a/lib/private/SystemConfig.php b/lib/private/SystemConfig.php
index 3610486140d..91afbeb8967 100644
--- a/lib/private/SystemConfig.php
+++ b/lib/private/SystemConfig.php
@@ -37,22 +37,30 @@ class SystemConfig {
/** @var array */
protected $sensitiveValues = [
+ 'instanceid' => true,
+ 'trusted_domains' => true,
+ 'datadirectory' => true,
+ 'overwrite.cli.url' => true,
'dbname' => true,
+ 'dbhost' => true,
'dbpassword' => true,
'dbuser' => true,
'mail_from_address' => true,
'mail_domain' => true,
+ 'mail_smtphost' => true,
'mail_smtpname' => true,
'mail_smtppassword' => true,
'passwordsalt' => true,
'secret' => true,
'updater.secret' => true,
+ 'trusted_proxies' => true,
'proxyuserpwd' => true,
'log.condition' => [
'shared_secret' => true,
],
'license-key' => true,
'redis' => [
+ 'host' => true,
'password' => true,
],
'objectstore' => [
diff --git a/lib/private/Tags.php b/lib/private/Tags.php
index b63435ff838..1947f0c07e6 100644
--- a/lib/private/Tags.php
+++ b/lib/private/Tags.php
@@ -140,7 +140,7 @@ class Tags implements \OCP\ITags {
/**
* Check if any tags are saved for this type and user.
*
- * @return boolean.
+ * @return boolean
*/
public function isEmpty() {
return count($this->tags) === 0;
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index efa2afd7356..49fac2f4d96 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -350,6 +350,7 @@ class OC_App {
*
* @param string $app app
* @return bool
+ * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
*
* This function checks whether or not an app is enabled.
*/
@@ -869,21 +870,6 @@ class OC_App {
return $appList;
}
- /**
- * Returns the internal app ID or false
- * @param string $ocsID
- * @return string|false
- */
- public static function getInternalAppIdByOcs($ocsID) {
- if(is_numeric($ocsID)) {
- $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
- if(array_search($ocsID, $idArray)) {
- return array_search($ocsID, $idArray);
- }
- }
- return false;
- }
-
public static function shouldUpgrade($app) {
$versions = self::getAppVersions();
$currentVersion = OC_App::getAppVersion($app);
@@ -1161,7 +1147,7 @@ class OC_App {
* @return \OC\Files\View|false
*/
public static function getStorage($appId) {
- if (OC_App::isEnabled($appId)) { //sanity check
+ if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
if (\OC::$server->getUserSession()->isLoggedIn()) {
$view = new \OC\Files\View('/' . OC_User::getUser());
if (!$view->file_exists($appId)) {
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index 120b19d1cff..cd5ca7bb5ce 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -431,7 +431,7 @@ class OC_Image implements \OCP\IImage {
* (I'm open for suggestions on better method name ;)
* Fixes orientation based on EXIF data.
*
- * @return bool.
+ * @return bool
*/
public function fixOrientation() {
$o = $this->getOrientation();
diff --git a/lib/private/legacy/json.php b/lib/private/legacy/json.php
index 180dd7c448d..221a0047eb4 100644
--- a/lib/private/legacy/json.php
+++ b/lib/private/legacy/json.php
@@ -55,7 +55,7 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function checkAppEnabled($app) {
- if( !OC_App::isEnabled($app)) {
+ if( !\OC::$server->getAppManager()->isEnabledForUser($app)) {
$l = \OC::$server->getL10N('lib');
self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
exit();
diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php
index 8c6185cd556..55df2dece11 100644
--- a/lib/private/legacy/template.php
+++ b/lib/private/legacy/template.php
@@ -297,7 +297,7 @@ class OC_Template extends \OC\Template\Base {
* @suppress PhanAccessMethodInternal
*/
public static function printErrorPage( $error_msg, $hint = '' ) {
- if (\OC_App::isEnabled('theming') && !\OC_App::isAppLoaded('theming')) {
+ if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
\OC_App::loadApp('theming');
}
diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php
index bca16b48c1a..1ef3541e880 100644
--- a/lib/private/legacy/template/functions.php
+++ b/lib/private/legacy/template/functions.php
@@ -278,7 +278,7 @@ function human_file_size( $bytes ) {
/**
* Strips the timestamp of its time value
* @param int $timestamp UNIX timestamp to strip
- * @return $timestamp without time value
+ * @return int timestamp without time value
*/
function strip_time($timestamp){
$date = new \DateTime("@{$timestamp}");