From 55890da6476116e4a2f08855d39615d298311d64 Mon Sep 17 00:00:00 2001 From: Fonata Date: Tue, 31 Jul 2018 21:55:08 +0200 Subject: [PATCH] Replace fread with file_get_contents to avoid the 8192 byte limit This can happen when using streams. Specific problem occurred with a file uploaded with Drupal's ``managed_file`` Form API element. See https://secure.php.net/manual/en/function.fread.php --- src/Csv.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Csv.php b/src/Csv.php index ced67a2..a97078d 100644 --- a/src/Csv.php +++ b/src/Csv.php @@ -1156,20 +1156,18 @@ class Csv { } /** - * Read local file + * Read local file. * - * @param string|null $file local filename + * @param string $file local filename * * @return string|false Data from file, or false on failure */ - protected function _rfile($file = null) { + protected function _rfile($file) { if (is_readable($file)) { - if (!($fh = fopen($file, 'r'))) { + $data = file_get_contents($file); + if ($data === false) { return false; } - - $data = fread($fh, filesize($file)); - fclose($fh); return rtrim($data, "\r\n"); }