r54239 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54238‎ | r54239 | r54240 >
Date:21:42, 2 August 2009
Author:demon
Status:ok
Tags:
Comment:
* Add way to get full input from stdin() without having to check the length
* Missing global
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)
  • /trunk/phase3/maintenance/edit.php (modified) (history)
  • /trunk/phase3/maintenance/initEditCount.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/edit.php
@@ -61,7 +61,7 @@
6262 $wgArticle = new Article( $wgTitle );
6363
6464 # Read the text
65 - $text = $this->getStdin();
 65+ $text = $this->getStdin( Maintenance::STDIN_ALL );
6666
6767 # Do the edit
6868 $this->output( "Saving... " );
Index: trunk/phase3/maintenance/Maintenance.php
@@ -45,6 +45,9 @@
4646 const DB_NONE = 0;
4747 const DB_STD = 1;
4848 const DB_ADMIN = 2;
 49+
 50+ // Const for getStdin()
 51+ const STDIN_ALL = 'all';
4952
5053 // This is the desired params
5154 private $mParams = array();
@@ -178,14 +181,16 @@
179182 /**
180183 * Return input from stdin.
181184 * @param $length int The number of bytes to read. If null,
182 - * just return the handle
 185+ * just return the handle. Maintenance::STDIN_ALL returns
 186+ * the full length
183187 * @return mixed
184188 */
185189 protected function getStdin( $len = null ) {
 190+ if ( $len == Maintenance::STDIN_ALL )
 191+ return file_get_contents( 'php://stdin' );
186192 $f = fopen( 'php://stdin', 'rt' );
187 - if( !$len ) {
 193+ if( !$len )
188194 return $f;
189 - }
190195 $input = fgets( $f, $len );
191196 fclose ( $f );
192197 return rtrim( $input );
Index: trunk/phase3/maintenance/initEditCount.php
@@ -35,6 +35,7 @@
3636 }
3737
3838 public function execute() {
 39+ global $wgDBservers;
3940 $dbw = wfGetDB( DB_MASTER );
4041 $user = $dbw->tableName( 'user' );
4142 $revision = $dbw->tableName( 'revision' );

Status & tagging log