Merge remote-tracking branch 'refs/remotes/origin/2.1' into 3.0
authorAlexander Ebert <ebert@woltlab.com>
Mon, 6 Nov 2017 13:05:25 +0000 (14:05 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 6 Nov 2017 13:05:25 +0000 (14:05 +0100)
# Conflicts:
# wcfsetup/install/files/lib/page/AttachmentPage.class.php

1  2 
com.woltlab.wcf/option.xml
wcfsetup/install/files/lib/page/AttachmentPage.class.php

Simple merge
index 3f3e46f8f3f9ff6ad48312aeca7a47277cb5abd5,acecb0733ba5e99b4edaa0312ccb897f7c62a5bc..da7e26c8e75db18a8c652604974dac7a874eb27a
@@@ -136,23 -130,26 +136,26 @@@ class AttachmentPage extends AbstractPa
                        $mimeType = $this->attachment->fileType;
                        $filesize = $this->attachment->filesize;
                        $location = $this->attachment->getLocation();
 +                      $this->eTag = $this->attachmentID;
                }
                
+               // unsaved attachments may be cached by the browser for up to 5 minutes only
+               $cacheDuration = ($this->attachment->tmpHash) ? 300 : 31536000;
+               
                // init file reader
 -              $this->fileReader = new FileReader($location, array(
 +              $this->fileReader = new FileReader($location, [
                        'filename' => $this->attachment->filename,
                        'mimeType' => $mimeType,
                        'filesize' => $filesize,
 -                      'showInline' => (in_array($mimeType, self::$inlineMimeTypes)),
 -                      'enableRangeSupport' => (!$this->tiny && !$this->thumbnail),
 +                      'showInline' => in_array($mimeType, self::$inlineMimeTypes),
 +                      'enableRangeSupport' => !$this->tiny && !$this->thumbnail,
                        'lastModificationTime' => $this->attachment->uploadTime,
-                       'expirationDate' => TIME_NOW + 31536000,
-                       'maxAge' => 31536000
+                       'expirationDate' => TIME_NOW + $cacheDuration,
+                       'maxAge' => $cacheDuration
 -              ));
 +              ]);
                
 -              // add etag for non-thumbnail
 -              if (!$this->thumbnail && !$this->tiny) {
 -                      $this->fileReader->addHeader('ETag', '"'.$this->attachmentID.'"');
 +              if ($this->eTag !== null) {
 +                      $this->fileReader->addHeader('ETag', '"'.$this->eTag.'"');
                }
        }