-
-
Notifications
You must be signed in to change notification settings - Fork 859
Closed
Description
Current Behavior
Mentioning a group which has been set up with a 3 characters hex color brings an error when you try to mention it: TypeError: Unsupported operand types: string + string in /var/www/flarum2.localhost/PATH_TO_MONOREPO/extensions/mentions/src/ConfigureMentions.php:208
Steps to Reproduce
- Set up a group with a 3 char hex color (e.g.
#CCC) - Mention this group in a conversation
Expected Behavior
The 3 char. hex color should be converted to a 6 char. hex color in order to being parsed in the isDark util
Screenshots
No response
Environment
- Flarum version: main branch
- local dev env
Output of php flarum info
No response
Possible Solution
The original javascript isDark util is working fine. This is the php implementation for Mentions which is in cause:
$hexNumbers = Str::replace('#', '', $hexColor);
if (Str::length($hexNumbers) === 3) {
$hexNumbers += $hexNumbers;
}should be:
$hexNumbers = Str::replace('#', '', $hexColor);
if (Str::length($hexNumbers) === 3) {
$hexNumbers = $hexNumbers . $hexNumbers;
}Additional Context
No response