# this breaks strtotime().
$modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
$modsinceTime = strtotime( $modsince );
- $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
+ $ismodsince = wfTimestamp( TS_MW, $modsinceTime ?: 1 );
wfDebug( "$fname: -- client send If-Modified-Since: $modsince", 'private' );
wfDebug( "$fname: -- we might send Last-Modified : $lastmod", 'private' );
$this->autoSumm = md5( '' );
}
- $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
+ $autosumm = $this->autoSumm ?: md5( $this->summary );
$out->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
$out->addHTML( Html::hidden( 'oldid', $this->oldid ) );
if ( $ret === null || !$ret->isSpecialPage() ) {
// We can have urls with just ?diff=,?oldid= or even just ?diff=
$oldid = $request->getInt( 'oldid' );
- $oldid = $oldid ? $oldid : $request->getInt( 'diff' );
+ $oldid = $oldid ?: $request->getInt( 'diff' );
// Allow oldid to override a changed or missing title
if ( $oldid ) {
$rev = Revision::newFromId( $oldid );
// If $target is set, then a hook wanted to redirect.
if ( !$ignoreRedirect && ( $target || $page->isRedirect() ) ) {
// Is the target already set by an extension?
- $target = $target ? $target : $page->followRedirect();
+ $target = $target ?: $page->followRedirect();
if ( is_string( $target ) ) {
if ( !$this->config->get( 'DisableHardRedirects' ) ) {
// we'll need to redirect
// Pre-process information
$separatorTransTable = $lang->separatorTransformTable();
- $separatorTransTable = $separatorTransTable ? $separatorTransTable : [];
+ $separatorTransTable = $separatorTransTable ?: [];
$compactSeparatorTransTable = [
implode( "\t", array_keys( $separatorTransTable ) ),
implode( "\t", $separatorTransTable ),
];
$digitTransTable = $lang->digitTransformTable();
- $digitTransTable = $digitTransTable ? $digitTransTable : [];
+ $digitTransTable = $digitTransTable ?: [];
$compactDigitTransTable = [
implode( "\t", array_keys( $digitTransTable ) ),
implode( "\t", $digitTransTable ),
if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
// If session.auto_start is there, we can't touch session name
if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) {
- session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
+ session_name( $wgSessionName ?: $wgCookiePrefix . '_session' );
}
// Create the SessionManager singleton and set up our session handler,
$res = $dbr->select( $table, $fields, $conds, $comment, [], $joins );
foreach ( $res as $row ) {
- $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default;
+ $this->cache[$row->user_name] = $row->up_value ?: $default;
}
}
// $prevTags can be out of date on replica DBs, especially when addTags is called consecutively,
// causing loss of tags added recently in tag_summary table.
$prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
- $prevTags = $prevTags ? $prevTags : '';
+ $prevTags = $prevTags ?: '';
$prevTags = array_filter( explode( ',', $prevTags ) );
// add tags
}
}
- $image = $image ? $image : false; // type sanity
+ $image = $image ?: false; // type sanity
# Cache file existence or non-existence
if ( $useCache && ( !$image || $image->isCacheable() ) ) {
$this->cache->set( $dbkey, $time, $image );
}
else
{
- $n->setup = $n2 ? $n2 : null;
+ $n->setup = $n2 ?: null;
$this->t->mustMatch(OP_SEMICOLON);
$n->condition = $this->t->peek() == OP_SEMICOLON ? null : $this->Expression($x);
$this->t->mustMatch(OP_SEMICOLON);
{
if ($token = $t->currentToken())
{
- $this->type = $type ? $type : $token->type;
+ $this->type = $type ?: $token->type;
$this->value = $token->value;
$this->lineno = $token->lineno;
$this->start = $token->start;
public function init($source, $filename = '', $lineno = 1)
{
$this->source = $source;
- $this->filename = $filename ? $filename : '[inline]';
+ $this->filename = $filename ?: '[inline]';
$this->lineno = $lineno;
$this->cursor = 0;
$this->lockExpiry = $config['lockExpiry'];
} else {
$met = ini_get( 'max_execution_time' );
- $this->lockExpiry = $met ? $met : 60; // use some sane amount if 0
+ $this->lockExpiry = $met ?: 60; // use some sane amount if 0
}
$this->safeDelay = ( $this->lockExpiry <= 0 )
? 60 // pick a safe-ish number to match DB timeout default
< ( $counters['ctrl'] + $counters['high'] ) * 16
) {
$kindOfBinary = true;
- $type = $binaryType ? $binaryType : $textType;
+ $type = $binaryType ?: $textType;
if ( $type === false ) {
$type = 'application/octet-stream';
}
} else {
$kindOfBinary = false;
- $type = $textType ? $textType : $binaryType;
+ $type = $textType ?: $binaryType;
if ( $type === false ) {
$type = 'text/plain';
}
$this->mOutput->setFlag( 'vary-revision' );
wfDebug( __METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n" );
}
- $value = $pageid ? $pageid : null;
+ $value = $pageid ?: null;
break;
case 'revisionid':
# Let the edit saving system know we should parse the page
$nu = User::newFromName( $target );
$error = self::validateTarget( $nu, $sender );
- return $error ? $error : $nu;
+ return $error ?: $nu;
}
/**
}
public function execute( $par ) {
- $this->mime = $par ? $par : $this->getRequest()->getText( 'mime' );
+ $this->mime = $par ?: $this->getRequest()->getText( 'mime' );
$this->mime = trim( $this->mime );
list( $this->major, $this->minor ) = File::splitMime( $this->mime );
}
// Hardcoded [def] if the language is set to null
- $logOld = $oldLanguage ? $oldLanguage : $defLang . '[def]';
- $logNew = $newLanguage ? $newLanguage : $defLang . '[def]';
+ $logOld = $oldLanguage ?: $defLang . '[def]';
+ $logNew = $newLanguage ?: $defLang . '[def]';
// Writing new page language to database
$dbw->update(
*/
public function getEntryPointInfo() {
global $wgArticlePath, $wgScriptPath;
- $scriptPath = $wgScriptPath ? $wgScriptPath : "/";
+ $scriptPath = $wgScriptPath ?: "/";
$entryPoints = [
'version-entrypoints-articlepath' => $wgArticlePath,
'version-entrypoints-scriptpath' => $scriptPath,
$this->talk = $this->msg( 'talkpagelinktext' )->escaped();
- $this->lang = ( $langObj ? $langObj : $wgContLang );
+ $this->lang = $langObj ?: $wgContLang;
$this->langcode = $this->lang->getCode();
$this->foreign = !$this->lang->equals( $wgContLang );
* @return null|UploadBase
*/
public static function createFromRequest( &$request, $type = null ) {
- $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
+ $type = $type ?: $request->getVal( 'wpSourceType', 'File' );
if ( !$type ) {
return null;
function importRevision( &$revision, &$importer ) {
$id = $revision->getID();
$content = $revision->getContent( Revision::RAW );
- $id = $id ? $id : '';
+ $id = $id ?: '';
if ( $content === null ) {
echo "Revision $id is broken, we have no content available\n";
return htmlspecialchars(
'?' .
wfArrayToCgi( [
- 'filter' => $_filter ? $_filter : $filter,
- 'sort' => $_sort ? $_sort : $sort,
+ 'filter' => $_filter ?: $filter,
+ 'sort' => $_sort ?: $sort,
'expand' => implode( ',', array_keys( $_expand ) )
] )
);
public function __construct() {
global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML, $wgFileExtensions, $wgDjvuTxt;
- $wgDjvuRenderer = $wgDjvuRenderer ? $wgDjvuRenderer : '/usr/bin/ddjvu';
- $wgDjvuDump = $wgDjvuDump ? $wgDjvuDump : '/usr/bin/djvudump';
- $wgDjvuToXML = $wgDjvuToXML ? $wgDjvuToXML : '/usr/bin/djvutoxml';
- $wgDjvuTxt = $wgDjvuTxt ? $wgDjvuTxt : '/usr/bin/djvutxt';
+ $wgDjvuRenderer = $wgDjvuRenderer ?: '/usr/bin/ddjvu';
+ $wgDjvuDump = $wgDjvuDump ?: '/usr/bin/djvudump';
+ $wgDjvuToXML = $wgDjvuToXML ?: '/usr/bin/djvutoxml';
+ $wgDjvuTxt = $wgDjvuTxt ?: '/usr/bin/djvutxt';
if ( !in_array( 'djvu', $wgFileExtensions ) ) {
$wgFileExtensions[] = 'djvu';
$WANObjectCache = null
) {
return new RevisionStore(
- $loadBalancer ? $loadBalancer : $this->getMockLoadBalancer(),
- $blobStore ? $blobStore : $this->getMockSqlBlobStore(),
- $WANObjectCache ? $WANObjectCache : $this->getHashWANObjectCache(),
+ $loadBalancer ?: $this->getMockLoadBalancer(),
+ $blobStore ?: $this->getMockSqlBlobStore(),
+ $WANObjectCache ?: $this->getHashWANObjectCache(),
MediaWikiServices::getInstance()->getCommentStore(),
MediaWikiServices::getInstance()->getActorMigration()
);