From 74ea267553bd94d84a819f54e9effe9c48b51299 Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Wed, 29 Nov 2006 05:45:03 +0000 Subject: [PATCH] Prevent the following strict-standards warnings - i.e. when running with error_logging(E_ALL | E_STRICT); - which seems to disable the yucky "@" operator, as well as maxing out the pedantry of warnings. Nothing major found, just nice to be as explicit and as forward-compatible as possible. * Strict Standards: Undefined index: switch in includes/Parser.php on line 3849 * Strict Standards: Undefined index: ref in includes/Parser.php on line 3818 * Strict Standards: Non-static method OutputPage::setEncodings() should not be called statically in index.php on line 11 * Strict Standards: Only variables should be assigned by reference in includes/Skin.php on line 888 * Strict Standards: Non-static method Title::newFromURL() should not be called statically in includes/SpecialContributions.php on line 178 * Strict Standards: Only variables should be assigned by reference in includes/GlobalFunctions.php on line 2054 * Strict Standards: Undefined index: contributions-summary in languages/Language.php on line 764 * Strict Standards: Undefined index: trackbackhtml in skins/MonoBook.php on line 86 * Strict Standards: Undefined index: blockip in skins/MonoBook.php on line 204 * Strict Standards: Undefined index: tagline in skins/MonoBook.php on line 261 * Strict Standards: Undefined index: uselang in includes/SkinTemplate.php on line 1159 * Strict Standards: Non-static method CoreParserFunctions::plural() cannot be called statically in includes/Parser.php on line 2902 * Strict Standards: Undefined offset: 0 in includes/SkinTemplate.php on line 196 * Strict Standards: Undefined index: USE INDEX in includes/Database.php on line 1015 * Strict Standards: Undefined index: image_tests in includes/Parser.php on line 3488 * Strict Standards: Undefined offset: 0 in includes/Parser.php on line 3507 * Strict Standards: Non-static method ChangesList::newFromUser() should not be called statically in includes/SpecialWatchlist.php on line 361 * Strict Standards: Non-static method RecentChange::newFromCurRow() should not be called statically in includes/SpecialWatchlist.php on line 367 * Strict Standards: is_a(): Deprecated. Please use the instanceof operator in includes/Exception.php on line 168 * Strict Standards: Non-static method LogPage::logName() should not be called statically in includes/SpecialContributions.php on line 325 * Strict Standards: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in maintenance/commandLine.inc on line 191 * Strict Standards: Undefined index: meatball in languages/Language.php on line 234 * Strict Standards: rmdir(/tmp/mwParser-2108164586-images/thumb): Directory not empty in maintenance/parserTests.inc on line 605 * Cleaning out some new temp files left over by parserTests (there were one or two straggler dirs/files that would persist after the test run ended, due to new tests being added over time) * Strict Standards: Non-static method CoreParserFunctions::special() cannot be called statically in includes/Parser.php on line 2902 * Strict Standards: Declaration of ListUsersPage::preprocessResults() should be compatible with that of QueryPage::preprocessResults() in includes/SpecialListusers.php on line 38 * Strict Standards: Only variables should be passed by reference in includes/SpecialBlockip.php on line 175 * Strict Standards: Skin::include_once(skins/Standard.deps.php) [function.include-once]: failed to open stream: No such file or directory in includes/Skin.php on line 121 * Strict Standards: Declaration of ApiMain::getResult() should be compatible with that of ApiBase::getResult() in includes/api/ApiMain.php on line 35 * Strict Standards: is_a(): Deprecated. Please use the instanceof operator in includes/WikiError.php on line 63 * Strict Standards: Non-static method WikiError::isError() should not be called statically in includes/SpecialImport.php on line 64 * Strict Standards: Non-static method ImportStreamSource::newFromInterwiki() should not be called statically in includes/SpecialImport.php on line 58getSkin(); $list = NULL; if( wfRunHooks( 'FetchChangesList', array( &$user, &$skin, &$list ) ) ) { diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index c0cdba9546..74a187b96e 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -88,19 +88,19 @@ class CoreParserFunctions { } } - function formatNum( $parser, $num = '' ) { + static function formatNum( $parser, $num = '' ) { return $parser->getFunctionLang()->formatNum( $num ); } - function grammar( $parser, $case = '', $word = '' ) { + static function grammar( $parser, $case = '', $word = '' ) { return $parser->getFunctionLang()->convertGrammar( $word, $case ); } - function plural( $parser, $text = '', $arg0 = null, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null ) { + static function plural( $parser, $text = '', $arg0 = null, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null ) { return $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 ); } - function displaytitle( $parser, $param = '' ) { + static function displaytitle( $parser, $param = '' ) { $parserOptions = new ParserOptions; $local_parser = clone $parser; $t2 = $local_parser->parse ( $param, $parser->mTitle, $parserOptions, false ); @@ -112,7 +112,7 @@ class CoreParserFunctions { return ''; } - function isRaw( $param ) { + static function isRaw( $param ) { static $mwRaw; if ( !$mwRaw ) { $mwRaw =& MagicWord::get( 'rawsuffix' ); @@ -124,7 +124,7 @@ class CoreParserFunctions { } } - function statisticsFunction( $func, $raw = null ) { + static function statisticsFunction( $func, $raw = null ) { if ( self::isRaw( $raw ) ) { return call_user_func( array( 'SiteStats', $func ) ); } else { @@ -133,13 +133,13 @@ class CoreParserFunctions { } } - function numberofpages( $parser, $raw = null ) { return self::statisticsFunction( 'pages', $raw ); } - function numberofusers( $parser, $raw = null ) { return self::statisticsFunction( 'users', $raw ); } - function numberofarticles( $parser, $raw = null ) { return self::statisticsFunction( 'articles', $raw ); } - function numberoffiles( $parser, $raw = null ) { return self::statisticsFunction( 'images', $raw ); } - function numberofadmins( $parser, $raw = null ) { return self::statisticsFunction( 'admins', $raw ); } + static function numberofpages( $parser, $raw = null ) { return self::statisticsFunction( 'pages', $raw ); } + static function numberofusers( $parser, $raw = null ) { return self::statisticsFunction( 'users', $raw ); } + static function numberofarticles( $parser, $raw = null ) { return self::statisticsFunction( 'articles', $raw ); } + static function numberoffiles( $parser, $raw = null ) { return self::statisticsFunction( 'images', $raw ); } + static function numberofadmins( $parser, $raw = null ) { return self::statisticsFunction( 'admins', $raw ); } - function pagesinnamespace( $parser, $namespace = 0, $raw = null ) { + static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) { $count = SiteStats::pagesInNs( intval( $namespace ) ); if ( self::isRaw( $raw ) ) { global $wgContLang; @@ -149,13 +149,13 @@ class CoreParserFunctions { } } - function language( $parser, $arg = '' ) { + static function language( $parser, $arg = '' ) { global $wgContLang; $lang = $wgContLang->getLanguageName( strtolower( $arg ) ); return $lang != '' ? $lang : $arg; } - function pad( $string = '', $length = 0, $char = 0, $direction = STR_PAD_RIGHT ) { + static function pad( $string = '', $length = 0, $char = 0, $direction = STR_PAD_RIGHT ) { $length = min( max( $length, 0 ), 500 ); $char = substr( $char, 0, 1 ); return ( $string && (int)$length > 0 && strlen( trim( (string)$char ) ) > 0 ) @@ -163,19 +163,19 @@ class CoreParserFunctions { : $string; } - function padleft( $parser, $string = '', $length = 0, $char = 0 ) { + static function padleft( $parser, $string = '', $length = 0, $char = 0 ) { return self::pad( $string, $length, $char, STR_PAD_LEFT ); } - function padright( $parser, $string = '', $length = 0, $char = 0 ) { + static function padright( $parser, $string = '', $length = 0, $char = 0 ) { return self::pad( $string, $length, $char ); } - function anchorencode( $parser, $text ) { + static function anchorencode( $parser, $text ) { return str_replace( '%', '.', str_replace('+', '_', urlencode( $text ) ) ); } - function special( $parser, $text ) { + static function special( $parser, $text ) { $title = SpecialPage::getTitleForAlias( $text ); if ( $title ) { return $title->getPrefixedText(); diff --git a/includes/Database.php b/includes/Database.php index 5f5601f101..fb4449b4a0 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1019,7 +1019,7 @@ class Database { $options = array( $options ); } if( is_array( $table ) ) { - if ( @is_array( $options['USE INDEX'] ) ) + if ( isset( $options['USE INDEX'] ) && is_array( $options['USE INDEX'] ) ) $from = ' FROM ' . $this->tableNamesWithUseIndex( $table, $options['USE INDEX'] ); else $from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) ); diff --git a/includes/Exception.php b/includes/Exception.php index 56f18d5ac6..ac9c8a2151 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -165,7 +165,7 @@ function wfInstallExceptionHandler() { * Report an exception to the user */ function wfReportException( Exception $e ) { - if ( is_a( $e, 'MWException' ) ) { + if ( $e instanceof MWException ) { try { $e->report(); } catch ( Exception $e2 ) { diff --git a/includes/Export.php b/includes/Export.php index aa70e27bef..c9878c97a0 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -597,7 +597,7 @@ class DumpFilter { * Override for page-based filter types. * @return bool */ - function pass( $page, $string ) { + function pass( $page ) { return true; } } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 238c77e2aa..4887653599 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2051,7 +2051,7 @@ function wfWikiID() { */ function &wfGetDB( $db = DB_LAST, $groups = array() ) { global $wgLoadBalancer; - $ret =& $wgLoadBalancer->getConnection( $db, true, $groups ); + $ret = $wgLoadBalancer->getConnection( $db, true, $groups ); return $ret; } ?> diff --git a/includes/Image.php b/includes/Image.php index 5170536e76..5e85602a00 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -58,7 +58,7 @@ class Image * @param string $name name of the image, used to create a title object using Title::makeTitleSafe * @public */ - function newFromName( $name ) { + public static function newFromName( $name ) { $title = Title::makeTitleSafe( NS_IMAGE, $name ); if ( is_object( $title ) ) { return new Image( $title ); diff --git a/includes/LogPage.php b/includes/LogPage.php index d25b8aa4ce..dd39512624 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -107,7 +107,7 @@ class LogPage { /** * @static */ - function logName( $type ) { + public static function logName( $type ) { global $wgLogNames; if( isset( $wgLogNames[$type] ) ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1dbcb9f715..264b5675a6 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -652,7 +652,7 @@ class OutputPage { /** * @todo document */ - public function setEncodings() { + public static function setEncodings() { global $wgInputEncoding, $wgOutputEncoding; global $wgUser, $wgContLang; diff --git a/includes/Parser.php b/includes/Parser.php index 695a630edd..94b8215948 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3485,7 +3485,7 @@ class Parser $refers[$headlineCount] = $canonized_headline; # count how many in assoc. array so we can track dupes in anchors - @$refers[$canonized_headline]++; + isset( $refers[$canonized_headline] ) ? $refers[$canonized_headline]++ : $refers[$canonized_headline] = 1; $refcount[$headlineCount]=$refers[$canonized_headline]; # Don't number the heading if it is the only one (looks silly) @@ -3503,7 +3503,7 @@ class Parser $toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel); } # give headline the correct tag - @$head[$headlineCount] .= "mTagHooks[$tag]; + $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null; $this->mTagHooks[$tag] = $callback; return $oldVal; @@ -3846,7 +3846,7 @@ class Parser * @return The old callback function for this name, if any */ function setFunctionHook( $id, $callback, $flags = 0 ) { - $oldVal = @$this->mFunctionHooks[$id]; + $oldVal = isset( $this->mFunctionHooks[$id] ) ? $this->mFunctionHooks[$id] : null; $this->mFunctionHooks[$id] = $callback; # Add to function cache diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 3839aae563..d0fa9f674d 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -376,9 +376,9 @@ class QueryPage { /** * Do any necessary preprocessing of the result object. - * You should pass this by reference: &$db , &$res + * You should pass this by reference: &$db , &$res [although probably no longer necessary in PHP5] */ - function preprocessResults( $db, $res ) {} + function preprocessResults( &$db, &$res ) {} /** * Similar to above, but packaging in a syndicated feed instead of a web page diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 6204def9c2..d1cda39d75 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -54,7 +54,7 @@ class RecentChange return $rc; } - /* static */ function newFromCurRow( $row, $rc_this_oldid = 0 ) + public static function newFromCurRow( $row, $rc_this_oldid = 0 ) { $rc = new RecentChange; $rc->loadFromCurRow( $row, $rc_this_oldid ); diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index cda1478c23..0c0f72444b 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -390,12 +390,13 @@ class Sanitizer { if(!$wgUseTidy) { $tagstack = $tablestack = array(); foreach ( $bits as $x ) { - $prev = error_reporting( E_ALL & ~( E_NOTICE | E_WARNING ) ); $regs = array(); - preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ); - list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; - error_reporting( $prev ); - + if( preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ) ) { + list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; + } else { + $slash = $t = $params = $brace = $rest = null; + } + $badtag = 0 ; if ( isset( $htmlelements[$t = strtolower( $t )] ) ) { # Check our stack diff --git a/includes/Skin.php b/includes/Skin.php index 43c7695ffc..9900ff4b14 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -116,10 +116,9 @@ class Skin extends Linker { $skinName = $skinNames[$key]; # Grab the skin class and initialise it. - wfSuppressWarnings(); // Preload base classes to work around APC/PHP5 bug - include_once( "{$wgStyleDirectory}/{$skinName}.deps.php" ); - wfRestoreWarnings(); + $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; + if( file_exists( $deps ) ) include_once( $deps ); require_once( "{$wgStyleDirectory}/{$skinName}.php" ); # Check if we got if not failback to default skin @@ -300,9 +299,9 @@ class Skin extends Linker { global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; global $wgTitle, $wgCanonicalNamespaceNames, $wgOut; - $nsname = @$wgCanonicalNamespaceNames[ $wgTitle->getNamespace() ]; - if ( $nsname === NULL ) $nsname = $wgTitle->getNsText(); - + $ns = $wgTitle->getNamespace(); + $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText(); + $vars = array( 'jsmimetype' => $wgJsMimeType, 'skinname' => $this->getSkinName(), @@ -884,7 +883,7 @@ END; } function getSearchLink() { - $searchPage =& SpecialPage::getTitleFor( 'Search' ); + $searchPage = SpecialPage::getTitleFor( 'Search' ); return $searchPage->getLocalURL(); } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index f804114525..c47e619ffb 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -193,8 +193,9 @@ class SkinTemplate extends Skin { $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle ); $tpl->set( 'pageclass', Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() ) ); - $nsname = @$wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ]; - if ( $nsname === NULL ) $nsname = $this->mTitle->getNsText(); + $nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ? + $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] : + $this->mTitle->getNsText(); $tpl->set( 'nscanonical', $nsname ); $tpl->set( 'nsnumber', $this->mTitle->getNamespace() ); @@ -236,8 +237,11 @@ class SkinTemplate extends Skin { } else { $tpl->set( 'feeds', false ); } - if ($wgUseTrackbacks && $out->isArticleRelated()) - $tpl->set( 'trackbackhtml', $wgTitle->trackbackRDF()); + if ($wgUseTrackbacks && $out->isArticleRelated()) { + $tpl->set( 'trackbackhtml', $wgTitle->trackbackRDF() ); + } else { + $tpl->set( 'trackbackhtml', null ); + } $tpl->setRef( 'mimetype', $wgMimeType ); $tpl->setRef( 'jsmimetype', $wgJsMimeType ); @@ -513,14 +517,17 @@ class SkinTemplate extends Skin { $href = self::makeSpecialUrl( "Contributions/$this->username" ); $personal_urls['mycontris'] = array( 'text' => wfMsg( 'mycontris' ), - 'href' => $href - # FIXME # 'active' => ( $href == $pageurl . '/' . $this->username ) + 'href' => $href, + // FIXME # 'active' was disabed in r11346 with message: "disable bold link to my contributions; link was bold on all + // Special:Contributions, not just current user's (fix me please!)". Until resolved, explicitly setting active to false. + 'active' => false # ( ( $href == $pageurl . '/' . $this->username ) ); $personal_urls['logout'] = array( 'text' => wfMsg( 'userlogout' ), 'href' => self::makeSpecialUrl( 'Userlogout', $wgTitle->isSpecial( 'Preferences' ) ? '' : "returnto={$this->thisurl}" - ) + ), + 'active' => false ); } else { if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) { @@ -821,7 +828,9 @@ class SkinTemplate extends Skin { } $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) ); - + // default permalink to being off, will override it as required below. + $nav_urls['permalink'] = false; + // A print stylesheet is attached to all pages, but nobody ever // figures that out. :) Add a link... if( $this->iscontent && ($action == '' || $action == 'view' || $action == 'purge' ) ) { @@ -859,6 +868,8 @@ class SkinTemplate extends Skin { $nav_urls['recentchangeslinked'] = array( 'href' => $rclTitle->getLocalUrl() ); + } else { + $nav_urls['recentchangeslinked'] = false; } if ($wgUseTrackbacks) $nav_urls['trackbacklink'] = array( @@ -878,12 +889,16 @@ class SkinTemplate extends Skin { $nav_urls['contributions'] = array( 'href' => self::makeSpecialUrl( 'Contributions/' . $this->mTitle->getText() ) ); - if ( $wgUser->isAllowed( 'block' ) ) + if ( $wgUser->isAllowed( 'block' ) ) { $nav_urls['blockip'] = array( 'href' => self::makeSpecialUrl( 'Blockip/' . $this->mTitle->getText() ) - ); + ); + } else { + $nav_urls['blockip'] = false; + } } else { $nav_urls['contributions'] = false; + $nav_urls['blockip'] = false; } $nav_urls['emailuser'] = false; if( $this->showEmailUser( $id ) ) { @@ -1141,7 +1156,7 @@ class QuickTemplate { * @private */ function haveData( $str ) { - return $this->data[$str]; + return isset( $this->data[$str] ); } /** diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 98d75ff0af..eb48d2ccba 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -172,7 +172,8 @@ class IPBlockForm { $user = User::newFromName( $this->BlockAddress ); if( is_object( $user ) ) { - $this->showLogFragment( $wgOut, $user->getUserPage() ); + $page = $user->getUserPage(); + $this->showLogFragment( $wgOut, $page ); } elseif( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->BlockAddress ) ) { $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) ); } diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index f147808268..1c8ee2e057 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -817,7 +817,7 @@ class ImportStreamSource { return new ImportStreamSource( $file ); } - function newFromUpload( $fieldname = "xmlimport" ) { + static function newFromUpload( $fieldname = "xmlimport" ) { $upload =& $_FILES[$fieldname]; if( !isset( $upload ) || !$upload['name'] ) { @@ -843,7 +843,7 @@ class ImportStreamSource { return $ret; } - function newFromInterwiki( $interwiki, $page, $history=false ) { + public static function newFromInterwiki( $interwiki, $page, $history=false ) { $link = Title::newFromText( "$interwiki:Special:Export/$page" ); if( is_null( $link ) || $link->getInterwiki() == '' ) { return new WikiErrorMsg( 'importbadinterwiki' ); diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 4668d0c7d7..b079434442 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -210,7 +210,7 @@ class ListUsersPage extends QueryPage { * $par string (optional) A group to list users from */ function wfSpecialListusers( $par = null ) { - global $wgRequest, $wgContLang; + global $wgRequest; list( $limit, $offset ) = wfCheckLimits(); diff --git a/includes/SpecialMIMEsearch.php b/includes/SpecialMIMEsearch.php index cbbe6f936d..8678118f2a 100644 --- a/includes/SpecialMIMEsearch.php +++ b/includes/SpecialMIMEsearch.php @@ -126,9 +126,12 @@ function wfSpecialMIMEsearch( $par = null ) { } function wfSpecialMIMEsearchParse( $str ) { - wfSuppressWarnings(); + // searched for an invalid MIME type. + if( strpos( $str, '/' ) === false) { + return array ('', ''); + } + list( $major, $minor ) = explode( '/', $str, 2 ); - wfRestoreWarnings(); return array( ltrim( $major, ' ' ), diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 9793b302b2..c78cae299b 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -498,7 +498,7 @@ class UndeleteForm { $wgOut->addWikiText( wfMsg( "undeletepagetext" ) ); $sk = $wgUser->getSkin(); - $undelete =& SpecialPage::getTitleFor( 'Undelete' ); + $undelete = SpecialPage::getTitleFor( 'Undelete' ); $wgOut->addHTML( "
    \n" ); while( $row = $result->fetchObject() ) { $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title ); diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 23d5c2825f..7205043164 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -12,7 +12,7 @@ function wfSpecialUserlogin() { global $wgCommandLineMode; global $wgRequest; if( !$wgCommandLineMode && !isset( $_COOKIE[session_name()] ) ) { - User::SetupSession(); + wfSetupSession(); } $form = new LoginForm( $wgRequest ); @@ -559,7 +559,7 @@ class LoginForm { if ( $wgUser->isLoggedIn() ) { $this->mName = $wgUser->getName(); } else { - $this->mName = @$_COOKIE[$wgCookiePrefix.'UserName']; + $this->mName = isset( $_COOKIE[$wgCookiePrefix.'UserName'] ) ? $_COOKIE[$wgCookiePrefix.'UserName'] : null; } } diff --git a/includes/Title.php b/includes/Title.php index f2b8d10c62..76cf0eba29 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -162,7 +162,7 @@ class Title { * @static * @access public */ - function newFromURL( $url ) { + public static function newFromURL( $url ) { global $wgLegalTitleChars; $t = new Title(); diff --git a/includes/WikiError.php b/includes/WikiError.php index 1b2c03bfd4..6986b1ce45 100644 --- a/includes/WikiError.php +++ b/includes/WikiError.php @@ -59,8 +59,8 @@ class WikiError { * @return bool * @static */ - function isError( &$object ) { - return is_a( $object, 'WikiError' ); + public static function isError( &$object ) { + return $object instanceof WikiError; } } diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index b2a8bd8786..335df324b7 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -82,7 +82,7 @@ class ApiFeedWatchlist extends ApiBase { $titleStr = $info['title']; $title = Title :: newFromText($titleStr); $titleUrl = $title->getFullUrl(); - $comment = $info['comment']; + $comment = isset( $info['comment'] ) ? $info['comment'] : null; $timestamp = $info['timestamp']; $user = $info['user']; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 22f02ba589..43d1da4321 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -100,7 +100,7 @@ class ApiMain extends ApiBase { return $this->mRequest; } - public function & getResult() { + public function getResult() { return $this->mResult; } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 4064075515..cc9a4fed7a 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -92,7 +92,7 @@ abstract class ApiQueryBase extends ApiBase { $isDirNewer = ($dir === 'newer'); $after = ($isDirNewer ? '>=' : '<='); $before = ($isDirNewer ? '<=' : '>='); - $db = & $this->getDB(); + $db = $this->getDB(); if (!is_null($start)) $this->addWhere($field . $after . $db->addQuotes($start)); @@ -113,7 +113,7 @@ abstract class ApiQueryBase extends ApiBase { protected function select($method) { // getDB has its own profileDBIn/Out calls - $db = & $this->getDB(); + $db = $this->getDB(); $this->profileDBIn(); $res = $db->select($this->tables, $this->fields, $this->where, $method, $this->options); @@ -127,10 +127,8 @@ abstract class ApiQueryBase extends ApiBase { $vals = array (); // ID - @ $tmp = $row-> { - $prefix . '_id' }; - if (!is_null($tmp)) - $vals[$prefix . 'id'] = intval($tmp); + if ( isset( $row-> { $prefix . '_id' } ) ) + $vals[$prefix . 'id'] = intval( $row-> { $prefix . '_id' } ); // Title $title = ApiQueryBase :: addRowInfo_title($row, $prefix . '_namespace', $prefix . '_title'); @@ -161,9 +159,8 @@ abstract class ApiQueryBase extends ApiBase { if (!is_null($tmp)) $vals['revid'] = intval($tmp); - @ $tmp = $row->rc_last_oldid; - if (!is_null($tmp)) - $vals['old_revid'] = intval($tmp); + if ( isset( $row->rc_last_oldid ) ) + $vals['old_revid'] = intval( $row->rc_last_oldid ); $title = ApiQueryBase :: addRowInfo_title($row, 'rc_moved_to_ns', 'rc_moved_to_title'); if ($title) { @@ -173,8 +170,7 @@ abstract class ApiQueryBase extends ApiBase { $vals['new_title'] = $title->getPrefixedText(); } - @ $tmp = $row->rc_patrolled; - if (!is_null($tmp)) + if ( isset( $row->rc_patrolled ) ) $vals['patrolled'] = ''; break; @@ -282,8 +278,8 @@ abstract class ApiQueryBase extends ApiBase { } private static function addRowInfo_title($row, $nsfld, $titlefld) { - @ $ns = $row-> $nsfld; - if (!is_null($ns)) { + if ( isset( $row-> $nsfld ) ) { + $ns = $row-> $nsfld; @ $title = $row-> $titlefld; if (!empty ($title)) return Title :: makeTitle($ns, $title); diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index dbe01c98f6..e2557e95fe 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -125,7 +125,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $count = 0; $res = $this->select(__METHOD__); - $db = & $this->getDB(); + $db = $this->getDB(); while ($row = $db->fetchObject($res)) { if (++ $count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... diff --git a/languages/Language.php b/languages/Language.php index 2f00a994dc..dacb2aaa83 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -231,12 +231,8 @@ class Language { */ function getNsIndex( $text ) { $this->load(); - $index = @$this->mNamespaceIds[$this->lc($text)]; - if ( is_null( $index ) ) { - return false; - } else { - return $index; - } + $lctext = $this->lc($text); + return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false; } /** @@ -761,7 +757,7 @@ class Language { function getMessage( $key ) { $this->load(); - return @$this->messages[$key]; + return isset( $this->messages[$key] ) ? $this->messages[$key] : null; } function getAllMessages() { @@ -1664,7 +1660,7 @@ class Language { */ static function getMessageFor( $key, $code ) { self::loadLocalisation( $code ); - return @self::$mLocalisationCache[$code]['messages'][$key]; + return isset( self::$mLocalisationCache[$code]['messages'][$key] ) ? self::$mLocalisationCache[$code]['messages'][$key] : null; } /** diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index 13e2ef5cd9..18a1d71298 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -188,7 +188,9 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { } # Turn off output buffering again, it might have been turned on in the settings files -@ob_end_flush(); +if( ob_get_level() ) { + ob_end_flush(); +} # Same with these $wgCommandLineMode = true; diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index f3b1754f54..0f5a4bd125 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -571,21 +571,56 @@ class ParserTest { * @private */ function teardownUploadDir( $dir ) { - unlink( "$dir/3/3a/Foobar.jpg" ); - rmdir( "$dir/3/3a" ); - rmdir( "$dir/3" ); - @rmdir( "$dir/thumb/6/65" ); - @rmdir( "$dir/thumb/6" ); - - @unlink( "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" ); - @rmdir( "$dir/thumb/3/3a/Foobar.jpg" ); - @rmdir( "$dir/thumb/3/3a" ); - @rmdir( "$dir/thumb/3/39" ); # wtf? - @rmdir( "$dir/thumb/3" ); - @rmdir( "$dir/thumb" ); - @rmdir( "$dir" ); + // delete the files first, then the dirs. + self::deleteFiles( + array ( + "$dir/3/3a/Foobar.jpg", + "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg", + "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg", + "$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg", + "$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg", + ) + ); + + self::deleteDirs( + array ( + "$dir/3/3a", + "$dir/3", + "$dir/thumb/6/65", + "$dir/thumb/6", + "$dir/thumb/3/3a/Foobar.jpg", + "$dir/thumb/3/3a", + "$dir/thumb/3", + "$dir/thumb", + "$dir", + ) + ); } + /** + * @desc delete the specified files, if they exist. + * @param array $files full paths to files to delete. + */ + private static function deleteFiles( $files ) { + foreach( $files as $file ) { + if( file_exists( $file ) ) { + unlink( $file ); + } + } + } + + /** + * @desc delete the specified directories, if they exist. Must be empty. + * @param array $dirs full paths to directories to delete. + */ + private static function deleteDirs( $dirs ) { + foreach( $dirs as $dir ) { + if( is_dir( $dir ) ) { + rmdir( $dir ); + } + } + } + /** * "Running test $desc..." * @private diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 4322e0dc74..eb1b3cebea 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -258,7 +258,7 @@ class MonoBookTemplate extends QuickTemplate { 'privacy', 'about', 'disclaimer', 'tagline', ); foreach( $footerlinks as $aLink ) { - if( $this->data[$aLink] ) { + if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { ?>
  • html($aLink) ?>