title: Error file_get_contents(): read of 8192 bytes failed with errno=21
body: <p>I have a simple script, that searches inside every file of every subfolder for a given string. It worked just fine, until I believe my PHP got updated (I'm not pretty sure if it was because of that). This is the code:</p>
  <pre><code>&lt;?php 
  $limit = ini_get('memory_limit');
  ini_set('memory_limit', -1);
  ini_set('max_execution_time', 300);
  
  function get_directory_content($directory){
      global $search, $results; 
  
      $files = scandir($directory);
  
      foreach ($files as $file) {
          if ($file == &quot;.&quot; || $file == &quot;..&quot;) {
              continue;
          }
  
          $is_file = false;
          $path = realpath($directory . DIRECTORY_SEPARATOR . $file);
  
          if (is_dir($path)) {
              get_directory_content($path);
              $is_file = true;
          }
          else{
              $is_file = true;
          }
  
          if ($is_file) {
              $content = file_get_contents($path);
          }
  
  
          if (stripos($content, $search) !== false) {
              $obj = new stdClass();
              $obj-&gt;dir = ($directory . DIRECTORY_SEPARATOR . &quot;&lt;b&gt;&quot;.$file.&quot;&lt;/b&gt;&quot;);
              $obj-&gt;file_name = $file;
              array_push($results, $obj);
          }
      }
  }
  
  if (isset($_GET[&quot;submit&quot;])) {
      $search = $_GET[&quot;search&quot;];
      $results = array();
  
      get_directory_content(dirname(__FILE__));
  }
  
   ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Main&lt;/h1&gt;
          &lt;form method=&quot;GET&quot;&gt;
              &lt;p&gt;
                  &lt;input name=&quot;search&quot; autocomplete=&quot;off&quot; placeholder=&quot;Enter query here&quot;&gt;
              &lt;/p&gt;
              &lt;input type=&quot;submit&quot; name=&quot;submit&quot;&gt;
          &lt;/form&gt;
  
  
          &lt;?php foreach ($results as $result):  ?&gt;
              &lt;h1&gt;&lt;?php echo $result-&gt;file_name; ?&gt;&lt;/h1&gt;
              &lt;p&gt;&lt;?php echo $result-&gt;dir; ?&gt;&lt;/p&gt;
          &lt;?php endforeach; ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>And the error that I'm getting is: Notice: file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory in /Users/nikolaynikolaev/Server/original_search.php on line 29</p>
  <p>Does anyone have any idea of a potential fix for that issue?</p>
  <p>I would be more than grateful if you help me with a fix. Thanks in advance! :)</p>