aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php4
-rw-r--r--lib/private/Files/ObjectStore/S3ObjectTrait.php8
-rw-r--r--lib/private/Log.php16
-rw-r--r--lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php13
-rw-r--r--lib/private/Server.php6
-rw-r--r--lib/private/Support/CrashReport/Registry.php57
-rw-r--r--lib/private/Template/CSSResourceLocator.php5
-rw-r--r--lib/private/Template/JSResourceLocator.php7
-rw-r--r--lib/private/User/Database.php2
9 files changed, 109 insertions, 9 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 15df808684b..79ce7ee3247 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -364,7 +364,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$fileId = $this->getCache()->put($path, $stat);
try {
//read an empty file from memory
- $this->objectStore->writeObject($this->getURN($fileId), fopen('php://memory', 'r'));
+ $this->file_put_contents($path, ' ');
} catch (\Exception $ex) {
$this->getCache()->remove($path);
$this->logger->logException($ex, [
@@ -392,7 +392,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$stat['storage_mtime'] = $mTime;
// run path based detection first, to use file extension because $tmpFile is only a random string
- $mimetypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimetypeDetector = \OC::$server->getMimeTypeDetector();
$mimetype = $mimetypeDetector->detectPath($path);
if ($mimetype === 'application/octet-stream') {
$mimetype = $mimetypeDetector->detect($tmpFile);
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php
index b418219c29b..9c5cf9ccc6c 100644
--- a/lib/private/Files/ObjectStore/S3ObjectTrait.php
+++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php
@@ -52,9 +52,15 @@ trait S3ObjectTrait {
'Key' => $urn
]);
$request = \Aws\serialize($command);
+ $headers = [];
+ foreach ($request->getHeaders() as $key => $values) {
+ foreach ($values as $value) {
+ $headers[] = "$key: $value";
+ }
+ }
$opts = [
'http' => [
- 'header' => $request->getHeaders()
+ 'header' => $headers
]
];
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 0d1f7a01265..a41c728df0d 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -36,7 +36,8 @@ namespace OC;
use InterfaSys\LogNormalizer\Normalizer;
-use \OCP\ILogger;
+use OCP\ILogger;
+use OCP\Support\CrashReport\IRegistry;
use OCP\Util;
/**
@@ -63,6 +64,9 @@ class Log implements ILogger {
/** @var Normalizer */
private $normalizer;
+ /** @var IRegistry */
+ private $crashReporters;
+
protected $methodsWithSensitiveParameters = [
// Session/User
'completeLogin',
@@ -110,9 +114,10 @@ class Log implements ILogger {
/**
* @param string $logger The logger that should be used
* @param SystemConfig $config the system config object
- * @param null $normalizer
+ * @param Normalizer|null $normalizer
+ * @param IRegistry|null $registry
*/
- public function __construct($logger = null, SystemConfig $config = null, $normalizer = null) {
+ public function __construct($logger = null, SystemConfig $config = null, $normalizer = null, IRegistry $registry = null) {
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
if($config === null) {
$config = \OC::$server->getSystemConfig();
@@ -133,7 +138,7 @@ class Log implements ILogger {
} else {
$this->normalizer = $normalizer;
}
-
+ $this->crashReporters = $registry;
}
/**
@@ -346,6 +351,9 @@ class Log implements ILogger {
$msg = isset($context['message']) ? $context['message'] : 'Exception';
$msg .= ': ' . json_encode($data);
$this->log($level, $msg, $context);
+ if (!is_null($this->crashReporters)) {
+ $this->crashReporters->delegateReport($exception, $context);
+ }
}
/**
diff --git a/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php b/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
index 9efe01508a6..e713f4dc63a 100644
--- a/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
+++ b/lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
@@ -30,6 +30,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\ILogger;
+use OCP\IUserManager;
class CleanPreviewsBackgroundJob extends QueuedJob {
/** @var IRootFolder */
@@ -44,6 +45,9 @@ class CleanPreviewsBackgroundJob extends QueuedJob {
/** @var ITimeFactory */
private $timeFactory;
+ /** @var IUserManager */
+ private $userManager;
+
/**
* CleanPreviewsBackgroundJob constructor.
*
@@ -51,19 +55,26 @@ class CleanPreviewsBackgroundJob extends QueuedJob {
* @param ILogger $logger
* @param IJobList $jobList
* @param ITimeFactory $timeFactory
+ * @param IUserManager $userManager
*/
public function __construct(IRootFolder $rootFolder,
ILogger $logger,
IJobList $jobList,
- ITimeFactory $timeFactory) {
+ ITimeFactory $timeFactory,
+ IUserManager $userManager) {
$this->rootFolder = $rootFolder;
$this->logger = $logger;
$this->jobList = $jobList;
$this->timeFactory = $timeFactory;
+ $this->userManager = $userManager;
}
public function run($arguments) {
$uid = $arguments['uid'];
+ if (!$this->userManager->userExists($uid)) {
+ $this->logger->info('User no longer exists, skip user ' . $uid);
+ return;
+ }
$this->logger->info('Started preview cleanup for ' . $uid);
$empty = $this->cleanupPreviews($uid);
diff --git a/lib/private/Server.php b/lib/private/Server.php
index af18b1a3a11..1e3ac3de271 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -516,12 +516,16 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
+ $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
+
$this->registerService(\OCP\ILogger::class, function (Server $c) {
$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
$logger = Log::getLogClass($logType);
call_user_func(array($logger, 'init'));
+ $config = $this->getSystemConfig();
+ $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
- return new Log($logger);
+ return new Log($logger, $config, null, $registry);
});
$this->registerAlias('Logger', \OCP\ILogger::class);
diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php
new file mode 100644
index 00000000000..670cea3da0e
--- /dev/null
+++ b/lib/private/Support/CrashReport/Registry.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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\Support\CrashReport;
+
+use Exception;
+use OCP\Support\CrashReport\IRegistry;
+use OCP\Support\CrashReport\IReporter;
+use Throwable;
+
+class Registry implements IRegistry {
+
+ /** @var array<IReporter> */
+ private $reporters = [];
+
+ /**
+ * Register a reporter instance
+ *
+ * @param IReporter $reporter
+ */
+ public function register(IReporter $reporter) {
+ $this->reporters[] = $reporter;
+ }
+
+ /**
+ * Delegate crash reporting to all registered reporters
+ *
+ * @param Exception|Throwable $exception
+ * @param array $context
+ */
+ public function delegateReport($exception, array $context = []) {
+ /** @var IReporter $reporter */
+ foreach ($this->reporters as $reporter) {
+ $reporter->report($exception, $context);
+ }
+ }
+
+}
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php
index 087ddec38ef..3c30a9d3356 100644
--- a/lib/private/Template/CSSResourceLocator.php
+++ b/lib/private/Template/CSSResourceLocator.php
@@ -76,6 +76,11 @@ class CSSResourceLocator extends ResourceLocator {
return;
}
+ // Account for the possibility of having symlinks in app path. Doing
+ // this here instead of above as an empty argument to realpath gets
+ // turned into cwd.
+ $app_path = realpath($app_path);
+
if(!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
$this->append($app_path, $style.'.css', $app_url);
}
diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php
index 9a2e0848214..d38488e4618 100644
--- a/lib/private/Template/JSResourceLocator.php
+++ b/lib/private/Template/JSResourceLocator.php
@@ -76,6 +76,13 @@ class JSResourceLocator extends ResourceLocator {
$app_path = \OC_App::getAppPath($app);
$app_url = \OC_App::getAppWebPath($app);
+ if ($app_path !== false) {
+ // Account for the possibility of having symlinks in app path. Only
+ // do this if $app_path is set, because an empty argument to realpath
+ // gets turned into cwd.
+ $app_path = realpath($app_path);
+ }
+
// missing translations files fill be ignored
if (strpos($script, 'l10n/') === 0) {
$this->appendIfExist($app_path, $script . '.js', $app_url);
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index a835ca3384e..471ff1f45ae 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -290,6 +290,8 @@ class Database extends Backend implements IUserBackend {
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);