@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.

preg_match() null exception setting custom user profile image with empty files.viewable-mime-types

Summary:
When `files.viewable-mime-types` is not set, `getViewableMimeType()` passes `null` to `preg_match()` which is deprecated behavior since PHP 8.1.
Only call `preg_match()` when there are some MIME types to compare.

```
ERROR 8192: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/files/storage/PhabricatorFile.php:974]
```

Closes T15710

Test Plan: Go to a user profile and try to upload a custom profile picture in BMP format.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15710

Differential Revision: https://we.phorge.it/D25516

+7 -4
+7 -4
src/applications/files/storage/PhabricatorFile.php
··· 971 971 // warns you if you don't have complete support. 972 972 973 973 $matches = null; 974 - $ok = preg_match( 975 - '@^image/(gif|png|jpe?g)@', 976 - $this->getViewableMimeType(), 977 - $matches); 974 + $ok = false; 975 + if ($this->getViewableMimeType() !== null) { 976 + $ok = preg_match( 977 + '@^image/(gif|png|jpe?g)@', 978 + $this->getViewableMimeType(), 979 + $matches); 980 + } 978 981 if (!$ok) { 979 982 return false; 980 983 }