@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 PHP 8.1 exceptions importing ICS file without attendee names

Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Passing `null` to `preg_match()` is deprecated behavior since PHP 8.1.
Thus only call `preg_match()` when the value is set.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

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

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/calendar/import/PhabricatorCalendarImportEngine.php:245]
```

Closes T15852

Test Plan: Import an ICS file which lists attendees without a name but only with an email address into the calendar via http://phorge.localhost/calendar/import/ > "Import Events" > "Import .ics File"

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15852

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

+2 -2
+2 -2
src/applications/calendar/import/PhabricatorCalendarImportEngine.php
··· 235 235 // We avoid disclosing email addresses to be consistent with the rest 236 236 // of the product. 237 237 $name = $attendee->getName(); 238 - if (preg_match('/@/', $name)) { 238 + if (phutil_nonempty_string($name) && preg_match('/@/', $name)) { 239 239 $name = new PhutilEmailAddress($name); 240 240 $name = $name->getDisplayName(); 241 241 } 242 242 243 243 // If we don't have a name or the name still looks like it's an 244 244 // email address, give them a dummy placeholder name. 245 - if (!strlen($name) || preg_match('/@/', $name)) { 245 + if (!phutil_nonempty_string($name) || preg_match('/@/', $name)) { 246 246 $name = pht('Private User %d', $private_index); 247 247 $private_index++; 248 248 }