1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Fix PHP 8.1 "addcslashes(null)" exception exporting task list to tab-separated text

Summary:
When a column value to export to Tab-Separated Text is empty, `null` is passed to `addcslashes()` which is deprecated behavior since PHP 8.1.
Thus only call `addclashes()` when the value is set.

```
ERROR 8192: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/infrastructure/export/format/PhabricatorTextExportFormat.php:45]
```

Closes T15771

Test Plan: Export a Maniphest task list of query results to Tab-Separated Text.

Reviewers: O1 Blessed Committers, 20after4, speck

Reviewed By: O1 Blessed Committers, 20after4, speck

Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15771

Differential Revision: https://we.phorge.it/D25568
This commit is contained in:
Andre Klapper 2024-04-02 22:48:12 +02:00
parent 0d9ca2589f
commit 79464882da

View file

@ -42,7 +42,9 @@ final class PhabricatorTextExportFormat
private function addRow(array $values) {
$row = array();
foreach ($values as $value) {
$row[] = addcslashes($value, "\0..\37\\\177..\377");
if (phutil_nonempty_string($value)) {
$row[] = addcslashes($value, "\0..\37\\\177..\377");
}
}
$this->rows[] = implode("\t", $row);