Bunch of error suppression operator fixes (bug
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 6 Jul 2011 21:57:44 +0000 (21:57 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 6 Jul 2011 21:57:44 +0000 (21:57 +0000)
includes/filerepo/FSRepo.php
includes/filerepo/ForeignAPIFile.php
includes/filerepo/LocalFile.php
includes/filerepo/LocalRepo.php
includes/media/DjVu.php
includes/templates/Userlogin.php
maintenance/checkSyntax.php
maintenance/rebuildFileCache.php
maintenance/updateSearchIndex.php
maintenance/updateSpecialPages.php

index 9049de1..2610ac6 100644 (file)
@@ -592,14 +592,18 @@ class FSRepo extends FileRepo {
                        $good = true;
                        if ( file_exists( $archivePath ) ) {
                                # A file with this content hash is already archived
-                               if ( !@unlink( $srcPath ) ) {
+                               wfSuppressWarnings();
+                               $good = unlink( $srcPath );
+                               wfRestoreWarnings();
+                               if ( !$good ) {
                                        $status->error( 'filedeleteerror', $srcPath );
-                                       $good = false;
                                }
                        } else{
-                               if ( !@rename( $srcPath, $archivePath ) ) {
+                               wfSuppressWarnings();
+                               $good = rename( $srcPath, $archivePath );
+                               wfRestoreWarnings();
+                               if ( !$good ) {
                                        $status->error( 'filerenameerror', $srcPath, $archivePath );
-                                       $good = false;
                                } else {
                                        $this->chmod( $archivePath );
                                }
index 8005ac5..abad830 100644 (file)
@@ -98,11 +98,11 @@ class ForeignAPIFile extends File {
 
        // Info we can get from API...
        public function getWidth( $page = 1 ) {
-               return intval( @$this->mInfo['width'] );
+               return isset( $this->mInfo['width'] ) ? intval( @$this->mInfo['width'] ) : 0;
        }
        
        public function getHeight( $page = 1 ) {
-               return intval( @$this->mInfo['height'] );
+               return isset( $this->mInfo['height'] ) ? intval( @$this->mInfo['height'] ) : 0;
        }
        
        public function getMetadata() {
index 1c9040b..56a2185 100644 (file)
@@ -697,7 +697,9 @@ class LocalFile extends File {
                        if ( strpos( $file, $this->getName() ) !== false ) {
                                $url = $this->getThumbUrl( $file );
                                $urls[] = $url;
-                               @unlink( "$dir/$file" );
+                               wfSuppressWarnings();
+                               unlink( "$dir/$file" );
+                               wfRestoreWarnings();
                        }
                }
 
index f3a15d9..9089f4d 100644 (file)
@@ -78,7 +78,10 @@ class LocalRepo extends FSRepo {
                        }
                        if ( !$inuse ) {
                                wfDebug( __METHOD__ . ": deleting $key\n" );
-                               if ( !@unlink( $path ) ) {
+                               wfSuppressWarnings();
+                               $unlink = unlink( $path );
+                               wfRestoreWarnings();
+                               if ( !$unlink ) {
                                        $status->error( 'undelete-cleanup-error', $path );
                                        $status->failCount++;
                                }
index 4b0292a..43d72aa 100644 (file)
@@ -120,7 +120,9 @@ class DjVuHandler extends ImageHandler {
                // normaliseParams will inevitably give.
                $xml = $image->getMetadata();
                if ( !$xml ) {
-                       return new MediaTransformError( 'thumbnail_error', @$params['width'], @$params['height'],
+                       $width = isset( $params['width'] ) ? $params['width'] : 0;
+                       $height = isset( $params['height'] ) ? $params['height'] : 0;
+                       return new MediaTransformError( 'thumbnail_error', $width, $height,
                                wfMsg( 'djvu_no_xml' ) );
                }
 
index bcc0224..2b9ff3f 100644 (file)
@@ -36,7 +36,7 @@ class UserloginTemplate extends QuickTemplate {
        <p id="userloginlink"><?php $this->html('link') ?></p>
        <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
        <div id="userloginprompt"><?php  $this->msgWiki('loginprompt') ?></div>
-       <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
+       <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
        <table>
                <tr>
                        <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
@@ -148,8 +148,8 @@ class UserloginTemplate extends QuickTemplate {
                        </td>
                </tr>
        </table>
-<?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
-<?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
+<?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
+<?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
 </form>
 </div>
 <div id="loginend"><?php $this->msgWiki( 'loginend' ); ?></div>
@@ -191,7 +191,7 @@ class UsercreateTemplate extends QuickTemplate {
        <h2><?php $this->msg('createaccount') ?></h2>
        <p id="userloginlink"><?php $this->html('link') ?></p>
        <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
-       <?php if( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
+       <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
        <table>
                <tr>
                        <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
@@ -373,8 +373,8 @@ class UsercreateTemplate extends QuickTemplate {
                        </td>
                </tr>
        </table>
-<?php if( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
-<?php if( @$this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
+<?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
+<?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
 </form>
 </div>
 <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
index ad52a18..83f73be 100644 (file)
@@ -101,7 +101,9 @@ class CheckSyntax extends Maintenance {
                        return; // process only this path
                } elseif ( $this->hasOption( 'list-file' ) ) {
                        $file = $this->getOption( 'list-file' );
-                       $f = @fopen( $file, 'r' );
+                       wfSuppressWarnings();
+                       $f = fopen( $file, 'r' );
+                       wfRestoreWarnings();
                        if ( !$f ) {
                                $this->error( "Can't open file $file\n", true );
                        }
index 42897af..84ada11 100644 (file)
@@ -95,7 +95,9 @@ class RebuildFileCache extends Maintenance {
                                        ob_start( array( &$cache, 'saveToFileCache' ) ); // save on ob_end_clean()
                                        $wgUseFileCache = false; // hack, we don't want $article fiddling with filecache
                                        $article->view();
-                                       @$wgOut->output(); // header notices
+                                       wfSuppressWarnings(); // header notices
+                                       $wgOut->output();
+                                       wfRestoreWarnings();
                                        $wgUseFileCache = true;
                                        ob_end_clean(); // clear buffer
                                        if ( $rebuilt )
index c73b465..eed3571 100644 (file)
@@ -55,11 +55,10 @@ class UpdateSearchIndex extends Maintenance {
                        # We can safely delete the file when we're done though.
                        $start = file_get_contents( 'searchUpdate.pos' );
                        unlink( 'searchUpdate.pos' );
+               } elseif( is_readable( $posFile ) ) {
+                       $start = file_get_contents( $posFile );
                } else {
-                       $start = @file_get_contents( $posFile );
-                       if ( !$start ) {
-                               $start = wfTimestamp( TS_MW, time() - 86400 );
-                       }
+                       $start = wfTimestamp( TS_MW, time() - 86400 );
                }
                $lockTime = $this->getOption( 'l', 20 );
 
index dff201c..ddf1601 100644 (file)
@@ -65,7 +65,8 @@ class UpdateSpecialPages extends Maintenance {
                require_once( "$IP/includes/QueryPage.php" );
 
                foreach ( $wgQueryPages as $page ) {
-                       @list( $class, $special, $limit ) = $page;
+                       list( $class, $special ) = $page;
+                       $limit = isset( $page[2] ) ? $page[2] : null;
 
                        # --list : just show the name of pages
                        if ( $this->hasOption( 'list' ) ) {