From f76419d190ab1557dcd333ebe7a9519340a2b0a7 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sat, 8 Nov 2014 00:38:00 -0800 Subject: [PATCH] fix touch() when $mtime is set (Google wants RFC3339) #11267 ownCloud passes us a Unix time integer, but the GDrive API wants an RFC3339-formatted date. Actually it wants a single particular RFC3339 format, not just anything that complies will do - it requires the fractions to be specified, though RFC3339 doesn't. This resolves issue #11267 (and was also noted by PVince81 in reviewing PR #6989). --- apps/files_external/lib/google.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 62b0f182e9..a4337bc937 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -496,7 +496,10 @@ class Google extends \OC\Files\Storage\Common { $result = false; if ($file) { if (isset($mtime)) { - $file->setModifiedDate($mtime); + // This is just RFC3339, but frustratingly, GDrive's API *requires* + // the fractions portion be present, while no handy PHP constant + // for RFC3339 or ISO8601 includes it. So we do it ourselves. + $file->setModifiedDate(date('Y-m-d\TH:i:s.uP', $mtime)); $result = $this->service->files->patch($file->getId(), $file, array( 'setModifiedDate' => true, ));