From cde6bce5454ebe09ffd8ee40340b86a7fff12195 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 13 Aug 2008 16:23:41 +0000 Subject: [PATCH] Catch php installs who have proc_open() disabled. --- includes/parser/Parser.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index de0d74369d..5f97184772 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -689,20 +689,22 @@ class Parser 2 => array('file', wfGetNull(), 'a') ); $pipes = array(); - $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts$opts", $descriptorspec, $pipes); - if (is_resource($process)) { - // Theoretically, this style of communication could cause a deadlock - // here. If the stdout buffer fills up, then writes to stdin could - // block. This doesn't appear to happen with tidy, because tidy only - // writes to stdout after it's finished reading from stdin. Search - // for tidyParseStdin and tidySaveStdout in console/tidy.c - fwrite($pipes[0], $text); - fclose($pipes[0]); - while (!feof($pipes[1])) { - $cleansource .= fgets($pipes[1], 1024); + if( function_exists('proc_open') ) { + $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts$opts", $descriptorspec, $pipes); + if (is_resource($process)) { + // Theoretically, this style of communication could cause a deadlock + // here. If the stdout buffer fills up, then writes to stdin could + // block. This doesn't appear to happen with tidy, because tidy only + // writes to stdout after it's finished reading from stdin. Search + // for tidyParseStdin and tidySaveStdout in console/tidy.c + fwrite($pipes[0], $text); + fclose($pipes[0]); + while (!feof($pipes[1])) { + $cleansource .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + proc_close($process); } - fclose($pipes[1]); - proc_close($process); } wfProfileOut( $fname ); -- 2.20.1