}
if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
- array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
- {
+ array( 'delete', $this->getTitle()->getPrefixedText() ) )
+ ) {
# Flag to hide all contents of the archived revisions
$suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
*/
function __construct( $address = '', $user = 0, $by = 0, $reason = '',
$timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
- $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' )
- {
+ $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = ''
+ ) {
if ( $timestamp === 0 ) {
$timestamp = wfTimestampNow();
}
// Check for CJK
$firstChar = mb_substr( $string, 0, 1, 'UTF-8' );
- if ( ord( $firstChar ) > 0x7f
- && self::isCjk( utf8ToCodepoint( $firstChar ) ) )
- {
+ if ( ord( $firstChar ) > 0x7f && self::isCjk( utf8ToCodepoint( $firstChar ) ) ) {
return $firstChar;
}
# Ignore some permissions errors when a user is just previewing/viewing diffs
$remove = array();
foreach ( $permErrors as $error ) {
- if ( ( $this->preview || $this->diff ) &&
- ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' ) )
- {
+ if ( ( $this->preview || $this->diff )
+ && ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' )
+ ) {
$remove[] = $error;
}
}
} elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
// Standard preference behavior
return true;
- } elseif ( !$this->mTitle->exists() &&
- isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) &&
- $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
- {
+ } elseif ( !$this->mTitle->exists()
+ && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
+ && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]
+ ) {
// Categories are special
return true;
} else {
$this->watchthis = $request->getCheck( 'wpWatchthis' );
# Don't force edit summaries when a user is editing their own user or talk page
- if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) &&
- $this->mTitle->getText() == $wgUser->getName() )
- {
+ if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK )
+ && $this->mTitle->getText() == $wgUser->getName()
+ ) {
$this->allowBlankSummary = true;
} else {
$this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary' );
// Show the edit conflict page for certain recognized errors from doEdit(),
// but don't show it for errors from extension hooks
$errors = $doEditStatus->getErrorsArray();
- if ( in_array( $errors[0][0], array( 'edit-gone-missing', 'edit-conflict',
- 'edit-already-exists' ) ) )
- {
+ if ( in_array( $errors[0][0],
+ array( 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ) )
+ ) {
$this->isConflict = true;
// Destroys data doEdit() put in $status->value but who cares
$doEditStatus->value = self::AS_END;
|| (
isset( $_SERVER['SCRIPT_NAME'] )
&& substr( $_SERVER['SCRIPT_NAME'], -8 ) == 'load.php'
- ) )
- {
+ )
+ ) {
$cache = true;
} else {
$cache = false;
$args = func_get_args();
array_shift( $args );
$forcontent = true;
- if ( is_array( $wgForceUIMsgAsContentMsg ) &&
- in_array( $key, $wgForceUIMsgAsContentMsg ) )
- {
+ if ( is_array( $wgForceUIMsgAsContentMsg )
+ && in_array( $key, $wgForceUIMsgAsContentMsg )
+ ) {
$forcontent = false;
}
return wfMsgReal( $key, $args, true, $forcontent );
$args = func_get_args();
array_shift( $args );
$forcontent = true;
- if ( is_array( $wgForceUIMsgAsContentMsg ) &&
- in_array( $key, $wgForceUIMsgAsContentMsg ) )
- {
+ if ( is_array( $wgForceUIMsgAsContentMsg )
+ && in_array( $key, $wgForceUIMsgAsContentMsg )
+ ) {
$forcontent = false;
}
return wfMsgReal( $key, $args, true, $forcontent, false );
# @todo FIXME: We may want to blacklist some broken browsers
$m = array();
if ( preg_match(
- '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
- $_SERVER['HTTP_ACCEPT_ENCODING'],
- $m )
- )
- {
+ '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
+ $_SERVER['HTTP_ACCEPT_ENCODING'],
+ $m
+ )
+ ) {
if ( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) {
$result = false;
return $result;
} elseif ( strpos( $selector, '#' ) === 0 ) {
$type = 'ID';
$rawName = substr( $selector, 1 );
- } elseif ( strpos( $selector, '.' ) !== 0 &&
- strpos( $selector, '.' ) !== false )
- {
+ } elseif ( strpos( $selector, '.' ) !== 0 && strpos( $selector, '.' ) !== false ) {
$type = 'TAG_CLASS';
$rawName = $selector;
- } elseif ( strpos( $selector, '[' ) === false
- && strpos( $selector, ']' ) === false )
- {
+ } elseif ( strpos( $selector, '[' ) === false && strpos( $selector, ']' ) === false ) {
$type = 'TAG';
$rawName = $selector;
} else {
// since that is added to the message separately, so
// it can be denoted as the current size being shown.
if ( $size[0] <= $width_orig && $size[1] <= $height_orig
- && $size[0] != $width && $size[1] != $height )
- {
+ && $size[0] != $width && $size[1] != $height
+ ) {
$sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
if ( $sizeLink ) {
$otherSizes[] = $sizeLink;
$lang = $this->getLanguage();
$user = $this->getUser();
if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE, $user )
- && !$file->isDeleted( File::DELETED_FILE ) )
- {
+ && !$file->isDeleted( File::DELETED_FILE )
+ ) {
$params = array(
'width' => '120',
'height' => '120',
*/
public static function linkKnown(
$target, $html = null, $customAttribs = array(),
- $query = array(), $options = array( 'known', 'noclasses' ) )
- {
+ $query = array(), $options = array( 'known', 'noclasses' )
+ ) {
return self::link( $target, $html, $customAttribs, $query, $options );
}
* @return String: HTML for an image, with links, wrappers, etc.
*/
public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
- $handlerParams = array(), $time = false, $query = "", $widthOption = null )
- {
+ $handlerParams = array(), $time = false, $query = "", $widthOption = null
+ ) {
$res = null;
$dummy = new DummyLinker;
if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
* @return mixed
*/
public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
- $align = 'right', $params = array(), $framed = false, $manualthumb = "" )
- {
+ $align = 'right', $params = array(), $framed = false, $manualthumb = ""
+ ) {
$frameParams = array(
'alt' => $alt,
'caption' => $label,
* @return mixed
*/
public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
- $handlerParams = array(), $time = false, $query = "" )
- {
+ $handlerParams = array(), $time = false, $query = ""
+ ) {
global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
$target = Title::newFromText( $linkTarget );
if ( $target ) {
if ( $target->getText() == '' && $target->getInterwiki() === ''
- && !self::$commentLocal && self::$commentContextTitle )
- {
+ && !self::$commentLocal && self::$commentContextTitle
+ ) {
$newTarget = clone ( self::$commentContextTitle );
$newTarget->setFragment( '#' . $target->getFragment() );
$target = $newTarget;
if ( $module instanceof ResourceLoaderModule
&& $module->getOrigin() <= $this->getAllowedModules( $type )
&& ( is_null( $position ) || $module->getPosition() == $position )
- && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) ) )
- {
+ && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) )
+ ) {
$filteredModules[] = $val;
}
}
$minDiff = $tz[1];
$tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
} elseif ( count( $tz ) > 1 && $tz[0] == 'ZoneInfo' &&
- !in_array( $tzOffset, HTMLFormField::flattenOptions( $tzOptions ) ) )
- {
+ !in_array( $tzOffset, HTMLFormField::flattenOptions( $tzOptions ) )
+ ) {
# Timezone offset can vary with DST
$userTZ = timezone_open( $tz[2] );
if ( $userTZ !== false ) {
global $wgLegacyEncoding;
if ( $text !== false && $wgLegacyEncoding
- && !in_array( 'utf-8', $flags ) && !in_array( 'utf8', $flags ) )
- {
+ && !in_array( 'utf-8', $flags ) && !in_array( 'utf8', $flags )
+ ) {
# Old revisions kept around in a legacy encoding?
# Upconvert on demand.
# ("utf8" checked for compatibility with some broken
$wgDeletedDirectory = $wgFileStore['deleted']['directory'];
}
-if ( isset( $wgFooterIcons['copyright'] ) &&
- isset( $wgFooterIcons['copyright']['copyright'] ) &&
- $wgFooterIcons['copyright']['copyright'] === array() )
-{
+if ( isset( $wgFooterIcons['copyright'] )
+ && isset( $wgFooterIcons['copyright']['copyright'] )
+ && $wgFooterIcons['copyright']['copyright'] === array()
+) {
if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
$wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
} elseif ( $wgRightsIcon || $wgRightsText ) {
}
}
-if ( isset( $wgFooterIcons['poweredby'] ) &&
- isset( $wgFooterIcons['poweredby']['mediawiki'] ) &&
- $wgFooterIcons['poweredby']['mediawiki']['src'] === null )
-{
+if ( isset( $wgFooterIcons['poweredby'] )
+ && isset( $wgFooterIcons['poweredby']['mediawiki'] )
+ && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
+) {
$wgFooterIcons['poweredby']['mediawiki']['src'] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
}
return 'unknown/unknown';
}
if ( $wgCheckFileExtensions && $wgStrictFileExtensions
- && !UploadBase::checkFileExtensionList( $extList, $wgFileExtensions ) )
- {
+ && !UploadBase::checkFileExtensionList( $extList, $wgFileExtensions )
+ ) {
return 'unknown/unknown';
}
if ( $wgVerifyMimeType && in_array( strtolower( $type ), $wgMimeTypeBlacklist ) ) {
$url = false;
$matches = array();
- if ( !empty( $wgActionPaths ) &&
- preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
- {
+ if ( !empty( $wgActionPaths )
+ && preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches )
+ ) {
$action = urldecode( $matches[2] );
if ( isset( $wgActionPaths[$action] ) ) {
$query = $matches[1];
}
}
- if ( $url === false &&
- $wgVariantArticlePath &&
- $wgContLang->getCode() === $this->getPageLanguage()->getCode() &&
- $this->getPageLanguage()->hasVariants() &&
- preg_match( '/^variant=([^&]*)$/', $query, $matches ) )
- {
+ if ( $url === false
+ && $wgVariantArticlePath
+ && $wgContLang->getCode() === $this->getPageLanguage()->getCode()
+ && $this->getPageLanguage()->hasVariants()
+ && preg_match( '/^variant=([^&]*)$/', $query, $matches )
+ ) {
$variant = urldecode( $matches[1] );
if ( $this->getPageLanguage()->hasVariant( $variant ) ) {
// Only do the variant replacement if the given variant is a valid
if ( $title_protection['pt_create_perm'] == 'autoconfirmed' ) {
$title_protection['pt_create_perm'] = 'editsemiprotected'; // B/C
}
- if ( $title_protection['pt_create_perm'] == '' ||
- !$user->isAllowed( $title_protection['pt_create_perm'] ) )
- {
+ if ( $title_protection['pt_create_perm'] == ''
+ || !$user->isAllowed( $title_protection['pt_create_perm'] )
+ ) {
$errors[] = array( 'titleprotected', User::whoIs( $title_protection['pt_user'] ), $title_protection['pt_reason'] );
}
}
}
} elseif ( $action == 'delete' ) {
if ( $doExpensiveQueries && $wgDeleteRevisionsLimit
- && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion() )
- {
+ && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion()
+ ) {
$errors[] = array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) );
}
}
# Redundant interwiki prefix to the local wiki
if ( $wgLocalInterwiki !== false
- && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) )
- {
+ && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki )
+ ) {
if ( $dbkey == '' ) {
# Can't have an empty self-link
return false;
// We don't know whether this function was called before
// or after moving the root page, so check both
// $this and $nt
- if ( $oldSubpage->getArticleID() == $this->getArticleID() ||
- $oldSubpage->getArticleID() == $nt->getArticleID() )
- {
+ if ( $oldSubpage->getArticleID() == $this->getArticleID()
+ || $oldSubpage->getArticleID() == $nt->getArticleID()
+ ) {
// When moving a page to a subpage of itself,
// don't move it twice
continue;
// Proxy blocking
if ( !$block instanceof Block && $ip !== null && !$this->isAllowed( 'proxyunbannable' )
- && !in_array( $ip, $wgProxyWhitelist ) )
- {
+ && !in_array( $ip, $wgProxyWhitelist )
+ ) {
// Local list
if ( self::isLocallyBlockedProxy( $ip ) ) {
$block = new Block;
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
$force = '';
- if ( $title->getNamespace() == NS_USER_TALK &&
- $title->getText() == $this->getName() )
- {
+ if ( $title->getNamespace() == NS_USER_TALK && $title->getText() == $this->getName() ) {
$force = 'force';
}
// Some wikis were converted from ISO 8859-1 to UTF-8, the passwords can't be converted
// Check for this with iconv
$cp1252Password = iconv( 'UTF-8', 'WINDOWS-1252//TRANSLIT', $password );
- if ( $cp1252Password != $password &&
- self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId ) )
- {
+ if ( $cp1252Password != $password
+ && self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId )
+ ) {
return true;
}
}
// Send updates to watchers other than the current editor
$userArray = UserArray::newFromIDs( $watchers );
foreach ( $userArray as $watchingUser ) {
- if ( $watchingUser->getOption( 'enotifwatchlistpages' ) &&
- ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) ) &&
- $watchingUser->isEmailConfirmed() &&
- $watchingUser->getID() != $userTalkId )
- {
+ if ( $watchingUser->getOption( 'enotifwatchlistpages' )
+ && ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) )
+ && $watchingUser->isEmailConfirmed()
+ && $watchingUser->getID() != $userTalkId
+ ) {
$this->compose( $watchingUser );
}
}
wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" );
} elseif ( $targetUser->getId() == $editor->getId() ) {
wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" );
- } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) &&
- ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) )
- {
+ } elseif ( $targetUser->getOption( 'enotifusertalkpages' )
+ && ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) )
+ ) {
if ( !$targetUser->isEmailConfirmed() ) {
wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
} elseif ( !wfRunHooks( 'AbortTalkPageEmailNotification', array( $targetUser, $title ) ) ) {
$adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
if ( $wgEnotifRevealEditorAddress
&& ( $this->editor->getEmail() != '' )
- && $this->editor->getOption( 'enotifrevealaddr' ) )
- {
+ && $this->editor->getOption( 'enotifrevealaddr' )
+ ) {
$editorAddress = new MailAddress( $this->editor );
if ( $wgEnotifFromEditor ) {
$this->from = $editorAddress;
$router->add( "$wgScript/$1" );
if ( isset( $_SERVER['SCRIPT_NAME'] )
- && preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] ) )
- {
+ && preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] )
+ ) {
# Check for SCRIPT_NAME, we handle index.php explicitly
# But we do have some other .php files such as img_auth.php
# Don't let root article paths clober the parsing for them
// Check variant links so that interwiki links don't have to worry
// about the possible different language variants
if ( count( $wgContLang->getVariants() ) > 1
- && !is_null( $ret ) && $ret->getArticleID() == 0 )
- {
+ && !is_null( $ret ) && $ret->getArticleID() == 0
+ ) {
$wgContLang->findVariantLink( $title, $ret );
}
}
wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) );
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
- if ( is_null( $title ) || ( $title->getDBkey() == '' && $title->getInterwiki() == '' ) ||
- $title->isSpecial( 'Badtitle' ) )
- {
+ if ( is_null( $title ) || ( $title->getDBkey() == '' && $title->getInterwiki() == '' )
+ || $title->isSpecial( 'Badtitle' )
+ ) {
$this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
wfProfileOut( __METHOD__ );
throw new BadTitleError();
}
// Check for a redirect loop
if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url )
- && $title->isLocal() )
- {
+ && $title->isLocal()
+ ) {
// 301 so google et al report the target as the actual url.
$output->redirect( $url, 301 );
} else {
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
- && ( $request->getVal( 'title' ) === null ||
- $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
+ && ( $request->getVal( 'title' ) === null
+ || $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
&& !count( $request->getValueNames( array( 'action', 'title' ) ) )
- && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) )
- {
+ && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) )
+ ) {
if ( $title->isSpecialPage() ) {
list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
if ( $name ) {
$action = $request->getVal( 'action', 'view' );
$file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
- && !$request->getVal( 'oldid' ) && // ... and are not old revisions
- !$request->getVal( 'diff' ) && // ... and not when showing diff
- $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
+ && !$request->getVal( 'oldid' ) // ... and are not old revisions
+ && !$request->getVal( 'diff' ) // ... and not when showing diff
+ && $request->getVal( 'redirect' ) != 'no' // ... unless explicitly told not to
// ... and the article is not a non-redirect image page with associated file
- !( is_object( $file ) && $file->exists() && !$file->getRedirected() ) )
- {
+ && !( is_object( $file ) && $file->exists() && !$file->getRedirected() )
+ ) {
// Give extensions a change to ignore/handle redirects as needed
$ignoreRedirect = $target = false;
$user = $this->context->getUser();
if ( !wfRunHooks( 'MediaWikiPerformAction',
- array( $output, $page, $title, $user, $request, $this ) ) )
- {
+ array( $output, $page, $title, $user, $request, $this ) )
+ ) {
wfProfileOut( __METHOD__ );
return;
}
* @return HTML string
*/
public static function actionText( $type, $action, $title = null, $skin = null,
- $params = array(), $filterWikilinks = false )
- {
+ $params = array(), $filterWikilinks = false
+ ) {
global $wgLang, $wgContLang, $wgLogActions;
if ( is_null( $skin ) ) {
$index['log_search'] = 'ls_field_val';
$index['logging'] = 'PRIMARY';
if ( !$this->hasEqualsClause( 'ls_field' )
- || !$this->hasEqualsClause( 'ls_value' ) )
- {
+ || !$this->hasEqualsClause( 'ls_value' )
+ ) {
# Since (ls_field,ls_value,ls_logid) is unique, if the condition is
# to match a specific (ls_field,ls_value) tuple, then there will be
# no duplicate log rows. Otherwise, we need to remove the duplicates.
public function getActionLinks() {
if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
|| $this->entry->getSubtype() !== 'move'
- || !$this->context->getUser()->isAllowed( 'move' ) )
- {
+ || !$this->context->getUser()->isAllowed( 'move' )
+ ) {
return '';
}
wfSuppressWarnings();
$exif = unserialize( $metadata );
wfRestoreWarnings();
- if ( !isset( $exif['MEDIAWIKI_EXIF_VERSION'] ) ||
- $exif['MEDIAWIKI_EXIF_VERSION'] != Exif::version() )
- {
- if ( isset( $exif['MEDIAWIKI_EXIF_VERSION'] ) &&
- $exif['MEDIAWIKI_EXIF_VERSION'] == 1 )
- {
+ if ( !isset( $exif['MEDIAWIKI_EXIF_VERSION'] )
+ || $exif['MEDIAWIKI_EXIF_VERSION'] != Exif::version()
+ ) {
+ if ( isset( $exif['MEDIAWIKI_EXIF_VERSION'] )
+ && $exif['MEDIAWIKI_EXIF_VERSION'] == 1
+ ) {
//back-compatible but old
wfDebug( __METHOD__ . ": back-compat version\n" );
return self::METADATA_COMPATIBLE;
public function getCommonMetaArray( File $file ) {
$metadata = $file->getMetadata();
- if ( $metadata === self::OLD_BROKEN_FILE ||
- $metadata === self::BROKEN_FILE ||
- $this->isMetadataValid( $file, $metadata ) === self::METADATA_BAD )
- {
+ if ( $metadata === self::OLD_BROKEN_FILE
+ || $metadata === self::BROKEN_FILE
+ || $this->isMetadataValid( $file, $metadata ) === self::METADATA_BAD
+ ) {
// So we don't try and display metadata from PagedTiffHandler
// for example when using InstantCommons.
return array();
$commentCount = count( $comment );
if ( $commentCount === 0
- || $comment[$commentCount - 1] !== $data )
- {
+ || $comment[$commentCount - 1] !== $data
+ ) {
// Some applications repeat the same comment on each
// frame of an animated GIF image, so if this comment
// is identical to the last, only extract once.
$xmp = self::readBlock( $fh, true );
if ( substr( $xmp, -257, 3 ) !== "\x01\xFF\xFE"
- || substr( $xmp, -4 ) !== "\x03\x02\x01\x00" )
- {
+ || substr( $xmp, -4 ) !== "\x03\x02\x01\x00"
+ ) {
// this is just a sanity check.
throw new Exception( "XMP does not have magic trailer!" );
}
foreach ( $codes as $ic ) {
$fields = explode( ':', $ic, 3 );
- if ( count( $fields ) < 2 ||
- $fields[0] !== 'IPTC' )
- {
+ if ( count( $fields ) < 2 || $fields[0] !== 'IPTC' ) {
wfDebugLog( 'IPTC', 'IPTC: '
. 'Invalid 2:12 - ' . $ic );
break;
function endElement( $parser, $elm ) {
if ( $elm === ( self::NS_RDF . ' RDF' )
|| $elm === 'adobe:ns:meta/ xmpmeta'
- || $elm === 'adobe:ns:meta/ xapmeta' )
- {
+ || $elm === 'adobe:ns:meta/ xapmeta'
+ ) {
// ignore these.
return;
}
if ( isset( $this->items[$ns][$tag] ) ) {
if ( isset( $this->items[$ns][$this->ancestorStruct]['children'] )
- && !isset( $this->items[$ns][$this->ancestorStruct]['children'][$tag] ) )
- {
+ && !isset( $this->items[$ns][$this->ancestorStruct]['children'][$tag] )
+ ) {
// This assumes that we don't have inter-namespace nesting
// which we don't in all the properties we're interested in.
throw new MWException( " <$tag> appeared nested in <" . $this->ancestorStruct
throw new MWException( __METHOD__ . " <rdf:li> expected but got $elm." );
}
if ( !isset( $attribs[self::NS_XML . ' lang'] )
- || !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $attribs[self::NS_XML . ' lang'] ) )
- {
+ || !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $attribs[self::NS_XML . ' lang'] )
+ ) {
throw new MWException( __METHOD__
. " <rdf:li> did not contain, or has invalid xml:lang attribute in lang alternative" );
}
if ( $elm === self::NS_RDF . ' RDF'
|| $elm === 'adobe:ns:meta/ xmpmeta'
- || $elm === 'adobe:ns:meta/ xapmeta' )
- {
+ || $elm === 'adobe:ns:meta/ xapmeta'
+ ) {
/* ignore. */
return;
} elseif ( $elm === self::NS_RDF . ' Description' ) {
if ( isset( $attribs[self::NS_RDF . ' parseType'] )
&& $attribs[self::NS_RDF . ' parseType'] === 'Resource'
- && $this->mode[0] === self::MODE_SIMPLE )
- {
+ && $this->mode[0] === self::MODE_SIMPLE
+ ) {
// this is equivalent to having an inner rdf:Description
$this->mode[0] = self::MODE_QDESC;
}
$len = strlen( $val );
- if ( $this->_have_zlib && $this->_compress_enable &&
- $this->_compress_threshold && $len >= $this->_compress_threshold )
- {
+ if ( $this->_have_zlib && $this->_compress_enable
+ && $this->_compress_threshold && $len >= $this->_compress_threshold
+ ) {
$c_val = gzcompress( $val, 9 );
$c_len = strlen( $c_val );
# Don't keep timing out trying to connect for each call if the DB is down
if ( isset( $this->connFailureErrors[$serverIndex] )
- && ( time() - $this->connFailureTimes[$serverIndex] ) < 60 )
- {
+ && ( time() - $this->connFailureTimes[$serverIndex] ) < 60
+ ) {
throw $this->connFailureErrors[$serverIndex];
}
for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) {
$db = $this->getDB( $serverIndex );
if ( $db->getType() !== 'mysql'
- || version_compare( $db->getServerVersion(), '4.1.0', '<' ) )
- {
+ || version_compare( $db->getServerVersion(), '4.1.0', '<' )
+ ) {
throw new MWException( __METHOD__ . ' is not supported on this DB server' );
}
$pos = 0;
while ( $pos < strlen( $text ) ) {
if ( !preg_match( '/<!--LINK (\d+):(\d+)-->/',
- $text, $m, PREG_OFFSET_CAPTURE, $pos ) )
- {
+ $text, $m, PREG_OFFSET_CAPTURE, $pos )
+ ) {
break;
}
$ns = $m[1][0];
* d) it is an interface message (which is in the user language)
*/
if ( !( $options->getDisableContentConversion()
- || isset( $this->mDoubleUnderscores['nocontentconvert'] ) ) )
- {
+ || isset( $this->mDoubleUnderscores['nocontentconvert'] ) )
+ ) {
if ( !$this->mOptions->getInterfaceMessage() ) {
# The position of the convert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
* automatic link conversion.
*/
if ( !( $options->getDisableTitleConversion()
- || isset( $this->mDoubleUnderscores['nocontentconvert'] )
- || isset( $this->mDoubleUnderscores['notitleconvert'] )
- || $this->mOutput->getDisplayTitle() !== false ) )
- {
+ || isset( $this->mDoubleUnderscores['nocontentconvert'] )
+ || isset( $this->mDoubleUnderscores['notitleconvert'] )
+ || $this->mOutput->getDisplayTitle() !== false )
+ ) {
$convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
if ( $convruletitle ) {
$this->mOutput->setTitleText( $convruletitle );
public static function getExternalLinkRel( $url = false, $title = null ) {
global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions;
$ns = $title ? $title->getNamespace() : false;
- if ( $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions ) &&
- !wfMatchesDomainList( $url, $wgNoFollowDomainExceptions ) )
- {
+ if ( $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions )
+ && !wfMatchesDomainList( $url, $wgNoFollowDomainExceptions )
+ ) {
return 'nofollow';
}
return null;
# Still some problems for cases where the ] is meant to be outside punctuation,
# and no image is in sight. See bug 2095.
#
- if ( $text !== '' &&
- substr( $m[3], 0, 1 ) === ']' &&
- strpos( $text, '[' ) !== false
- )
- {
+ if ( $text !== ''
+ && substr( $m[3], 0, 1 ) === ']'
+ && strpos( $text, '[' ) !== false
+ ) {
$text .= ']'; # so that replaceExternalLinks($text) works later
$m[3] = substr( $m[3], 1 );
}
if ( !$title->isExternal() ) {
if ( $title->isSpecialPage()
&& $this->mOptions->getAllowSpecialInclusion()
- && $this->ot['html'] )
- {
+ && $this->ot['html']
+ ) {
// Pass the template arguments as URL parameters.
// "uselang" will have no effect since the Language object
// is forced to the one defined in ParserOptions.
$text = wfEscapeWikiText( $text );
} elseif ( is_string( $text )
&& !$piece['lineStart']
- && preg_match( '/^(?:{\\||:|;|#|\*)/', $text ) )
- {
+ && preg_match( '/^(?:{\\||:|;|#|\*)/', $text )
+ ) {
# Bug 529: if the template begins with a table or block-level
# element, it should be treated as beginning a new line.
# This behavior is somewhat controversial.
const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
- $containsOldMagic = false, $titletext = '' )
- {
+ $containsOldMagic = false, $titletext = ''
+ ) {
$this->mText = $text;
$this->mLanguageLinks = $languageLinks;
$this->mCategories = $categoryLinks;
// the overall start. That's not how Sanitizer::removeHTMLcomments() did it, but
// it's a possible beneficial b/c break.
if ( $wsStart > 0 && substr( $text, $wsStart - 1, 1 ) == "\n"
- && substr( $text, $wsEnd + 1, 1 ) == "\n" )
- {
+ && substr( $text, $wsEnd + 1, 1 ) == "\n"
+ ) {
// Remove leading whitespace from the end of the accumulator
// Sanity check first though
$wsLength = $i - $wsStart;
if ( $wsLength > 0
- && strspn( $accum, " \t", -$wsLength ) === $wsLength )
- {
+ && strspn( $accum, " \t", -$wsLength ) === $wsLength
+ ) {
$accum = substr( $accum, 0, -$wsLength );
}
$attrEnd = $tagEndPos;
// Find closing tag
if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
- $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 ) )
- {
+ $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 )
+ ) {
$inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
$i = $matches[0][1] + strlen( $matches[0][0] );
$close = '<close>' . htmlspecialchars( $matches[0][0] ) . '</close>';
# Remove it in HTML, pre+remove and STRIP_COMMENTS modes
if ( $this->parser->ot['html']
|| ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() )
- || ( $flags & PPFrame::STRIP_COMMENTS ) )
- {
+ || ( $flags & PPFrame::STRIP_COMMENTS )
+ ) {
$out .= '';
}
# Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
// the overall start. That's not how Sanitizer::removeHTMLcomments() did it, but
// it's a possible beneficial b/c break.
if ( $wsStart > 0 && substr( $text, $wsStart - 1, 1 ) == "\n"
- && substr( $text, $wsEnd + 1, 1 ) == "\n" )
- {
+ && substr( $text, $wsEnd + 1, 1 ) == "\n"
+ ) {
// Remove leading whitespace from the end of the accumulator
// Sanity check first though
$wsLength = $i - $wsStart;
if ( $wsLength > 0
&& $accum->lastNode instanceof PPNode_Hash_Text
- && strspn( $accum->lastNode->value, " \t", -$wsLength ) === $wsLength )
- {
+ && strspn( $accum->lastNode->value, " \t", -$wsLength ) === $wsLength
+ ) {
$accum->lastNode->value = substr( $accum->lastNode->value, 0, -$wsLength );
}
$attrEnd = $tagEndPos;
// Find closing tag
if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
- $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 ) )
- {
+ $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 )
+ ) {
$inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
$i = $matches[0][1] + strlen( $matches[0][0] );
$close = $matches[0][0];
# Remove it in HTML, pre+remove and STRIP_COMMENTS modes
if ( $this->parser->ot['html']
|| ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() )
- || ( $flags & PPFrame::STRIP_COMMENTS ) )
- {
+ || ( $flags & PPFrame::STRIP_COMMENTS )
+ ) {
$out .= '';
}
# Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
if ( $child->name === 'name' ) {
$bits['name'] = $child;
if ( $child->firstChild instanceof PPNode_Hash_Attr
- && $child->firstChild->name === 'index' )
- {
+ && $child->firstChild->name === 'index'
+ ) {
$bits['index'] = $child->firstChild->value;
}
} elseif ( $child->name === 'value' ) {
return; // short-circuit
// @TODO: hardcoded check is a tad janky (what about FOR UPDATE?)
} elseif ( !preg_match( '/^query-m: (?!SELECT)/', $method )
- && $realtime < $this->mDBLockThreshold )
- {
+ && $realtime < $this->mDBLockThreshold
+ ) {
return; // not a DB master query nor slow enough
}
$now = microtime( true );
// For empty/whitespace-only data or for unknown filters, don't perform
// any caching or processing
- if ( trim( $data ) === ''
- || !in_array( $filter, array( 'minify-js', 'minify-css' ) ) )
- {
+ if ( trim( $data ) === '' || !in_array( $filter, array( 'minify-js', 'minify-css' ) ) ) {
wfProfileOut( __METHOD__ );
return $data;
}
return $list[$key];
} elseif ( is_string( $fallback )
&& isset( $list[$fallback] )
- && is_array( $list[$fallback] ) )
- {
+ && is_array( $list[$fallback] )
+ ) {
return $list[$fallback];
}
return array();
if ( $request->getVal( 'fulltext' )
|| !is_null( $request->getVal( 'offset' ) )
- || !is_null( $request->getVal( 'searchx' ) ) )
- {
+ || !is_null( $request->getVal( 'searchx' ) )
+ ) {
$this->showResults( $search );
} else {
$this->goResult( $search );
# mDestWarningAck is set when some javascript has shown the warning
# to the user. mForReUpload is set when the user clicks the "upload a
# new version" link.
- if ( !$warnings || ( count( $warnings ) == 1 &&
- isset( $warnings['exists'] ) &&
- ( $this->mDestWarningAck || $this->mForReUpload ) ) )
- {
+ if ( !$warnings || ( count( $warnings ) == 1
+ && isset( $warnings['exists'] )
+ && ( $this->mDestWarningAck || $this->mForReUpload ) )
+ ) {
return false;
}
wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults );
}
- if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
- $request->wasPosted() )
- {
+ if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' )
+ && $request->wasPosted()
+ ) {
$user->clearAllNotifications();
$output->redirect( $this->getTitle()->getFullURL( $nondefaults ) );
return;
$error = '';
if ( !wfRunHooks( 'UploadVerification',
- array( $this->mDestName, $this->mTempPath, &$error ) ) )
- {
+ array( $this->mDestName, $this->mTempPath, &$error ) )
+ ) {
wfProfileOut( __METHOD__ );
return array( 'status' => self::HOOK_ABORTED, 'error' => $error );
}
protected static function newFromCode( $code ) {
// Protect against path traversal below
if ( !Language::isValidCode( $code )
- || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
- {
+ || strcspn( $code, ":/\\\000" ) !== strlen( $code )
+ ) {
throw new MWException( "Invalid language code \"$code\"" );
}
if (
( $zy > 1582 ) || ( ( $zy == 1582 ) && ( $zm > 10 ) ) ||
( ( $zy == 1582 ) && ( $zm == 10 ) && ( $zd > 14 ) )
- )
- {
+ ) {
$zjd = (int)( ( 1461 * ( $zy + 4800 + (int)( ( $zm - 14 ) / 12 ) ) ) / 4 ) +
(int)( ( 367 * ( $zm - 2 - 12 * ( (int)( ( $zm - 14 ) / 12 ) ) ) ) / 12 ) -
(int)( ( 3 * (int)( ( ( $zy + 4900 + (int)( ( $zm - 14 ) / 12 ) ) / 100 ) ) ) / 4 ) +
( ( $gy > 1912 ) && ( $gy < 1926 ) ) ||
( ( $gy == 1926 ) && ( $gm < 12 ) ) ||
( ( $gy == 1926 ) && ( $gm == 12 ) && ( $gd < 26 ) )
- )
- {
+ ) {
# Taishō period
$gy_gannen = $gy - 1912 + 1;
$gy_offset = $gy_gannen;
( ( $gy == 1926 ) && ( $gm == 12 ) && ( $gd >= 26 ) ) ||
( ( $gy > 1926 ) && ( $gy < 1989 ) ) ||
( ( $gy == 1989 ) && ( $gm == 1 ) && ( $gd < 8 ) )
- )
- {
+ ) {
# Shōwa period
$gy_gannen = $gy - 1926 + 1;
$gy_offset = $gy_gannen;
public static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) {
// Protect against path traversal
if ( !Language::isValidCode( $code )
- || strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
- {
+ || strcspn( $code, ":/\\\000" ) !== strlen( $code )
+ ) {
throw new MWException( "Invalid language code \"$code\"" );
}
$startPos = $elementPos + strlen( $element );
// Translate any alt or title attributes inside the matched element
- if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element,
- $elementMatches ) )
- {
+ if ( $element !== ''
+ && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element, $elementMatches )
+ ) {
$attrs = Sanitizer::decodeTagAttributes( $elementMatches[2] );
$changed = false;
foreach ( array( 'title', 'alt' ) as $attrName ) {
}
/* for unidirectional array fill to convert tables */
if ( ( $manLevel[$v] == 'bidirectional' || $manLevel[$v] == 'unidirectional' )
- && isset( $unidtable[$v] ) )
- {
+ && isset( $unidtable[$v] )
+ ) {
if ( isset( $this->mConvTable[$v] ) ) {
$this->mConvTable[$v] = array_merge( $this->mConvTable[$v], $unidtable[$v] );
} else {
foreach ( $this->parts as $part ) {
if ( is_array( $part ) ) {
if ( ( !$integerConstraint || floor( $number ) === (float)$number )
- && $number >= $part[0] && $number <= $part[1] )
- {
+ && $number >= $part[0] && $number <= $part[1]
+ ) {
return true;
}
} else {
// Look ahead one word
$nextTokenPos += strspn( $this->rule, self::WHITESPACE_CLASS, $nextTokenPos );
if ( $nextTokenPos < $this->end
- && preg_match( self::WORD_REGEX, $this->rule, $m, 0, $nextTokenPos ) )
- {
+ && preg_match( self::WORD_REGEX, $this->rule, $m, 0, $nextTokenPos )
+ ) {
$word2 = strtolower( $m[0] );
$nextTokenPos += strlen( $word2 );
}
$db = $this->getDB( DB_MASTER );
$key = $this->getUpdateKey();
- if ( !$this->hasOption( 'force' ) &&
- $db->selectRow( 'updatelog', '1', array( 'ul_key' => $key ), __METHOD__ ) )
- {
+ if ( !$this->hasOption( 'force' )
+ && $db->selectRow( 'updatelog', '1', array( 'ul_key' => $key ), __METHOD__ )
+ ) {
$this->output( "..." . $this->updateSkippedMessage() . "\n" );
return true;
}
return false;
}
- if (
- $db->insert( 'updatelog', array( 'ul_key' => $key ), __METHOD__, 'IGNORE' ) )
- {
+ if ( $db->insert( 'updatelog', array( 'ul_key' => $key ), __METHOD__, 'IGNORE' ) ) {
return true;
} else {
$this->output( $this->updatelogFailedMessage() . "\n" );
$this->error( "$wikiId: Detected illegal (non-UTF8) path for $srcPath." );
continue;
} elseif ( !$this->hasOption( 'missingonly' )
- && $this->filesAreSame( $src, $dst, $srcPath, $dstPath ) )
- {
+ && $this->filesAreSame( $src, $dst, $srcPath, $dstPath )
+ ) {
$this->output( "\tAlready have $srcPathRel.\n" );
continue; // assume already copied...
}
require $maintenance->loadSettings();
}
-if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
- is_readable( "$IP/AdminSettings.php" ) )
-{
+if ( $maintenance->getDbType() === Maintenance::DB_ADMIN
+ && is_readable( "$IP/AdminSettings.php" )
+) {
require "$IP/AdminSettings.php";
}
$this->printArray( 'Documented and not found', $deprecated );
$this->printArray( 'Unclear hook calls', $bad );
- if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 )
- {
+ if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 ) {
$this->output( "Looks good!\n" );
}
}
// Sanity check the file extension against known cache types
if ( $mts < $this->minSurviveTimestamp
&& preg_match( '/\.(?:html|cache)(?:\.gz)?$/', $file )
- && unlink( $path ) )
- {
+ && unlink( $path )
+ ) {
$daysOld = round( ( $tsNow - $mts ) / 86400, 2 );
$this->output( "Deleted `$path` [days=$daysOld]\n" );
}
}
if ( !$this->dryrun ) {
$file = wfLocalFile( $filename );
- if ( !$file->recordUpload( '', '(recovered file, missing upload log entry)', '', '', '',
- false, $timestamp ) )
- {
+ if ( !$file->recordUpload(
+ '',
+ '(recovered file, missing upload log entry)',
+ '',
+ '',
+ '',
+ false,
+ $timestamp
+ )
+ ) {
$this->output( "Error uploading file $fullpath\n" );
return;
}
* @return bool
*/
private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
- $endDate, $extdb = "", $maxPageId = false )
- {
+ $endDate, $extdb = "", $maxPageId = false
+ ) {
$loadStyle = self::LS_CHUNKED;
$dbr = wfGetDB( DB_SLAVE );
$totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ );
if ( $dbr->getType() == 'mysql'
- && version_compare( $dbr->getServerVersion(), '4.1.0', '>=' ) )
- {
+ && version_compare( $dbr->getServerVersion(), '4.1.0', '>=' )
+ ) {
// In MySQL 4.1+, the binary field old_text has a non-working LOWER() function
$lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))';
} else {