From: Chad Horohoe Date: Sun, 2 Aug 2009 21:42:47 +0000 (+0000) Subject: * Add way to get full input from stdin() without having to check the length X-Git-Tag: 1.31.0-rc.0~40560 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=5ff7ffe312d2881725293deb994c863103923271;p=lhc%2Fweb%2Fwiklou.git * Add way to get full input from stdin() without having to check the length * Missing global --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index edfbe79394..b1f0a8d7d9 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -45,6 +45,9 @@ abstract class Maintenance { const DB_NONE = 0; const DB_STD = 1; const DB_ADMIN = 2; + + // Const for getStdin() + const STDIN_ALL = 'all'; // This is the desired params private $mParams = array(); @@ -178,14 +181,16 @@ abstract class Maintenance { /** * Return input from stdin. * @param $length int The number of bytes to read. If null, - * just return the handle + * just return the handle. Maintenance::STDIN_ALL returns + * the full length * @return mixed */ protected function getStdin( $len = null ) { + if ( $len == Maintenance::STDIN_ALL ) + return file_get_contents( 'php://stdin' ); $f = fopen( 'php://stdin', 'rt' ); - if( !$len ) { + if( !$len ) return $f; - } $input = fgets( $f, $len ); fclose ( $f ); return rtrim( $input ); diff --git a/maintenance/edit.php b/maintenance/edit.php index 9fdce24fa0..704909adf7 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -61,7 +61,7 @@ class EditCLI extends Maintenance { $wgArticle = new Article( $wgTitle ); # Read the text - $text = $this->getStdin(); + $text = $this->getStdin( Maintenance::STDIN_ALL ); # Do the edit $this->output( "Saving... " ); diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index da60763522..c8bc58639b 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -35,6 +35,7 @@ in $wgDBservers, usually indicating a replication environment.' ); } public function execute() { + global $wgDBservers; $dbw = wfGetDB( DB_MASTER ); $user = $dbw->tableName( 'user' ); $revision = $dbw->tableName( 'revision' );