1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-23 12:09:12 +01:00

PHP 8.1: Do not pass null to ctype_digit() in AphrontFormDateControlValue::getStandardDateFormat()

Summary:
PHP 8.1 warns that `ctype_digit(): Argument of type null will be interpreted as string in the future`. Thus do not pass a `null` value to `ctype_digit()` in `AphrontFormDateControlValue` but check first that the value is not null.
```
ERROR 8192: ctype_digit(): Argument of type null will be interpreted as string in the future at [/var/www/html/phorge/phorge/src/view/form/control/AphrontFormDateControlValue.php:332]
```
(It does not matter if we `return null` or `return ''` as the new fallback of `getStandardDateFormat()` - Phorge seems to handle both in this case.)

Closes T15994

Test Plan:
1. Go to http://phorge.localhost/T1, select "Start Tracking Time", remove both values, click the "Start Timer" button
2. Go to http://phorge.localhost/phrequent/ and see that the task is listed
3. Go to http://phorge.localhost/T1, select "Stop Tracking Time", remove both values, click the "Stop Timer" button
4. Go to http://phorge.localhost/phrequent/ and see that the task is not listed
5. Use a non-standard task creation form via http://phorge.localhost/maniphest/task/edit/form/5/ which has custom date fields visible and editable defined via http://phorge.localhost/config/edit/maniphest.custom-field-definitions/, enable the date fields, and remove their values, and file the task. Same behavior as on git master without the patch: These custom date values get set on the newly created task (which is not what I'd expect but it's not a regression created by this patch).

Reviewers: O1 Blessed Committers, slip, valerio.bozzolan

Reviewed By: O1 Blessed Committers, slip, valerio.bozzolan

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

Maniphest Tasks: T15994

Differential Revision: https://we.phorge.it/D25875
This commit is contained in:
Andre Klapper 2025-02-13 21:05:24 +01:00
parent a474a38dd6
commit 6ea09aa82c

View file

@ -307,6 +307,10 @@ final class AphrontFormDateControlValue extends Phobject {
}
private function getStandardDateFormat($date) {
// no value entered into the field at all
if (!$date) {
return null;
}
$colloquial = array(
'newyear' => 'January 1',
'valentine' => 'February 14',