# but actually an old subpage (bug #29797)
if ( strpos( $target, '/' ) !== false ) {
# An old subpage, drill down to the user behind it
- $parts = explode( '/', $target );
- $target = $parts[0];
+ $target = explode( '/', $target )[0];
}
$userObj = User::newFromName( $target );
# Show a warning message when someone creates/edits a user (talk) page but the user does not exist
# Show log extract when the user is currently blocked
if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
- $parts = explode( '/', $this->mTitle->getText(), 2 );
- $username = $parts[0];
+ $username = explode( '/', $this->mTitle->getText(), 2 )[0];
$user = User::newFromName( $username, false /* allow IP users*/ );
$ip = User::isIP( $username );
$block = Block::newFromTarget( $user, $user );
if ( array_key_exists( $type, $avail ) ) {
return $type;
} else {
- $parts = explode( '/', $type );
- if ( array_key_exists( $parts[0] . '/*', $avail ) ) {
- return $parts[0] . '/*';
+ $mainType = explode( '/', $type )[0];
+ if ( array_key_exists( "$mainType/*", $avail ) ) {
+ return "$mainType/*";
} elseif ( array_key_exists( '*/*', $avail ) ) {
return '*/*';
} else {
$combine = [];
foreach ( array_keys( $sprefs ) as $type ) {
- $parts = explode( '/', $type );
- if ( $parts[1] != '*' ) {
+ $subType = explode( '/', $type )[1];
+ if ( $subType != '*' ) {
$ckey = mimeTypeMatch( $type, $cprefs );
if ( $ckey ) {
$combine[$type] = $sprefs[$type] * $cprefs[$ckey];
}
foreach ( array_keys( $cprefs ) as $type ) {
- $parts = explode( '/', $type );
- if ( $parts[1] != '*' && !array_key_exists( $type, $sprefs ) ) {
+ $subType = explode( '/', $type )[1];
+ if ( $subType != '*' && !array_key_exists( $type, $sprefs ) ) {
$skey = mimeTypeMatch( $type, $sprefs );
if ( $skey ) {
$combine[$type] = $sprefs[$skey] * $cprefs[$type];
* @return mixed Parameter value
*/
protected function getParameter( $paramName, $parseLimit = true ) {
- $params = $this->getFinalParams();
- $paramSettings = $params[$paramName];
+ $paramSettings = $this->getFinalParams()[$paramName];
return $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit );
}
return trim( $matches[1] );
} else {
// Just return the first line
- $lines = explode( "\n", $text );
- return trim( $lines[0] );
+ return trim( explode( "\n", $text )[0] );
}
}
// Special-case single values, as IN isn't terribly efficient
// Don't necessarily assume the single key is 0; we don't
// enforce linear numeric ordering on other arrays here.
- $value = array_values( $value );
- $list .= $field . " = " . $this->addQuotes( $value[0] );
+ $value = array_values( $value )[0];
+ $list .= $field . " = " . $this->addQuotes( $value );
} else {
$list .= $field . " IN (" . $this->makeList( $value ) . ") ";
}
$res = $res->result;
}
- $metadata = sqlsrv_field_metadata( $res );
- return $metadata[$n]['Name'];
+ return sqlsrv_field_metadata( $res )[$n]['Name'];
}
/**
$this->fileMode = isset( $config['fileMode'] ) ? $config['fileMode'] : 0644;
if ( isset( $config['fileOwner'] ) && function_exists( 'posix_getuid' ) ) {
$this->fileOwner = $config['fileOwner'];
- $info = posix_getpwuid( posix_getuid() );
- $this->currentUser = $info['name']; // cache this, assuming it doesn't change
+ // cache this, assuming it doesn't change
+ $this->currentUser = posix_getpwuid( posix_getuid() )['name'];
}
}
# posix_getegid() *not* getmygid() because we want the group of the webserver,
# not whoever owns the current script.
$gid = posix_getegid();
- $getpwuid = posix_getpwuid( $gid );
- $group = $getpwuid['name'];
+ $group = posix_getpwuid( $gid )['name'];
return $group;
}
}
protected function doIsRootJobOldDuplicate( Job $job ) {
- $params = $job->getRootJobParams();
- $sigature = $params['rootJobSignature'];
- $partition = $this->partitionRing->getLiveLocation( $sigature );
+ $signature = $job->getRootJobParams()['rootJobSignature'];
+ $partition = $this->partitionRing->getLiveLocation( $signature );
try {
return $this->partitionQueues[$partition]->doIsRootJobOldDuplicate( $job );
} catch ( JobQueueError $e ) {
if ( $this->partitionRing->ejectFromLiveRing( $partition, 5 ) ) {
- $partition = $this->partitionRing->getLiveLocation( $sigature );
+ $partition = $this->partitionRing->getLiveLocation( $signature );
return $this->partitionQueues[$partition]->doIsRootJobOldDuplicate( $job );
}
}
}
protected function doDeduplicateRootJob( IJobSpecification $job ) {
- $params = $job->getRootJobParams();
- $sigature = $params['rootJobSignature'];
- $partition = $this->partitionRing->getLiveLocation( $sigature );
+ $signature = $job->getRootJobParams()['rootJobSignature'];
+ $partition = $this->partitionRing->getLiveLocation( $signature );
try {
return $this->partitionQueues[$partition]->doDeduplicateRootJob( $job );
} catch ( JobQueueError $e ) {
if ( $this->partitionRing->ejectFromLiveRing( $partition, 5 ) ) {
- $partition = $this->partitionRing->getLiveLocation( $sigature );
+ $partition = $this->partitionRing->getLiveLocation( $signature );
return $this->partitionQueues[$partition]->doDeduplicateRootJob( $job );
}
}
$stats->timing( "jobqueue.pickup_delay.$jType", 1000 * $pickupDelay );
}
// Record root job age for jobs being run
- $root = $job->getRootJobParams();
- if ( $root['rootJobTimestamp'] ) {
- $age = max( 0, $popTime - wfTimestamp( TS_UNIX, $root['rootJobTimestamp'] ) );
+ $rootTimestamp = $job->getRootJobParams()['rootJobTimestamp'];
+ if ( $rootTimestamp ) {
+ $age = max( 0, $popTime - wfTimestamp( TS_UNIX, $rootTimestamp ) );
$stats->timing( "jobqueue.pickup_root_age.$jType", 1000 * $age );
}
// Track the execution time for jobs
* @return array Response array for request
*/
final public function run( array $req, array $opts = [] ) {
- $req = $this->runMulti( [ $req ], $opts );
- return $req[0]['response'];
+ return $this->runMulti( [ $req ], $opts )[0]['response'];
}
/**
* @return int
*/
public static function extractUInt32( $string ) {
- $unpacked = unpack( 'V', $string );
- return $unpacked[1];
+ return unpack( 'V', $string )[1];
}
};
* @param string $host
*/
function _dead_host( $host ) {
- $parts = explode( ':', $host );
- $ip = $parts[0];
+ $ip = explode( ':', $host )[0];
$this->_host_dead[$ip] = time() + 30 + intval( rand( 0, 10 ) );
$this->_host_dead[$host] = $this->_host_dead[$ip];
unset( $this->_cache_sock[$host] );
$result = [];
foreach ( $reqs as $key => $req ) {
- $parts = explode( '/', $req['url'] );
- if ( $parts[1] === 'v3' ) {
+ $version = explode( '/', $req['url'] )[1];
+ if ( $version === 'v3' ) {
$result[$key] = $this->onParsoid3Request( $req, $idGeneratorFunc );
- } elseif ( $parts[1] === 'v1' ) {
+ } elseif ( $version === 'v1' ) {
$result[$key] = $this->onParsoid1Request( $req, $idGeneratorFunc );
} else {
throw new Exception( "Only v1 and v3 are supported." );
* @return array Response array for request
*/
public function run( array $req ) {
- $responses = $this->runMulti( [ $req ] );
- return $responses[0];
+ return $this->runMulti( [ $req ] )[0];
}
/**
function convertMetadataVersion( $metadata, $version = 1 ) {
// basically flattens arrays.
- $version = explode( ';', $version, 2 );
- $version = intval( $version[0] );
+ $version = intval( explode( ';', $version, 2 )[0] );
if ( $version < 1 || $version >= 2 ) {
return $metadata;
}
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $extension_code = unpack( 'C', $buf );
- $extension_code = $extension_code[1];
+ $extension_code = unpack( 'C', $buf )[1];
if ( $extension_code == 0xF9 ) {
// Graphics Control Extension.
if ( strlen( $buf ) < 2 ) {
throw new Exception( "Ran out of input" );
}
- $delay = unpack( 'v', $buf );
- $delay = $delay[1];
+ $delay = unpack( 'v', $buf )[1];
$duration += $delay * 0.01;
fread( $fh, 1 ); // Transparent colour index
if ( strlen( $term ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $term = unpack( 'C', $term );
- $term = $term[1];
+ $term = unpack( 'C', $term )[1];
if ( $term != 0 ) {
throw new Exception( "Malformed Graphics Control Extension block" );
}
if ( strlen( $blockLength ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $blockLength = unpack( 'C', $blockLength );
- $blockLength = $blockLength[1];
+ $blockLength = unpack( 'C', $blockLength )[1];
$data = fread( $fh, $blockLength );
if ( $blockLength != 11 ) {
if ( strlen( $loopData ) < 2 ) {
throw new Exception( "Ran out of input" );
}
- $loopData = unpack( 'v', $loopData );
- $loopCount = $loopData[1];
+ $loopCount = unpack( 'v', $loopData )[1];
if ( $loopCount != 1 ) {
$isLooped = true;
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $byte = unpack( 'C', $buf );
- $byte = $byte[1];
+ $byte = unpack( 'C', $buf )[1];
throw new Exception( "At position: " . ftell( $fh ) . ", Unknown byte " . $byte );
}
}
if ( strlen( $data ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $buf = unpack( 'C', $data );
- $buf = $buf[1];
+ $buf = unpack( 'C', $data )[1];
$bpp = ( $buf & 7 ) + 1;
$buf >>= 7;
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $block_len = unpack( 'C', $buf );
- $block_len = $block_len[1];
+ $block_len = unpack( 'C', $buf )[1];
if ( $block_len == 0 ) {
return;
}
if ( !$buf || strlen( $buf ) < 4 ) {
throw new Exception( __METHOD__ . ": Read error" );
}
- $chunk_size = unpack( "N", $buf );
- $chunk_size = $chunk_size[1];
+ $chunk_size = unpack( "N", $buf )[1];
if ( $chunk_size < 0 ) {
throw new Exception( __METHOD__ . ": Chunk size too big for unpack" );
if ( $title->getNamespace() == NS_USER
|| $title->getNamespace() == NS_USER_TALK
) {
- $parts = explode( '/', $title->getText() );
- $rootPart = $parts[0];
+ $rootPart = explode( '/', $title->getText() )[0];
$user = User::newFromName( $rootPart, false /* allow IP users*/ );
$ip = User::isIP( $rootPart );
$block = Block::newFromTarget( $user, $user );
* @return string|bool
*/
public function fetchTemplate( $title ) {
- $rv = $this->fetchTemplateAndTitle( $title );
- return $rv[0];
+ return $this->fetchTemplateAndTitle( $title )[0];
}
/**
* @return File|bool
*/
public function fetchFile( $title, $options = [] ) {
- $res = $this->fetchFileAndTitle( $title, $options );
- return $res[0];
+ return $this->fetchFileAndTitle( $title, $options )[0];
}
/**
# # TODO: Better output (example to catch: one 'two)
die( "Sorry, that was not a valid search string. Please go back and try again" );
}
- $top = $res->fetchRow();
- $top = $top[0];
+ $top = $res->fetchRow()[0];
$this->searchTerms = [];
if ( $top === "" ) { # # e.g. if only stopwords are used XXX return something better
$languageLinks = array();
foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
- $languageLinkParts = explode( ':', $languageLinkText, 2 );
- $class = 'interlanguage-link interwiki-' . $languageLinkParts[0];
- unset( $languageLinkParts );
+ $class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
$languageLinkTitle = Title::newFromText( $languageLinkText );
if ( $languageLinkTitle ) {
}
// or display current variant in unidirectional array
if ( $disp === false && array_key_exists( $variant, $unidtable ) ) {
- $disp = array_values( $unidtable[$variant] );
- $disp = $disp[0];
+ $disp = array_values( $unidtable[$variant] )[0];
}
// or display frist text under disable manual convert
if ( $disp === false && $this->mConverter->mManualLevel[$variant] == 'disable' ) {
if ( count( $bidtable ) > 0 ) {
- $disp = array_values( $bidtable );
- $disp = $disp[0];
+ $disp = array_values( $bidtable )[0];
} else {
- $disp = array_values( $unidtable );
- $disp = array_values( $disp[0] );
- $disp = $disp[0];
+ $disp = array_values( array_values( $unidtable )[0] )[0];
}
}
return $disp;
return $disp;
}
if ( array_key_exists( $variant, $this->mUnidtable ) ) {
- $disp = array_values( $this->mUnidtable[$variant] );
- $disp = $disp[0];
+ $disp = array_values( $this->mUnidtable[$variant] )[0];
}
// Assigned above or still false.
return $disp;
return $this->mParentLanguage;
}
- $pieces = explode( '-', $this->getCode() );
- $code = $pieces[0];
+ $code = explode( '-', $this->getCode() )[0];
if ( !in_array( $code, LanguageConverter::$languagesWithVariants ) ) {
$this->mParentLanguage = null;
return null;
$first = false;
continue;
}
- $mappings = explode( '}-', $block, 2 );
- $stripped = str_replace( [ "'", '"', '*', '#' ], '', $mappings[0] );
+ $mappings = explode( '}-', $block, 2 )[0];
+ $stripped = str_replace( [ "'", '"', '*', '#' ], '', $mappings );
$table = StringUtils::explode( ';', $stripped );
foreach ( $table as $t ) {
$m = explode( '=>', $t, 3 );
);
foreach ( $result as $row ) {
- $paramLines = explode( "\n", $row->log_params );
- $ids = explode( ',', $paramLines[0] ); // Array dereferencing is PHP >= 5.4 :(
+ $ids = explode( ',', explode( "\n", $row->log_params )[0] );
$result = $this->getDB( DB_SLAVE )->select( // Work out what log entries were changed here.
'logging',
'log_type',
) );
}
- $tokens = array_values( $tokens );
- return $tokens[0];
+ return array_values( $tokens )[0];
}
}