From 79464882da14c2bd2dc674b14225b2ed96d4910e Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Tue, 2 Apr 2024 22:48:12 +0200 Subject: [PATCH] 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 --- .../export/format/PhabricatorTextExportFormat.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/export/format/PhabricatorTextExportFormat.php b/src/infrastructure/export/format/PhabricatorTextExportFormat.php index d51e199f91..eada8cac94 100644 --- a/src/infrastructure/export/format/PhabricatorTextExportFormat.php +++ b/src/infrastructure/export/format/PhabricatorTextExportFormat.php @@ -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);