Security update for Core, with self-updated composer
[yaffs-website] / vendor / drush / drush / includes / output.inc
index 1c56dc63efcac2c013a7290eedf7c85d91f9139d..950953f12123252c8a294d6d9fef210094907b6d 100644 (file)
@@ -34,12 +34,15 @@ function drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE
   if (($charset = drush_get_option('output_charset')) && function_exists('iconv')) {
     $msg = iconv('UTF-8', $charset, $msg);
   }
-  if (isset($handle)) {
-    fwrite($handle, $msg);
-  }
-  else {
-    print $msg;
-  }
+  if (!isset($handle)) {
+    $handle = STDOUT;
+    // In the past, Drush would use `print` here; now that we are using
+    // fwrite (to avoid problems with php sending the http headers), we
+    // must explicitly capture the output, because ob_start() / ob_end()
+    // does not capture output written via fwrite to STDOUT.
+    drush_backend_output_collect($msg);
+  }
+  fwrite($handle, $msg);
 }
 
 /**