Преглед на файлове

Move error message to log entry

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
tags/v12.0.0beta1
Lukas Reschke преди 7 години
родител
ревизия
ab9e3525cc
No account linked to committer's email address
променени са 2 файла, в които са добавени 14 реда и са изтрити 1 реда
  1. 12
    1
      lib/private/Files/View.php
  2. 2
    0
      tests/lib/Files/ViewTest.php

+ 12
- 1
lib/private/Files/View.php Целия файл

@@ -96,8 +96,12 @@ class View {

private $updaterEnabled = true;

/** @var \OC\User\Manager */
private $userManager;

/** @var \OCP\ILogger */
private $logger;

/**
* @param string $root
* @throws \Exception If $root contains an invalid path
@@ -114,6 +118,7 @@ class View {
$this->lockingProvider = \OC::$server->getLockingProvider();
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
$this->userManager = \OC::$server->getUserManager();
$this->logger = \OC::$server->getLogger();
}

public function getAbsolutePath($path = '/') {
@@ -2068,7 +2073,13 @@ class View {
$parts = explode('/', trim($path, '/'), 3);
// "$user", "files", "path/to/dir"
if (!isset($parts[1]) || $parts[1] !== 'files') {
throw new \InvalidArgumentException('"' . $absolutePath . '" must be relative to "files"');
$this->logger->error(
'$absolutePath must be relative to "files", value is "%s"',
[
$absolutePath
]
);
throw new \InvalidArgumentException('$absolutePath must be relative to "files"');
}
if (isset($parts[2])) {
return $parts[2];

+ 2
- 0
tests/lib/Files/ViewTest.php Целия файл

@@ -1488,6 +1488,8 @@ class ViewTest extends \Test\TestCase {
/**
* @dataProvider pathRelativeToFilesProviderExceptionCases
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage $absolutePath must be relative to "files"
* @param string $path
*/
public function testGetPathRelativeToFilesWithInvalidArgument($path) {
$view = new View();

Loading…
Отказ
Запис