svn: /web/doc-editor/trunk/php/ RepositoryManager.php

From: Date: Sun, 26 Dec 2010 22:54:04 +0000
Subject: svn: /web/doc-editor/trunk/php/ RepositoryManager.php
Groups: php.doc.web 
Request: Send a blank email to doc-web+get-1907@lists.php.net to get a copy of this message
yannick Sun, 26 Dec 2010 22:54:04 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=306712 Log: Add a new method to allow exec to catch STDERR when we check the build Changed paths: U web/doc-editor/trunk/php/RepositoryManager.php Modified: web/doc-editor/trunk/php/RepositoryManager.php =================================================================== --- web/doc-editor/trunk/php/RepositoryManager.php 2010-12-26 22:48:47 UTC (rev 306711) +++ web/doc-editor/trunk/php/RepositoryManager.php 2010-12-26 22:54:04 UTC (rev 306712) @@ -309,6 +309,21 @@ } /** + * Personnal exec to allow STDERR catch. + * Found in user's note : http://php.net/manual/fr/function.system.php + */ + public function my_exec($cmd, $input='') + { + $proc=proc_open($cmd, array(0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes); + fwrite($pipes[0], $input);fclose($pipes[0]); + $stdout=stream_get_contents($pipes[1]);fclose($pipes[1]); + $stderr=stream_get_contents($pipes[2]);fclose($pipes[2]); + $rtn=proc_close($proc); + + return $stdout.$stderr; + } + + /** * Check the build of the documentation (using configure.php script). * * @param $lang The lang of the documentation we want to check the build. We must take out $lang to be able to use this method from cron script on multiple language @@ -326,12 +341,12 @@ "logContent" => "" ); - $cmd = 'cd '.realpath($appConf[$project]['vcs.configure.script.path']).';' + $cmd = 'cd '.realpath($appConf[$project]['vcs.configure.script.path']).' && ' .$appConf['GLOBAL_CONFIGURATION']['php.bin'].' configure.php --with-php=' .$appConf['GLOBAL_CONFIGURATION']['php.bin'].' ' .$appConf[$project]['vcs.configure.script.options']; - $cmd = str_replace("{LangCode}", $lang, $cmd).';'; + $cmd = str_replace("{LangCode}", $lang, $cmd).''; if ( $enable_xml_details == "true" ) { $cmd = str_replace("{XmlDetails}", "--enable-xml-details", $cmd); @@ -341,16 +356,16 @@ $trial_threshold = 3; while ($trial_threshold-- > 0) { - $output = array(); - exec($cmd, $output); - if (strlen(trim(implode('', $output))) != 0) break; + $output =''; + $output = $this->my_exec($cmd); + if (strlen(trim($output)) != 0) break; } $return["logContent"] = $output; // We save the result of this check only if it failed. - if ( strstr(implode(" ", $output), 'Eyh man. No worries. Happ shittens. Try again after fixing the errors above.') || - strstr(implode(" ", $output), 'There were warnings loading the manual') ) + if ( strstr($output, 'Eyh man. No worries. Happ shittens. Try again after fixing the errors above.') || + strstr($output, 'There were warnings loading the manual') ) { $return["state"] = "ko"; }

« previous php.doc.web (#1907) next »