From f1cd0598591043d99c92bc5ce51c2e833625a531 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 6 Jul 2011 21:57:44 +0000 Subject: [PATCH] Bunch of error suppression operator fixes (bug --- includes/filerepo/FSRepo.php | 12 ++++++++---- includes/filerepo/ForeignAPIFile.php | 4 ++-- includes/filerepo/LocalFile.php | 4 +++- includes/filerepo/LocalRepo.php | 5 ++++- includes/media/DjVu.php | 4 +++- includes/templates/Userlogin.php | 12 ++++++------ maintenance/checkSyntax.php | 4 +++- maintenance/rebuildFileCache.php | 4 +++- maintenance/updateSearchIndex.php | 7 +++---- maintenance/updateSpecialPages.php | 3 ++- 10 files changed, 37 insertions(+), 22 deletions(-) diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 9049de1e3e..2610ac6e77 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -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 ); } diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 8005ac563e..abad830755 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -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() { diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 1c9040b75d..56a2185947 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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(); } } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index f3a15d9177..9089f4d7ba 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -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++; } diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index 4b0292ad5d..43d72aa9c7 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -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' ) ); } diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php index bcc02240f6..2b9ff3f7ba 100644 --- a/includes/templates/Userlogin.php +++ b/includes/templates/Userlogin.php @@ -36,7 +36,7 @@ class UserloginTemplate extends QuickTemplate { html('header'); /* pre-table point for form plugins... */ ?>
msgWiki('loginprompt') ?>
- haveData( 'languages' ) ) { ?> + haveData( 'languages' ) ) { ?> @@ -148,8 +148,8 @@ class UserloginTemplate extends QuickTemplate {
-haveData( 'uselang' ) ) { ?> -haveData( 'token' ) ) { ?> +haveData( 'uselang' ) ) { ?> +haveData( 'token' ) ) { ?>
msgWiki( 'loginend' ); ?>
@@ -191,7 +191,7 @@ class UsercreateTemplate extends QuickTemplate {

msg('createaccount') ?>

html('header'); /* pre-table point for form plugins... */ ?> - haveData( 'languages' ) ) { ?> + haveData( 'languages' ) ) { ?> @@ -373,8 +373,8 @@ class UsercreateTemplate extends QuickTemplate {
-haveData( 'uselang' ) ) { ?> -haveData( 'token' ) ) { ?> +haveData( 'uselang' ) ) { ?> +haveData( 'token' ) ) { ?>
msgWiki( 'signupend' ); ?>
diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index ad52a18a42..83f73be508 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -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 ); } diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 42897aff7e..84ada11c95 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -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 ) diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index c73b46562c..eed3571c2b 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -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 ); diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index dff201c1b3..ddf1601b1f 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -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' ) ) { -- 2.20.1