Skip to content

Commit

Permalink
Issue 83: Rename variables that hold timestamps, time strings or date…
Browse files Browse the repository at this point in the history
…time objects.
  • Loading branch information
donquixote committed Jan 9, 2025
1 parent 6e0d1ef commit 0a91f3a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ protected function createNewFileEntity(FileInterface $file, string $new_file_con
* Failure response, or NULL if no conflict.
*/
protected function checkSaveTimestampConflict(Request $request, MediaInterface $media, FileInterface $file): ?Response {
$timestamp = $request->headers->get('x-cool-wopi-timestamp');
if (!$timestamp) {
$wopi_time_atom = $request->headers->get('x-cool-wopi-timestamp');
if (!$wopi_time_atom) {
return NULL;
}
$wopi_stamp = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $timestamp);
$file_stamp = \DateTimeImmutable::createFromFormat('U', $file->getChangedTime());
$wopi_datetime = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $wopi_time_atom);
$file_datetime = \DateTimeImmutable::createFromFormat('U', $file->getChangedTime());

if ($wopi_stamp == $file_stamp) {
if ($wopi_datetime == $file_datetime) {
return NULL;
}

$this->logger->error(
'Conflict saving file for media @media_id: WOPI time @wopi_time differs from file time @file_time.',
[
'@media_id' => $media->id(),
'@wopi_time' => $wopi_stamp->format('c'),
'@file_time' => $file_stamp->format('c'),
'@wopi_time' => $wopi_datetime->format('c'),
'@file_time' => $file_datetime->format('c'),
],
);

Expand Down

0 comments on commit 0a91f3a

Please sign in to comment.