Skip to content

Commit 5e9cea6

Browse files
fix: visualizer getCSV method throwing constant errors (#1263)
* fix: visualizer getCSV method throwing constant errors * fix: pr review changes * fix: pr review changes
1 parent 57a71e7 commit 5e9cea6

6 files changed

Lines changed: 2040 additions & 97 deletions

File tree

classes/Visualizer/Module.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,15 @@ private function _getCSV( $rows, $filename, $enclose ) {
270270
$bom = chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF );
271271
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
272272
$fp = function_exists( 'tmpfile' ) ? @tmpfile() : null;
273-
if ( null === $fp ) {
273+
if ( ! $fp ) {
274274
if ( ! function_exists( 'wp_tempnam' ) ) {
275275
require_once ABSPATH . 'wp-admin/includes/file.php';
276276
}
277277
$fp = fopen( wp_tempnam(), 'w+' );
278278
}
279+
if ( ! $fp ) {
280+
return array( 'csv' => '', 'name' => $filename, 'string' => '' );
281+
}
279282
if ( ! apply_filters( 'vizualizer_export_include_series_type', true ) ) {
280283
unset( $rows[1] );
281284
$rows = array_values( $rows );

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
5353
"phpcompatibility/phpcompatibility-wp": "*",
5454
"phpstan/phpstan": "^2.1",
55-
"szepeviktor/phpstan-wordpress": "^2.0"
55+
"szepeviktor/phpstan-wordpress": "^2.0",
56+
"yoast/phpunit-polyfills": "^4.0"
5657
}
5758
}

0 commit comments

Comments
 (0)