WordPress / WordPress/plugin-check
False positive: WordPress.WP.AlternativeFunctions.file_system_operations_fopen for php://output CSV streaming
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_fopenWordPress.WP.AlternativeFunctions.file_system_operations_fclose
Expected Result
The check should not report an error for php://output, since:
php://outputis not a filesystem path.WP_Filesystemcannot be used to replace this functionality.- Streaming CSV responses using
fopen( 'php://output', 'w' )andfputcsv()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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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