Page MenuHomePhorge

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

Authored by aklapper on Jan 14 2024, 11:18.
Tags
None
Referenced Files
F2987193: D25516.1740110746.diff
Thu, Feb 20, 04:05
F2982287: D25516.1739948802.diff
Tue, Feb 18, 07:06
F2938345: D25516.1737994266.diff
Sun, Jan 26, 16:11
F2938344: D25516.1737994262.diff
Sun, Jan 26, 16:11
F2938343: D25516.1737994257.diff
Sun, Jan 26, 16:10
F2936258: D25516.1737911635.diff
Sat, Jan 25, 17:13
F2927385: D25516.1737647677.diff
Wed, Jan 22, 15:54
F2908533: D25516.1737379263.diff
Jan 19 2025, 13:21

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable