From c161c46d26c24643d7fced554ab6e45fb8ec7529 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 17 Feb 2016 20:54:59 +0100 Subject: [PATCH] Improve code suffering from PHP 5.3's lack of support for foo()[] I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored everything involving isset(), unset() or array assigments, then skimmed through the remaining results and changed things where they made sense. These changes were not automated, so please review them. Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538 --- includes/Block.php | 3 +-- includes/EditPage.php | 3 +-- includes/GlobalFunctions.php | 14 +++++------ includes/api/ApiBase.php | 3 +-- includes/api/ApiOpenSearch.php | 3 +-- includes/db/Database.php | 4 ++-- includes/db/DatabaseMssql.php | 3 +-- includes/filebackend/FSFileBackend.php | 4 ++-- includes/installer/Installer.php | 3 +-- includes/jobqueue/JobQueueFederated.php | 14 +++++------ includes/jobqueue/JobRunner.php | 6 ++--- includes/libs/MultiHttpClient.php | 3 +-- includes/libs/RiffExtractor.php | 3 +-- includes/libs/objectcache/MemcachedClient.php | 3 +-- .../RestbaseVirtualRESTService.php | 6 ++--- .../virtualrest/VirtualRESTServiceClient.php | 3 +-- includes/media/ExifBitmap.php | 3 +-- includes/media/GIFMetadataExtractor.php | 24 +++++++------------ includes/media/PNGMetadataExtractor.php | 3 +-- includes/page/Article.php | 3 +-- includes/parser/Parser.php | 6 ++--- includes/search/SearchPostgres.php | 3 +-- includes/skins/SkinTemplate.php | 4 +--- languages/ConverterRule.php | 13 ++++------ languages/Language.php | 3 +-- languages/LanguageConverter.php | 4 ++-- maintenance/tidyUpBug37714.php | 3 +-- tests/testHelpers.inc | 3 +-- 28 files changed, 57 insertions(+), 93 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 696a520ed8..764592d0cd 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1307,8 +1307,7 @@ class Block { # 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 ); diff --git a/includes/EditPage.php b/includes/EditPage.php index b5d0a7b017..32064867d1 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2320,8 +2320,7 @@ class EditPage { # 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 ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index eb174f2e3b..7ed5fba3e2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1949,9 +1949,9 @@ function mimeTypeMatch( $type, $avail ) { 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 { @@ -1977,8 +1977,8 @@ function wfNegotiateType( $cprefs, $sprefs ) { $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]; @@ -1987,8 +1987,8 @@ function wfNegotiateType( $cprefs, $sprefs ) { } 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]; diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index e71cbae22b..f99be4f70e 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -694,8 +694,7 @@ abstract class ApiBase extends ContextSource { * @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 ); } diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 7a7d8f50db..304b2d6ecf 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -338,8 +338,7 @@ class ApiOpenSearch extends ApiBase { return trim( $matches[1] ); } else { // Just return the first line - $lines = explode( "\n", $text ); - return trim( $lines[0] ); + return trim( explode( "\n", $text )[0] ); } } diff --git a/includes/db/Database.php b/includes/db/Database.php index 02a6ec870b..c065ee952a 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1558,8 +1558,8 @@ abstract class DatabaseBase implements IDatabase { // 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 ) . ") "; } diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index a295b0b4d5..ce34537aee 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -301,8 +301,7 @@ class DatabaseMssql extends Database { $res = $res->result; } - $metadata = sqlsrv_field_metadata( $res ); - return $metadata[$n]['Name']; + return sqlsrv_field_metadata( $res )[$n]['Name']; } /** diff --git a/includes/filebackend/FSFileBackend.php b/includes/filebackend/FSFileBackend.php index 86d146d90f..efe78ee24b 100644 --- a/includes/filebackend/FSFileBackend.php +++ b/includes/filebackend/FSFileBackend.php @@ -86,8 +86,8 @@ class FSFileBackend extends FileBackendStore { $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']; } } diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index c076cbabd1..442baf76a0 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -609,8 +609,7 @@ abstract class Installer { # 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; } diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index ecf1a28bb9..c127239360 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -315,14 +315,13 @@ class JobQueueFederated extends JobQueue { } 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 ); } } @@ -331,14 +330,13 @@ class JobQueueFederated extends JobQueue { } 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 ); } } diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index ed29e59c83..c542d97be2 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -289,9 +289,9 @@ class JobRunner implements LoggerAwareInterface { $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 diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index 4e19025bbc..331f2d5e99 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -105,8 +105,7 @@ class MultiHttpClient { * @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']; } /** diff --git a/includes/libs/RiffExtractor.php b/includes/libs/RiffExtractor.php index 3a8b55e21c..304b99b8a4 100644 --- a/includes/libs/RiffExtractor.php +++ b/includes/libs/RiffExtractor.php @@ -94,7 +94,6 @@ class RiffExtractor { * @return int */ public static function extractUInt32( $string ) { - $unpacked = unpack( 'V', $string ); - return $unpacked[1]; + return unpack( 'V', $string )[1]; } }; diff --git a/includes/libs/objectcache/MemcachedClient.php b/includes/libs/objectcache/MemcachedClient.php index ae82ca1bc9..59322b676a 100644 --- a/includes/libs/objectcache/MemcachedClient.php +++ b/includes/libs/objectcache/MemcachedClient.php @@ -791,8 +791,7 @@ class MemcachedClient { * @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] ); diff --git a/includes/libs/virtualrest/RestbaseVirtualRESTService.php b/includes/libs/virtualrest/RestbaseVirtualRESTService.php index d2dd89f809..16c93313f2 100644 --- a/includes/libs/virtualrest/RestbaseVirtualRESTService.php +++ b/includes/libs/virtualrest/RestbaseVirtualRESTService.php @@ -109,10 +109,10 @@ class RestbaseVirtualRESTService extends VirtualRESTService { $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." ); diff --git a/includes/libs/virtualrest/VirtualRESTServiceClient.php b/includes/libs/virtualrest/VirtualRESTServiceClient.php index c64fe34af7..4b8ad5ecc7 100644 --- a/includes/libs/virtualrest/VirtualRESTServiceClient.php +++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php @@ -134,8 +134,7 @@ class VirtualRESTServiceClient { * @return array Response array for request */ public function run( array $req ) { - $responses = $this->runMulti( [ $req ] ); - return $responses[0]; + return $this->runMulti( [ $req ] )[0]; } /** diff --git a/includes/media/ExifBitmap.php b/includes/media/ExifBitmap.php index 6a3809b481..732be3d672 100644 --- a/includes/media/ExifBitmap.php +++ b/includes/media/ExifBitmap.php @@ -34,8 +34,7 @@ class ExifBitmapHandler extends BitmapHandler { 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; } diff --git a/includes/media/GIFMetadataExtractor.php b/includes/media/GIFMetadataExtractor.php index 65a8fdc84a..de409e78e7 100644 --- a/includes/media/GIFMetadataExtractor.php +++ b/includes/media/GIFMetadataExtractor.php @@ -118,8 +118,7 @@ class GIFMetadataExtractor { 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. @@ -131,8 +130,7 @@ class GIFMetadataExtractor { 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 @@ -141,8 +139,7 @@ class GIFMetadataExtractor { 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" ); } @@ -182,8 +179,7 @@ class GIFMetadataExtractor { 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 ) { @@ -206,8 +202,7 @@ class GIFMetadataExtractor { 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; @@ -245,8 +240,7 @@ class GIFMetadataExtractor { 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 ); } } @@ -283,8 +277,7 @@ class GIFMetadataExtractor { 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; @@ -303,8 +296,7 @@ class GIFMetadataExtractor { 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; } diff --git a/includes/media/PNGMetadataExtractor.php b/includes/media/PNGMetadataExtractor.php index 7d59767731..f4f29dd1fb 100644 --- a/includes/media/PNGMetadataExtractor.php +++ b/includes/media/PNGMetadataExtractor.php @@ -105,8 +105,7 @@ class PNGMetadataExtractor { 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" ); diff --git a/includes/page/Article.php b/includes/page/Article.php index 4252f8578e..f6b490ae3d 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1252,8 +1252,7 @@ class Article implements Page { 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 ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 477d1f7d81..d65e8be59f 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3948,8 +3948,7 @@ class Parser { * @return string|bool */ public function fetchTemplate( $title ) { - $rv = $this->fetchTemplateAndTitle( $title ); - return $rv[0]; + return $this->fetchTemplateAndTitle( $title )[0]; } /** @@ -4052,8 +4051,7 @@ class Parser { * @return File|bool */ public function fetchFile( $title, $options = [] ) { - $res = $this->fetchFileAndTitle( $title, $options ); - return $res[0]; + return $this->fetchFileAndTitle( $title, $options )[0]; } /** diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 8da39dbd1b..8ba49b60f9 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -136,8 +136,7 @@ class SearchPostgres extends SearchDatabase { # # 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 diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 1328870da1..134c096c52 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -99,9 +99,7 @@ class SkinTemplate extends Skin { $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 ) { diff --git a/languages/ConverterRule.php b/languages/ConverterRule.php index d66a86a9d5..0d0d90dbc5 100644 --- a/languages/ConverterRule.php +++ b/languages/ConverterRule.php @@ -228,18 +228,14 @@ class ConverterRule { } // 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; @@ -267,8 +263,7 @@ class ConverterRule { 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; diff --git a/languages/Language.php b/languages/Language.php index 506877775d..0bd227621f 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -4303,8 +4303,7 @@ class Language { 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; diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 0be3784e46..81e78b5914 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -992,8 +992,8 @@ class LanguageConverter { $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 ); diff --git a/maintenance/tidyUpBug37714.php b/maintenance/tidyUpBug37714.php index e9c006eac5..f47e13c06d 100644 --- a/maintenance/tidyUpBug37714.php +++ b/maintenance/tidyUpBug37714.php @@ -20,8 +20,7 @@ class TidyUpBug37714 extends Maintenance { ); 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', diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index 0299c26232..76544a50bc 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -661,8 +661,7 @@ class TestFileIterator implements Iterator { ) ); } - $tokens = array_values( $tokens ); - return $tokens[0]; + return array_values( $tokens )[0]; } } -- 2.20.1