getid3_handler::fread() –
You appear to be a bot. Output may be restricted
Description
Usage
$string|false = getid3_handler::fread( $bytes );
Parameters
- $bytes
- ( int ) required –
Returns
string|false
Source
File name: wordpress/wp-includes/ID3/getid3.php
Lines:
1 to 37 of 37
protected function fread($bytes) { if ($this->data_string_flag) { $this->data_string_position += $bytes; return substr($this->data_string, $this->data_string_position - $bytes, $bytes); } if ($bytes == 0) { return ''; } elseif ($bytes < 0) { throw new getid3_exception('cannot fread('.$bytes.' from '.$this->getid3_handler::ftell().')', 10); } $pos = $this->getid3_handler::ftell() + $bytes; if (!getid3_lib::intValueSupported($pos)) { throw new getid3_exception('cannot fread('.$bytes.' from '.$this->getid3_handler::ftell().') because beyond PHP filesystem limit', 10); } //return fread($this->getid3->fp, $bytes); /* * https://www.getid3.org/phpBB3/viewtopic.php?t=1930 * "I found out that the root cause for the problem was how getID3 uses the PHP system function fread(). * It seems to assume that fread() would always return as many bytes as were requested. * However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes. * The call may return only part of the requested data and a new call is needed to get more." */ $contents = ''; do { //if (($this->getid3->memory_limit > 0) && ($bytes > $this->getid3->memory_limit)) { if (($this->getid3->memory_limit > 0) && (($bytes / $this->getid3->memory_limit) > 0.99)) { // enable a more-fuzzy match to prevent close misses generating errors like "PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 33554464 bytes)" throw new getid3_exception('cannot fread('.$bytes.' from '.$this->getid3_handler::ftell().') that is more than available PHP memory ('.$this->getid3->memory_limit.')', 10); } $part = fread($this->getid3->fp, $bytes); $partLength = strlen($part); $bytes -= $partLength; $contents .= $part; } while (($bytes > 0) && ($partLength > 0)); return $contents; }