1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Fix PHP 8.1 strlen(null) error in PhabricatorFile::newChunkedFile()

Summary:
Fix PHP 8.1 strlen(null) error in PhabricatorFile::newChunkedFile().

Fixes T15499

Test Plan:
Added a unit test which replicated the fault, so you can test simply by 'arc unit'
Alternatively, see test in T15499

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15499

Differential Revision: https://we.phorge.it/D25352
This commit is contained in:
Steve Campbell 2023-07-17 13:25:32 +01:00
parent dbc101ca8a
commit 27fa498966
2 changed files with 8 additions and 1 deletions

View file

@ -287,7 +287,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
// NOTE: Once we receive the first chunk, we'll detect its MIME type and
// update the parent file if a MIME type hasn't been provided. This matters
// for large media files like video.
$mime_type = idx($params, 'mime-type');
$mime_type = idx($params, 'mime-type', '');
if (!strlen($mime_type)) {
$file->setMimeType('application/octet-stream');
}

View file

@ -532,4 +532,11 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase {
$this->assertEqual(array(), $alternate_c);
}
public function testNewChunkedFile() {
$engine = new PhabricatorTestStorageEngine();
$file = PhabricatorFile::newChunkedFile($engine, 10, []);
$this->assertTrue($file instanceof PhabricatorFile,
pht('newChunkedFile returns a PhabricatorFile'));
}
}