r91609 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91608‎ | r91609 | r91610 >
Date:21:57, 6 July 2011
Author:demon
Status:ok
Tags:
Comment:
Bunch of error suppression operator fixes (bug
Modified paths:
  • /trunk/phase3/includes/filerepo/FSRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalRepo.php (modified) (history)
  • /trunk/phase3/includes/media/DjVu.php (modified) (history)
  • /trunk/phase3/includes/templates/Userlogin.php (modified) (history)
  • /trunk/phase3/maintenance/checkSyntax.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildFileCache.php (modified) (history)
  • /trunk/phase3/maintenance/updateSearchIndex.php (modified) (history)
  • /trunk/phase3/maintenance/updateSpecialPages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/checkSyntax.php
@@ -101,7 +101,9 @@
102102 return; // process only this path
103103 } elseif ( $this->hasOption( 'list-file' ) ) {
104104 $file = $this->getOption( 'list-file' );
105 - $f = @fopen( $file, 'r' );
 105+ wfSuppressWarnings();
 106+ $f = fopen( $file, 'r' );
 107+ wfRestoreWarnings();
106108 if ( !$f ) {
107109 $this->error( "Can't open file $file\n", true );
108110 }
Index: trunk/phase3/maintenance/rebuildFileCache.php
@@ -95,7 +95,9 @@
9696 ob_start( array( &$cache, 'saveToFileCache' ) ); // save on ob_end_clean()
9797 $wgUseFileCache = false; // hack, we don't want $article fiddling with filecache
9898 $article->view();
99 - @$wgOut->output(); // header notices
 99+ wfSuppressWarnings(); // header notices
 100+ $wgOut->output();
 101+ wfRestoreWarnings();
100102 $wgUseFileCache = true;
101103 ob_end_clean(); // clear buffer
102104 if ( $rebuilt )
Index: trunk/phase3/maintenance/updateSearchIndex.php
@@ -55,11 +55,10 @@
5656 # We can safely delete the file when we're done though.
5757 $start = file_get_contents( 'searchUpdate.pos' );
5858 unlink( 'searchUpdate.pos' );
 59+ } elseif( is_readable( $posFile ) ) {
 60+ $start = file_get_contents( $posFile );
5961 } else {
60 - $start = @file_get_contents( $posFile );
61 - if ( !$start ) {
62 - $start = wfTimestamp( TS_MW, time() - 86400 );
63 - }
 62+ $start = wfTimestamp( TS_MW, time() - 86400 );
6463 }
6564 $lockTime = $this->getOption( 'l', 20 );
6665
Index: trunk/phase3/maintenance/updateSpecialPages.php
@@ -65,7 +65,8 @@
6666 require_once( "$IP/includes/QueryPage.php" );
6767
6868 foreach ( $wgQueryPages as $page ) {
69 - @list( $class, $special, $limit ) = $page;
 69+ list( $class, $special ) = $page;
 70+ $limit = isset( $page[2] ) ? $page[2] : null;
7071
7172 # --list : just show the name of pages
7273 if ( $this->hasOption( 'list' ) ) {
Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -697,7 +697,9 @@
698698 if ( strpos( $file, $this->getName() ) !== false ) {
699699 $url = $this->getThumbUrl( $file );
700700 $urls[] = $url;
701 - @unlink( "$dir/$file" );
 701+ wfSuppressWarnings();
 702+ unlink( "$dir/$file" );
 703+ wfRestoreWarnings();
702704 }
703705 }
704706
Index: trunk/phase3/includes/filerepo/FSRepo.php
@@ -592,14 +592,18 @@
593593 $good = true;
594594 if ( file_exists( $archivePath ) ) {
595595 # A file with this content hash is already archived
596 - if ( !@unlink( $srcPath ) ) {
 596+ wfSuppressWarnings();
 597+ $good = unlink( $srcPath );
 598+ wfRestoreWarnings();
 599+ if ( !$good ) {
597600 $status->error( 'filedeleteerror', $srcPath );
598 - $good = false;
599601 }
600602 } else{
601 - if ( !@rename( $srcPath, $archivePath ) ) {
 603+ wfSuppressWarnings();
 604+ $good = rename( $srcPath, $archivePath );
 605+ wfRestoreWarnings();
 606+ if ( !$good ) {
602607 $status->error( 'filerenameerror', $srcPath, $archivePath );
603 - $good = false;
604608 } else {
605609 $this->chmod( $archivePath );
606610 }
Index: trunk/phase3/includes/filerepo/LocalRepo.php
@@ -78,7 +78,10 @@
7979 }
8080 if ( !$inuse ) {
8181 wfDebug( __METHOD__ . ": deleting $key\n" );
82 - if ( !@unlink( $path ) ) {
 82+ wfSuppressWarnings();
 83+ $unlink = unlink( $path );
 84+ wfRestoreWarnings();
 85+ if ( !$unlink ) {
8386 $status->error( 'undelete-cleanup-error', $path );
8487 $status->failCount++;
8588 }
Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php
@@ -98,11 +98,11 @@
9999
100100 // Info we can get from API...
101101 public function getWidth( $page = 1 ) {
102 - return intval( @$this->mInfo['width'] );
 102+ return isset( $this->mInfo['width'] ) ? intval( @$this->mInfo['width'] ) : 0;
103103 }
104104
105105 public function getHeight( $page = 1 ) {
106 - return intval( @$this->mInfo['height'] );
 106+ return isset( $this->mInfo['height'] ) ? intval( @$this->mInfo['height'] ) : 0;
107107 }
108108
109109 public function getMetadata() {
Index: trunk/phase3/includes/media/DjVu.php
@@ -120,7 +120,9 @@
121121 // normaliseParams will inevitably give.
122122 $xml = $image->getMetadata();
123123 if ( !$xml ) {
124 - return new MediaTransformError( 'thumbnail_error', @$params['width'], @$params['height'],
 124+ $width = isset( $params['width'] ) ? $params['width'] : 0;
 125+ $height = isset( $params['height'] ) ? $params['height'] : 0;
 126+ return new MediaTransformError( 'thumbnail_error', $width, $height,
125127 wfMsg( 'djvu_no_xml' ) );
126128 }
127129
Index: trunk/phase3/includes/templates/Userlogin.php
@@ -36,7 +36,7 @@
3737 <p id="userloginlink"><?php $this->html('link') ?></p>
3838 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
3939 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
40 - <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
 40+ <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
4141 <table>
4242 <tr>
4343 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
@@ -148,8 +148,8 @@
149149 </td>
150150 </tr>
151151 </table>
152 -<?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
153 -<?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
 152+<?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
 153+<?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
154154 </form>
155155 </div>
156156 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
@@ -191,7 +191,7 @@
192192 <h2><?php $this->msg('createaccount') ?></h2>
193193 <p id="userloginlink"><?php $this->html('link') ?></p>
194194 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
195 - <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
 195+ <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
196196 <table>
197197 <tr>
198198 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
@@ -373,8 +373,8 @@
374374 </td>
375375 </tr>
376376 </table>
377 -<?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
378 -<?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
 377+<?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
 378+<?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
379379 </form>
380380 </div>
381381 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>

Follow-up revisions

RevisionCommit summaryAuthorDate
r91611Followup r91609, helps to actually remove the @demon22:07, 6 July 2011

Status & tagging log