@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix mishandling of chunk threshold in Diffusion for installs with no chunk engines available

Summary: Fixes T10273. The threshold is `null` if no chunk engines are available, but the code didn't handle this properly.

Test Plan: Disabled all chunk engines, reloaded, hit issue described in task. Applied patch, got clean file content.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10273

Differential Revision: https://secure.phabricator.com/D15179

+18 -12
+18 -12
src/applications/files/uploadsource/PhabricatorFileUploadSource.php
··· 92 92 93 93 $threshold = PhabricatorFileStorageEngine::getChunkThreshold(); 94 94 95 - // If we don't know how large the file is, we're going to read some data 96 - // from it until we know whether it's a small file or not. This will give 97 - // us enough information to make a decision about chunking. 98 - $length = $this->getDataLength(); 99 - if ($length === null) { 100 - $rope = $this->getRope(); 101 - while ($this->readFileData()) { 102 - $length = $rope->getByteLength(); 103 - if ($length > $threshold) { 104 - break; 95 + if ($threshold === null) { 96 + // If there are no chunk engines available, we clearly can't chunk the 97 + // file. 98 + $this->shouldChunk = false; 99 + } else { 100 + // If we don't know how large the file is, we're going to read some data 101 + // from it until we know whether it's a small file or not. This will give 102 + // us enough information to make a decision about chunking. 103 + $length = $this->getDataLength(); 104 + if ($length === null) { 105 + $rope = $this->getRope(); 106 + while ($this->readFileData()) { 107 + $length = $rope->getByteLength(); 108 + if ($length > $threshold) { 109 + break; 110 + } 105 111 } 106 112 } 113 + 114 + $this->shouldChunk = ($length > $threshold); 107 115 } 108 - 109 - $this->shouldChunk = ($length > $threshold); 110 116 111 117 return $this->shouldChunk; 112 118 }