From 86471fa4d37b359605c2c5a9a27e80d877549147 Mon Sep 17 00:00:00 2001 From: fumikito Date: Sun, 17 Nov 2024 01:15:18 +0900 Subject: [PATCH] Fix downloader --- app/Hametuha/Hamail/API/UserDataGenerator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Hametuha/Hamail/API/UserDataGenerator.php b/app/Hametuha/Hamail/API/UserDataGenerator.php index dff76f6..e980a53 100644 --- a/app/Hametuha/Hamail/API/UserDataGenerator.php +++ b/app/Hametuha/Hamail/API/UserDataGenerator.php @@ -89,8 +89,11 @@ private function file_name() { * @return bool|\WP_Error */ public function to_path( $path ) { - if ( empty( $path ) || ! is_dir( $path ) || ! is_writable( $path ) ) { - return new \WP_Error( 'hamail_api_error', __( 'Directory must exist and be writable.', 'hamail' ) ); + if ( ! str_contains( 'php://', $path ) ) { + $dir = dirname( $path ); + if ( empty( $dir ) || ! is_dir( $dir ) || ! is_writable( $dir ) ) { + return new \WP_Error( 'hamail_api_error', __( 'Directory must exist and be writable.', 'hamail' ) ); + } } $handle = new \SplFileObject( $path, 'w' ); $fields = hamail_fields_array(); @@ -147,9 +150,12 @@ public function generate_csv_in_background( $path = '' ) { $body = <<get_error_messages() ); + error_log( $body ); } else { $body = <<