PHP 8.4 deprecation: fgetcsv()/fputcsv() missing explicit $escape parameter in GtfsFilter
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3584709. -->
Reported by: [jamesfmcgrath](https://www.drupal.org/user/546314)
>>>
<p><strong>Problem/Motivation</strong></p>
<p>On PHP 8.4, all calls to fgetcsv() and fputcsv() without an explicit $escape argument emit a deprecation notice:</p>
<p>Deprecated function: fgetcsv(): the $escape parameter must be provided as its default value will change</p>
<p>This causes visible errors in Drupal's watchdog/error log during GTFS import batch processing. The affected method is GtfsFilter::scanCsv() (and the related rewriteCsv() method), called during the geography filter collect batch step.</p>
<p>The old default value of "\\" is also incorrect for RFC 4180 CSV files — PHP's backslash escape is non-standard and can corrupt field values containing backslashes (e.g. free-text fields in some UK GTFS feeds).</p>
<p><strong>Steps to reproduce</strong></p>
<ol>
<li>Run a GTFS import on a site hosted on PHP 8.4.</li>
<li>Observe deprecation notices in the Drupal log during the filterGeographyCollect batch step.</li>
<li>Proposed resolution</li>
</ol>
<p>Pass escape: '' explicitly to all fgetcsv() and fputcsv() calls in GtfsFilter. An empty string disables PHP's non-standard backslash escape, which is the RFC 4180-compliant behaviour and matches what these calls should have been doing all along.</p>
<p>Affected calls in src/Service/GtfsFilter.php:</p>
<p>columnIndices() — line 675<br>
scanCsv() — lines 712, 717<br>
rewriteCsv() — lines 753, 760, 762, 764</p>
<p>Additionally, the early-return path in rewriteCsv() was not cleaning up the temporary .tmp file on a failed header read, and a silent @unlink() suppressor has been replaced with explicit error logging.</p>
issue