From 44229b50e680b935dfb30a7ccb22535bc3cae708 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 9 Jun 2010 11:44:05 +0000 Subject: [PATCH] Fixed a bunch of silly instances of [^!=]==\s*(true|false) --- config/Installer.php | 2 +- includes/BagOStuff.php | 2 +- includes/EditPage.php | 2 +- includes/GlobalFunctions.php | 2 +- includes/ImageGallery.php | 4 ++-- includes/OutputPage.php | 2 ++ includes/SkinTemplate.php | 15 +++++++++++++++ includes/SpecialPage.php | 2 +- includes/Title.php | 6 +++--- includes/api/ApiProtect.php | 2 +- includes/db/DatabaseIbm_db2.php | 2 +- includes/db/DatabaseOracle.php | 6 +++--- includes/db/DatabasePostgres.php | 6 +++--- includes/db/DatabaseSqlite.php | 2 +- includes/parser/CoreParserFunctions.php | 9 +++++++++ includes/parser/ParserOutput.php | 13 ++++++++++++- languages/LanguageConverter.php | 2 +- languages/messages/MessagesEn.php | 1 + maintenance/rebuildrecentchanges.php | 4 ++-- maintenance/refreshLinks.php | 2 +- maintenance/runJobs.php | 6 ++---- 21 files changed, 64 insertions(+), 28 deletions(-) diff --git a/config/Installer.php b/config/Installer.php index 082d491468..191ca852d7 100644 --- a/config/Installer.php +++ b/config/Installer.php @@ -1330,7 +1330,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $localSettings = str_replace( "\r\n", "\n", $localSettings ); $f = fopen( "LocalSettings.php", 'xt' ); - if( $f == false ) { + if( !$f ) { print( "\n" ); dieout( "

Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...

\n" . "

Here's the file that would have been written, try to paste it into place manually:

\n" . diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index aa52a842d9..fb57ad023c 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -102,7 +102,7 @@ abstract class BagOStuff { } public function add( $key, $value, $exptime = 0 ) { - if ( $this->get( $key ) == false ) { + if ( !$this->get( $key ) ) { $this->set( $key, $value, $exptime ); return true; diff --git a/includes/EditPage.php b/includes/EditPage.php index a158193b20..8830a7d9e9 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2628,7 +2628,7 @@ INPUTS } function getBaseRevision() { - if ( $this->mBaseRevision == false ) { + if ( !$this->mBaseRevision ) { $db = wfGetDB( DB_MASTER ); $baseRevision = Revision::loadFromTimestamp( $db, $this->mTitle, $this->edittime ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 005fb8e0fe..273a7d049e 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1500,7 +1500,7 @@ function wfMerge( $old, $mine, $yours, &$result ){ pclose( $handle ); unlink( $mytextName ); unlink( $oldtextName ); unlink( $yourtextName ); - if ( $result === '' && $old !== '' && $conflict == false ) { + if ( $result === '' && $old !== '' && !$conflict ) { wfDebug( "Unexpected null result from diff3. Command: $cmd\n" ); $conflict = true; } diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index e5a8070963..0b44ab906e 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -183,7 +183,7 @@ class ImageGallery * @param $f Boolean: set to false to disable. */ function setShowBytes( $f ) { - $this->mShowBytes = ( $f == true); + $this->mShowBytes = $f; } /** @@ -193,7 +193,7 @@ class ImageGallery * @param $f Boolean: set to false to disable. */ function setShowFilename( $f ) { - $this->mShowFilename = ( $f == true); + $this->mShowFilename = $f; } /** diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 9722be80ed..3812ce1bf8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -39,6 +39,7 @@ class OutputPage { var $mParseWarnings = array(); var $mSquidMaxage = 0; var $mRevisionId = null; + var $mPageIcons = array(); protected $mTitle = null; /** @@ -1079,6 +1080,7 @@ class OutputPage { $this->addCategoryLinks( $parserOutput->getCategories() ); $this->mNewSectionLink = $parserOutput->getNewSection(); $this->mHideNewSectionLink = $parserOutput->getHideNewSection(); + $this->mPageIcons = $parserOutput->getPageIcons(); $this->mParseWarnings = $parserOutput->getWarnings(); if ( !$parserOutput->isCacheable() ) { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index e049f57f23..c5d09b28ac 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -230,6 +230,21 @@ class SkinTemplate extends Skin { $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) ); $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) ); + $icons = ''; + foreach( $out->mPageIcons as $icon ) { + list( $file, $alt ) = $icon; + $fileAttr = array( 'src' => $file->createThumb( 16 ) ); + if( $alt != '' ) { + $msg = wfMsg( $alt ); + if( !wfEmptyMsg( $alt ) ) { + $alt = $msg; + } + $fileAttr['alt'] = htmlspecialchars( $alt ); + } + $icons .= Html::element( 'img', $fileAttr ) . " "; + } + $tpl->set( 'pageicons', $icons ); + $nsname = MWNamespace::exists( $this->mTitle->getNamespace() ) ? MWNamespace::getCanonicalName( $this->mTitle->getNamespace() ) : $this->mTitle->getNsText(); diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index b0f8fc4cfe..c452b17eec 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -698,7 +698,7 @@ Perhaps no page aliases are defined for it?" ); $this->mRestriction = $restriction; $this->mListed = $listed; $this->mIncludable = $includable; - if ( $function == false ) { + if ( !$function ) { $this->mFunction = 'wfSpecial'.$name; } else { $this->mFunction = $function; diff --git a/includes/Title.php b/includes/Title.php index 8bdc1833ff..29a4e70fd8 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -824,7 +824,7 @@ class Title { } // internal links should point to same variant as current page (only anonymous users) - if ( $variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) { + if ( !$variant && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) { $pref = $wgContLang->getPreferredVariant( false ); if ( $pref != $wgContLang->getCode() ) $variant = $pref; @@ -843,7 +843,7 @@ class Title { $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); if ( $query == '' ) { if ( $variant != false && $wgContLang->hasVariants() ) { - if ( $wgVariantArticlePath == false ) { + if ( !$wgVariantArticlePath ) { $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default } else { $variantArticlePath = $wgVariantArticlePath; @@ -1474,7 +1474,7 @@ class Title { $scBlockExpiryOptions = wfMsg( 'ipboptions' ); foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) { - if ( strpos( $option, ':' ) == false ) + if ( !strpos( $option, ':' ) ) continue; list ( $show, $value ) = explode( ":", $option ); diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 0dfa6a99f3..126303cdc3 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -95,7 +95,7 @@ class ApiProtect extends ApiBase { $expiryarray[$p[0]] = Block::infinity(); } else { $exp = strtotime( $expiry[$i] ); - if ( $exp < 0 || $exp == false ) { + if ( $exp < 0 || !$exp ) { $this->dieUsageMsg( array( 'invalidexpiry', $expiry[$i] ) ); } diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index e53c0283e3..2319056d19 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -520,7 +520,7 @@ class DatabaseIbm_db2 extends DatabaseBase { // Rather, turn autocommit off in the begin function and turn on after a commit db2_autocommit($this->mConn, DB2_AUTOCOMMIT_ON); - if ( $this->mConn == false ) { + if ( !$this->mConn ) { $this->installPrint( "DB connection error\n" ); $this->installPrint( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" ); $this->installPrint( $this->lastError()."\n" ); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index bd60bbf88a..bb967fc4b0 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -249,7 +249,7 @@ class DatabaseOracle extends DatabaseBase { $this->mConn = oci_connect( $user, $password, $dbName, $this->defaultCharset, $session_mode ); } - if ( $this->mConn == false ) { + if ( !$this->mConn ) { wfDebug( "DB connection error\n" ); wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" ); wfDebug( $this->lastError() . "\n" ); @@ -310,7 +310,7 @@ class DatabaseOracle extends DatabaseBase { return false; } - if ( oci_execute( $stmt, $this->execFlags() ) == false ) { + if ( !oci_execute( $stmt, $this->execFlags() ) ) { $e = oci_error( $stmt ); if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) { $this->reportQueryError( $e['message'], $e['code'], $sql, __FUNCTION__ ); @@ -1013,7 +1013,7 @@ class DatabaseOracle extends DatabaseBase { // Avoid the non-standard "REPLACE INTO" syntax echo "
  • Populating interwiki table
  • \n"; $f = fopen( "../maintenance/interwiki.sql", 'r' ); - if ( $f == false ) { + if ( !$f ) { dieout( "Could not find the interwiki.sql file" ); } diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index cf62554ad5..e3219069e3 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -181,7 +181,7 @@ class DatabasePostgres extends DatabaseBase { $this->mConn = pg_connect( $connectString ); $phpError = $this->restoreErrorHandler(); - if ( $this->mConn == false ) { + if ( !$this->mConn ) { wfDebug( "DB connection error\n" ); wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" ); wfDebug( $this->lastError()."\n" ); @@ -309,7 +309,7 @@ class DatabasePostgres extends DatabaseBase { $connectVars['password'] = $password; @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) ); - if ( $this->mConn == false ) { + if ( $this->mConn ) { print "FAILED TO CONNECT!"; dieout(""); } @@ -1355,7 +1355,7 @@ SQL; echo "
  • Populating interwiki table... "; ## Avoid the non-standard "REPLACE INTO" syntax $f = fopen( "../maintenance/interwiki.sql", 'r' ); - if ($f == false ) { + if ( $f ) { print "FAILED
  • "; dieout( "Could not find the interwiki.sql file" ); } diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index c149cf04aa..83876b4e9a 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -494,7 +494,7 @@ class DatabaseSqlite extends DatabaseBase { # Use DatabasePostgres's code to populate interwiki from MySQL template $f = fopen( "$IP/maintenance/interwiki.sql", 'r' ); - if ( $f == false ) { + if ( !$f ) { dieout( "Could not find the interwiki.sql file." ); } diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index c3e9884eac..d557711ea7 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -69,6 +69,7 @@ class CoreParserFunctions { $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH ); $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS ); $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) ); + $parser->setFunctionHook( 'pageicon', array( __CLASS__, 'pageicon' ) ); if ( $wgAllowDisplayTitle ) { $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH ); @@ -628,6 +629,14 @@ class CoreParserFunctions { } } + public static function pageicon( $parser, $name = '', $alt = '' ) { + $file = wfFindFile( $name ); + if( $file ) { + $parser->mOutput->addPageIcon( $file, $alt ); + } + return ''; + } + /** * Parser function to extension tag adaptor */ diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 1f390a26e8..b2a774eb25 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -28,7 +28,8 @@ class ParserOutput $mSections = array(), # Table of contents $mProperties = array(), # Name/value pairs to be cached in the DB $mTOCHTML = ''; # HTML of the TOC - private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. + private $mIndexPolicy = '', # 'index' or 'noindex'? Any other value will result in no change. + $mPageIcons = array(); # Array of icons to show for the page (like Protect, Featured, etc) function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(), $containsOldMagic = false, $titletext = '' ) @@ -59,6 +60,7 @@ class ParserOutput function getWarnings() { return array_keys( $this->mWarnings ); } function getIndexPolicy() { return $this->mIndexPolicy; } function getTOCHTML() { return $this->mTOCHTML; } + function getPageIcons() { return $this->mPageIcons; } function containsOldMagic() { return $this->mContainsOldMagic; } function setText( $text ) { return wfSetVar( $this->mText, $text ); } @@ -250,6 +252,15 @@ class ParserOutput } } + /** + * Add page icons to the parser output. + * @param File $file A valid file + * @param String $alt Alt text, if any + */ + function addPageIcon( $file, $alt = '' ) { + $this->mPageIcons[] = array( $file, $alt ); + } + /** * Override the title to be used for display * -- this is assumed to have been validated diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 06f794dc2d..c9835837a5 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -698,7 +698,7 @@ class LanguageConverter { } $variants = $this->autoConvertToAllVariants( $link ); - if ( $variants == false ) { // give up + if ( !$variants ) { // give up return; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ce69a93231..3c396e30d0 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -356,6 +356,7 @@ $magicWords = array( 'url_path' => array( 0, 'PATH' ), 'url_wiki' => array( 0, 'WIKI' ), 'url_query' => array( 0, 'QUERY' ), + 'pageicon' => array( 1, 'pageicon' ), ); /** diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index dc6db59343..8bd0458ec5 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -216,10 +216,10 @@ class RebuildRecentchanges extends Maintenance { $botgroups = $autopatrolgroups = array(); foreach ( $wgGroupPermissions as $group => $rights ) { - if ( isset( $rights['bot'] ) && $rights['bot'] == true ) { + if ( isset( $rights['bot'] ) && $rights['bot'] ) { $botgroups[] = $dbw->addQuotes( $group ); } - if ( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] == true ) { + if ( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] ) { $autopatrolgroups[] = $dbw->addQuotes( $group ); } } diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 018e3d78c5..917c53ae23 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -176,7 +176,7 @@ class RefreshLinks extends Maintenance { $rt = $wgArticle->followRedirect(); - if ( $rt == false || !is_object( $rt ) ) { + if ( !$rt || !is_object( $rt ) ) { // $wgTitle is not a redirect // Delete any redirect table entry for it $dbw->delete( 'redirect', array( 'rd_from' => $id ), diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 99d30eab05..25dde7dc83 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -64,11 +64,9 @@ class RunJobs extends Maintenance { while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) { $offset = 0; for ( ; ; ) { - $job = ( $type == false ) ? - Job::pop( $offset ) - : Job::pop_type( $type ); + $job = !$type ? Job::pop( $offset ) : Job::pop_type( $type ); - if ( $job == false ) + if ( !$job ) break; wfWaitForSlaves( 5 ); -- 2.20.1