} elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
} else {
- if ( $rcObj->unpatrolled && $type == RC_NEW) {
+ if ( $rcObj->unpatrolled && $type == RC_NEW ) {
$params['rcid'] = $rcObj->mAttribs['rc_id'];
}
$out = " <page>\n";
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
$out .= ' ' . Xml::elementClean( 'title', array(), self::canonicalTitle( $title ) ) . "\n";
- $out .= ' ' . Xml::element( 'ns', array(), strval( $row->page_namespace) ) . "\n";
+ $out .= ' ' . Xml::element( 'ns', array(), strval( $row->page_namespace ) ) . "\n";
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
if ( $row->page_is_redirect ) {
$page = WikiPage::factory( $title );
// Suppress annoying useless crap from p7zip
// Unfortunately this could suppress real error messages too
$command .= ' >' . wfGetNull() . ' 2>&1';
- return( $command );
+ return $command;
}
/**
try {
$timestamp = new MWTimestamp( $ts );
return $timestamp->getTimestamp( $outputtype );
- } catch( TimestampException $e ) {
+ } catch ( TimestampException $e ) {
wfDebug( "wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts\n" );
return false;
}
* Compress the bulk data in the object
*/
public function compress() {
- if ( !$this->mCompressed ) {
+ if ( !$this->mCompressed ) {
$this->mItems = gzdeflate( serialize( $this->mItems ) );
$this->mCompressed = true;
}
* @since 1.18
*/
public static function register( $name, $callback ) {
- if( !isset( self::$handlers[$name] ) ) {
+ if ( !isset( self::$handlers[$name] ) ) {
self::$handlers[$name] = array();
}
// Run autoloader (workaround for call_user_func_array bug)
// and throw error if not callable.
- if( !is_callable( $callback ) ) {
+ if ( !is_callable( $callback ) ) {
throw new MWException( 'Invalid callback in hooks for ' . $event . "\n" );
}
if ( $bits == 0 ) {
$network = 0;
} else {
- $network &= ~( ( 1 << ( 32 - $bits ) ) - 1);
+ $network &= ~( ( 1 << ( 32 - $bits ) ) - 1 );
}
# Convert to unsigned
if ( $network < 0 ) {
static function classExists( $class ) {
try {
$r = new ReflectionClass( $class );
- } catch( ReflectionException $r ) {
+ } catch ( ReflectionException $r ) {
$r = false;
}
return $r !== false;
static function methodExists( $class, $method ) {
try {
$r = new ReflectionMethod( $class, $method );
- } catch( ReflectionException $r ) {
+ } catch ( ReflectionException $r ) {
$r = false;
}
return $r !== false;
static function functionExists( $function ) {
try {
$r = new ReflectionFunction( $function );
- } catch( ReflectionException $r ) {
+ } catch ( ReflectionException $r ) {
$r = false;
}
return $r !== false;
*/
static function removeHTMLcomments( $text ) {
wfProfileIn( __METHOD__ );
- while ( ($start = strpos( $text, '<!--' ) ) !== false ) {
+ while ( ( $start = strpos( $text, '<!--' ) ) !== false ) {
$end = strpos( $text, '-->', $start + 4 );
if ( $end === false ) {
# Unterminated comment; bail out
| [\xf8-\xfb][\x80-\xbf]{4}
| \xfc[\x84-\xbf][\x80-\xbf]{4}
)+$/x', $value );
- return ($hasUtf8 > 0 );
+ return ( $hasUtf8 > 0 );
}
}
try {
$final = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
}
}
- $interval = new DateInterval('PT' . abs( $diff ) . 'M');
+ $interval = new DateInterval( 'PT' . abs( $diff ) . 'M' );
if ( $diff < 1 ) {
$interval->invert = 1;
}
*/
public function useNPPatrol() {
global $wgUseRCPatrol, $wgUseNPPatrol;
- return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) );
+ return ( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) );
}
/**
return parent::checkCanExecute( $user );
}
- public static function doWatch( Title $title, User $user ) {
+ public static function doWatch( Title $title, User $user ) {
$page = WikiPage::factory( $title );
if ( wfRunHooks( 'WatchArticle', array( &$user, &$page ) ) ) {
return true;
}
- public static function doUnwatch( Title $title, User $user ) {
+ public static function doUnwatch( Title $title, User $user ) {
$page = WikiPage::factory( $title );
if ( wfRunHooks( 'UnwatchArticle', array( &$user, &$page ) ) ) {
protected function feedItem( $row ) {
$title = Title::makeTitle( intval( $row->page_namespace ), $row->page_title );
- if( $title && $title->userCan( 'read' ) ) {
+ if ( $title && $title->userCan( 'read' ) ) {
$date = $row->rev_timestamp;
$comments = $title->getTalkPage()->getFullURL();
$revision = Revision::newFromRow( $row );
if ( !is_null( $params['mime'] ) ) {
global $wgMiserMode;
- if ( $wgMiserMode ) {
+ if ( $wgMiserMode ) {
$this->dieUsage( 'MIME search disabled in Miser Mode', 'mimesearchdisabled' );
}
* @param $protocol String
* @return null|string
*/
- public function prepareUrlQuerySearchString( $query = null, $protocol = null) {
+ public function prepareUrlQuerySearchString( $query = null, $protocol = null ) {
$db = $this->getDb();
if ( !is_null( $query ) || $query != '' ) {
if ( is_null( $protocol ) ) {
if ( $fld_sortkeyprefix ) {
$vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
}
- if ( $fld_type ) {
+ if ( $fld_type ) {
$vals['type'] = $row->cl_type;
}
if ( $fld_timestamp ) {
}
if ( is_null( $matches ) ) {
$this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" );
- } elseif( $matches instanceof Status && !$matches->isGood() ) {
+ } elseif ( $matches instanceof Status && !$matches->isGood() ) {
$this->dieUsage( $matches->getWikiText(), 'search-error' );
}
return $text;
}
- wfDebug( __METHOD__ . "()\n", false);
+ wfDebug( __METHOD__ . "()\n", false );
$now = wfTimestampNow();
if ( $this->useGzip() ) {
}
try {
$compiledRules = CLDRPluralRuleEvaluator::compile( $rules );
- } catch( CLDRPluralRuleError $e ) {
+ } catch ( CLDRPluralRuleError $e ) {
wfDebugLog( 'l10n', $e->getMessage() . "\n" );
return array();
}
$myModelId = $this->getModel();
$sectionModelId = $with->getModel();
- if ( $sectionModelId != $myModelId ) {
+ if ( $sectionModelId != $myModelId ) {
wfProfileOut( __METHOD__ );
throw new MWException( "Incompatible content model for section: " .
"document uses $myModelId but " .
public function setFlag( $flag ) {
global $wgDebugDBTransactions;
$this->mFlags |= $flag;
- if ( ( $flag & DBO_TRX) & $wgDebugDBTransactions ) {
+ if ( ( $flag & DBO_TRX ) & $wgDebugDBTransactions ) {
wfDebug( "Implicit transactions are now disabled.\n" );
}
}
* @return array
*/
function listTables( $prefix = null, $fname = 'DatabaseMysql::listTables' ) {
- $result = $this->query( "SHOW TABLES", $fname);
+ $result = $this->query( "SHOW TABLES", $fname );
$endArray = array();
function tableNameInternal( $name ) {
$name = $this->tableName( $name );
- return preg_replace( '/.*\.(.*)/', '$1', $name);
+ return preg_replace( '/.*\.(.*)/', '$1', $name );
}
/**
* Return the next in a sequence, save the value for retrieval via insertId()
function __construct( $conf ) {
}
- function newMainLB( $wiki = false) {
+ function newMainLB( $wiki = false ) {
throw new DBAccessError;
}
// Try the master
$dbw =& $this->getMaster( $cluster );
$ret = $dbw->selectField( $this->getTable( $dbw ), 'blob_text', array( 'blob_id' => $id ), __METHOD__ );
- if ( $ret === false) {
+ if ( $ret === false ) {
wfDebugLog( 'ExternalStoreDB', "ExternalStoreDB::fetchBlob master failed to find $cacheID\n" );
}
}
return false;
}
$redir = $this->checkRedirect( $title );
- if ( $redir && $title->getNamespace() == NS_FILE) {
+ if ( $redir && $title->getNamespace() == NS_FILE ) {
$img = $this->newFile( $redir );
if ( !$img ) {
return false;
try {
$text = Http::get( $url . $file, array( 'timeout' => 3 ) );
}
- catch( MWException $e ) {
+ catch ( MWException $e ) {
// Http::get throws with allow_url_fopen = false and no curl extension.
$text = null;
}
try {
$user->setPassword( $this->getVar( '_AdminPassword' ) );
- } catch( PasswordError $pwe ) {
+ } catch ( PasswordError $pwe ) {
return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
}
foreach ( $createHostList as $host ) {
$fullName = $this->buildFullUserName( $dbUser, $host );
if ( !$this->userDefinitelyExists( $dbUser, $host ) ) {
- try{
+ try {
$this->db->begin( __METHOD__ );
$this->db->query( "CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
$this->db->commit( __METHOD__ );
$grantableNames[] = $fullName;
- } catch( DBQueryError $dqe ) {
+ } catch ( DBQueryError $dqe ) {
if ( $this->db->lastErrno() == 1396 /* ER_CANNOT_USER */ ) {
// User (probably) already exists
$this->db->rollback( __METHOD__ );
$this->db->begin( __METHOD__ );
$this->db->query( "GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
$this->db->commit( __METHOD__ );
- } catch( DBQueryError $dqe ) {
+ } catch ( DBQueryError $dqe ) {
$this->db->rollback( __METHOD__ );
$status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getText() );
}
$res = $this->db->selectRow( 'mysql.user', array( 'Host', 'User' ),
array( 'Host' => $host, 'User' => $user ), __METHOD__ );
return (bool)$res;
- } catch( DBQueryError $dqe ) {
+ } catch ( DBQueryError $dqe ) {
return false;
}
* @param $parser
* @return String Html for download link
*/
- public function downloadLinkHook( $text, $attribs, $parser ) {
+ public function downloadLinkHook( $text, $attribs, $parser ) {
$img = Html::element( 'img', array(
'src' => '../skins/common/images/download-32.png',
'width' => '32',
// Hopefully, when leaf jobs are popped, the slaves will have reached that position.
if ( isset( $this->params['masterPos'] ) ) {
$masterPos = $this->params['masterPos'];
- } elseif ( wfGetLB()->getServerCount() > 1 ) {
+ } elseif ( wfGetLB()->getServerCount() > 1 ) {
$masterPos = wfGetLB()->getMasterPos();
} else {
$masterPos = false;
// Paranoia: avoid brute force searches (bug 17342)
$user = $this->getUser();
if ( !$user->isAllowed( 'deletedhistory' ) ) {
- $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION) . ' = 0';
+ $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0';
} elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
- $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION) .
+ $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) .
' != ' . LogPage::SUPPRESSED_ACTION;
}
}
} else {
$image->dejaMetaTree = $tree;
}
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
wfDebug( "Bogus multipage XML metadata on '{$image->getName()}'\n" );
}
wfRestoreWarnings();
function getMetadata( $image, $filename ) {
try {
$parsedGIFMetadata = BitmapMetadataHandler::GIF( $filename );
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
// Broken file?
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
return self::BROKEN_FILE;
function getMetadata( $image, $filename ) {
try {
$metadata = BitmapMetadataHandler::PNG( $filename );
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
// Broken file?
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
return self::BROKEN_FILE;
$metadata = array( 'version' => self::SVG_METADATA_VERSION );
try {
$metadata += SVGMetadataExtractor::getMetadata( $filename );
- } catch( MWException $e ) { // @TODO: SVG specific exceptions
+ } catch ( MWException $e ) { // @TODO: SVG specific exceptions
// File not found, broken, etc.
$metadata['error'] = array(
'message' => $e->getMessage(),
wfSuppressWarnings();
try {
$this->read();
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
// Note, if this happens, the width/height will be taken to be 0x0.
// Should we consider it the default 512x512 instead?
wfRestoreWarnings();
. "/Nbase_type" # /
, $binaryHeader
);
- } catch( MWException $mwe ) {
+ } catch ( MWException $mwe ) {
return false;
}
function _fwrite( $sock, $buf ) {
$bytesWritten = 0;
$bufSize = strlen( $buf );
- while ( $bytesWritten < $bufSize ) {
+ while ( $bytesWritten < $bufSize ) {
$result = fwrite( $sock, $buf );
$data = stream_get_meta_data( $sock );
if ( $data['timed_out'] ) {
return;
}
- $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+ $sock = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
$plength = 0;
$packet = "";
foreach ( $this->mCollated as $entry => $pfdata ) {
* @param array $properties source properties
* @throws MWException
*/
- public function addSource( $id, $properties = null) {
+ public function addSource( $id, $properties = null ) {
// Allow multiple sources to be registered in one call
if ( is_array( $id ) ) {
foreach ( $id as $key => $value ) {
// Preload information needed to the mtime calculation below
try {
$this->preloadModuleInfo( array_keys( $modules ), $context );
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
// Add exception to the output as a comment
$errors .= $this->makeComment( $e->__toString() );
$this->hasErrors = true;
if ( !$good ) {
try { // RL always hits the DB on file cache miss...
wfGetDB( DB_SLAVE );
- } catch( DBConnectionError $e ) { // ...check if we need to fallback to cache
+ } catch ( DBConnectionError $e ) { // ...check if we need to fallback to cache
$good = $fileCache->isCacheGood(); // cache existence check
}
}
function searchText( $term ) {
$q = $this->searchQuery( $term, 'textvector', 'old_text' );
- $olderror = error_reporting(E_ERROR);
+ $olderror = error_reporting( E_ERROR );
$resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
error_reporting( $olderror );
if ( !$resultSet ) {
global $wgLogTypes;
# Get parameters
- $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) );
+ $parms = explode( '/', ( $par = ( $par !== null ) ? $par : '' ) );
$symsForAll = array( '*', 'all' );
if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) {
$opts->setValue( 'type', $par );
$haveRevisions = $dbw->selectField(
'revision',
'rev_timestamp',
- array( 'rev_page' => $this->mTargetID ),
+ array( 'rev_page' => $this->mTargetID ),
__METHOD__,
array( 'FOR UPDATE' )
);
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
if ( $t ) {
- $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
+ $link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
Linker::linkKnown(
$t,
htmlspecialchars( $t->getText() ),
$s->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array()
) .
- ($s->page_is_redirect ? '</div>' : '' );
+ ( $s->page_is_redirect ? '</div>' : '' );
} else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
// Third pass generates sorted XHTML content
foreach ( $m as $text => $type ) {
- $selected = ($type == $pr_type );
+ $selected = ( $type == $pr_type );
$options[] = Xml::option( $text, $type, $selected ) . "\n";
}
}
// Third pass generates sorted XHTML content
foreach ( $m as $text => $type ) {
- $selected = ($type == $pr_level );
+ $selected = ( $type == $pr_level );
$options[] = Xml::option( $text, $type, $selected );
}
$opts->add( 'from', '' );
$opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
- $opts->add( 'hidebots', true );
+ $opts->add( 'hidebots', true );
$opts->add( 'hideanons', false );
$opts->add( 'hideliu', false );
$opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'hidepatrolled' ) );
} else {
return $this->outputLocalFile( $params['file'] );
}
- } catch( UploadStashFileNotFoundException $e ) {
+ } catch ( UploadStashFileNotFoundException $e ) {
$code = 404;
$message = $e->getMessage();
- } catch( UploadStashZeroLengthFileException $e ) {
+ } catch ( UploadStashZeroLengthFileException $e ) {
$code = 500;
$message = $e->getMessage();
- } catch( UploadStashBadPathException $e ) {
+ } catch ( UploadStashBadPathException $e ) {
$code = 500;
$message = $e->getMessage();
- } catch( SpecialUploadStashTooLargeException $e ) {
+ } catch ( SpecialUploadStashTooLargeException $e ) {
$code = 500;
$message = 'Cannot serve a file larger than ' . self::MAX_SERVE_BYTES . ' bytes. ' . $e->getMessage();
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
$code = 500;
$message = $e->getMessage();
}
id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
type="checkbox" value="1"
tabindex="<?php echo $tabIndex++; ?>"
- <?php if ( !empty( $inputItem['value'] ) ) {
+ <?php if ( !empty( $inputItem['value'] ) ) {
echo 'checked="checked"';
} ?>
>
<?php
if ( $this->data['messagetype'] == 'error' ) {
?>
- <strong><?php $this->msg( 'loginerror' )?></strong><br />
+ <strong><?php $this->msg( 'loginerror' ) ?></strong><br />
<?php
}
$this->html( 'message' );