WordPress / WordPress/plugin-check

False positive: WordPress.WP.AlternativeFunctions.file_system_operations_fopen for php://output CSV streaming

Open
#1,377 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
362
Forks
126
Avg merge
1d 23h
Merged PRs (30d)
22

Description

Summary

The WordPress.WP.AlternativeFunctions.file_system_operations_fopen and WordPress.WP.AlternativeFunctions.file_system_operations_fclose checks report an error when using php://output for streaming a CSV download.

In this case, the warning appears to be a false positive because php://output is an output stream rather than a filesystem path, and there is no equivalent WordPress API (WP_Filesystem) for writing streamed CSV responses.

Minimal Reproduction

header( 'Content-Type: text/csv; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=test.csv' );

$output = fopen( 'php://output', 'w' );

foreach ( $rows as $row ) {
	fputcsv( $output, $row );
}

fclose( $output );
exit;

Current Result

Plugin Check reports:

  • WordPress.WP.AlternativeFunctions.file_system_operations_fopen
  • WordPress.WP.AlternativeFunctions.file_system_operations_fclose

Expected Result

The check should not report an error for php://output, since:

  • php://output is not a filesystem path.
  • WP_Filesystem cannot be used to replace this functionality.
  • Streaming CSV responses using fopen( 'php://output', 'w' ) and fputcsv() is a common PHP pattern, and there is currently no WordPress-native alternative.

If this usage is intentionally unsupported, it would be helpful for the documentation to explain the recommended approach.


Disclaimer: Claude was used to help investigate and draft this issue. I verified the behavior and confirmed the reproduction before submitting.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the WordPress.WP.AlternativeFunctions.file_system_operations_fopen and file_system_operations_fclose checks and reproduce the reported behavior with the minimal php://output CSV example. Done means the checks no longer report this stream, or the supported alternative is documented if the usage remains intentionally unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.