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
This commit is contained in:
Fonata
2018-07-31 21:55:08 +02:00
parent 21953ab6be
commit 55890da647

View File

@@ -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");
}