From cf9b04ffdb384296fdecbaa1feb27bc158d4b72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 14 Aug 2017 16:48:29 +0200 Subject: [PATCH 1/2] Don't use runInSeparateProcess --- apps/dav/lib/Connector/Sabre/File.php | 8 ++++++-- apps/dav/tests/unit/Connector/Sabre/FileTest.php | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index c2407846207a..5d2071a3bc07 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -232,7 +232,7 @@ public function put($data) { if (isset($this->request->server['HTTP_X_OC_MTIME'])) { $mtime = $this->sanitizeMtime($this->request->server ['HTTP_X_OC_MTIME']); if ($this->fileView->touch($this->path, $mtime)) { - header('X-OC-MTime: accepted'); + $this->header('X-OC-MTime: accepted'); } } @@ -486,7 +486,7 @@ private function createFileChunked($data) { $this->request->server ['HTTP_X_OC_MTIME'] ); if ($targetStorage->touch($targetInternalPath, $mtime)) { - header('X-OC-MTime: accepted'); + $this->header('X-OC-MTime: accepted'); } } @@ -639,4 +639,8 @@ public function getChecksum($algo = null) { return ''; } + + protected function header($string) { + \header($string); + } } diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 7e78ffd49905..feca28850fe1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -325,7 +325,11 @@ private function doPut($path, $viewRoot = null, \OC\AppFramework\Http\Request $r null ); - $file = new File($view, $info, null, $request); + /** @var File | \PHPUnit_Framework_MockObject_MockObject $file */ + $file = $this->getMockBuilder(File::class) + ->setConstructorArgs([$view, $info, null, $request]) + ->setMethods(['header']) + ->getMock(); // beforeMethod locks $view->lockFile($path, ILockingProvider::LOCK_SHARED); @@ -351,7 +355,7 @@ public function testPutSingleFile() { * @return boolean true if negative mtime is supported */ private function supportsNegativeMtime() { - return (getenv("PRIMARY_STORAGE_CONFIG") !== "swift"); + return !(getenv("RUN_OBJECTSTORE_TESTS") !== false); } public function legalMtimeProvider() { @@ -409,8 +413,6 @@ public function legalMtimeProvider() { /** * Test putting a file with string Mtime - * @runInSeparateProcess - * @preserveGlobalState disabled * @dataProvider legalMtimeProvider */ public function testPutSingleFileLegalMtime($requestMtime, $resultMtime) { @@ -426,8 +428,6 @@ public function testPutSingleFileLegalMtime($requestMtime, $resultMtime) { /** * Test putting a file with string Mtime using chunking - * @runInSeparateProcess - * @preserveGlobalState disabled * @dataProvider legalMtimeProvider */ public function testChunkedPutLegalMtime($requestMtime, $resultMtime) { From de2db6a80b34522597f6f040893fd35c2041109d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 14 Aug 2017 17:44:13 +0200 Subject: [PATCH 2/2] Revert server side part of #12639 --- apps/dav/tests/unit/Connector/Sabre/FileTest.php | 13 ++----------- lib/private/Files/Storage/Common.php | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index feca28850fe1..b665cb3273d0 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -349,15 +349,6 @@ public function testPutSingleFile() { $this->assertNotEmpty($this->doPut('/foo.txt')); } - /** - * Determine if the underlying storage supports a negative mtime value - * - * @return boolean true if negative mtime is supported - */ - private function supportsNegativeMtime() { - return !(getenv("RUN_OBJECTSTORE_TESTS") !== false); - } - public function legalMtimeProvider() { return [ "string" => [ @@ -402,11 +393,11 @@ public function legalMtimeProvider() { ], "negative int" => [ 'HTTP_X_OC_MTIME' => -34, - 'expected result' => ($this->supportsNegativeMtime() ? -34 : 0) + 'expected result' => -34 ], "negative float" => [ 'HTTP_X_OC_MTIME' => -34.43, - 'expected result' => ($this->supportsNegativeMtime() ? -34 : 0) + 'expected result' => -34 ], ]; } diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index c0c6af2e49de..1c56606f9610 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -170,7 +170,7 @@ public function getPermissions($path) { public function filemtime($path) { $stat = $this->stat($path); - if (isset($stat['mtime']) && $stat['mtime'] > 0) { + if (isset($stat['mtime'])) { return $stat['mtime']; } else { return 0;