title: PHP FTP script works by itself, but fails when part of a WordPress plugin
body: <p>I have this really simple bit of PHP which connects via FTP to get a file. It looks like this:</p>
  <pre><code>error_reporting(-1);
  ini_set(&quot;display_errors&quot;, 1);
  
  $ftp_server = &quot;xxxx&quot;;
  $ftp_user = &quot;xxxx&quot;;
  $ftp_pass = &quot;xxxx&quot;;
  
  $conn_id = ftp_connect($ftp_server); 
  
  if (ftp_login($conn_id, $ftp_user, $ftp_pass)) 
  {
      echo &quot;Connected successfully as $ftp_user@$ftp_server&lt;br&gt;\n&quot;;
  
      ftp_pasv($conn_id, true);
  
      if ( ftp_chdir($conn_id, '/mydir') )
      {
          echo &quot;Changed directory successfully&lt;br&gt;\n&quot;;
      
          if (ftp_get($conn_id, '/full/path/to/local.file', 'remote.file', FTP_ASCII))
          {
              echo &quot;Got file successfully. No problems here&lt;br&gt;\n&quot;;
          }
          else
          {
              echo &quot;Uh oh. Problems getting file&lt;br&gt;\n&quot;;
              print_r(error_get_last());
          }
      }
      else
      {
          echo &quot;Couldn't change directory&lt;br&gt;\n&quot;;
      }
  } else {
      echo &quot;Couldn't connect as $ftp_user&lt;br&gt;\n&quot;;
  }
  
  // close the connection
  ftp_close($conn_id);
  </code></pre>
  <p>Creating a standalone PHP file with that in works fine. It connects, logs in and gets the files. No errors at all.</p>
  <p>Now, I take that exact same piece of code, make no changes at all, and put it inside a WordPress plugin and it no longer works. Instead I get:</p>
  <blockquote>
  <p>Warning: ftp_get(): php_connect_nonb() failed: Operation now in progress (115) in /path/to/file/cron.php on line xx</p>
  <p>Warning: ftp_get(): Type set to A. in /path/to/file/cron.php on line xx</p>
  </blockquote>
  <p>I've done a lot of searching on the php_connect_nonb warning and they all suggest it's firewall related, but how can it then work when it's a standalone script.</p>
  <p>Has anyone got any logical reasoning as to how this can be possible and why it would suddenly stop working when put into WP? I'm completely out of ideas.</p>