From c2720d56865fb62e7044620b2d18ac71815c2dc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Sat, 2 Sep 2017 20:01:44 +0200 Subject: [PATCH] Drop compatibility with PHP 5.3 Since 5.4, $this works inside closures. Change-Id: I6987f76a1e33d6d7ab020a57186e5477186bbf2e --- includes/filerepo/LocalRepo.php | 7 +++---- includes/filerepo/file/File.php | 5 ++--- includes/page/WikiPage.php | 5 ++--- includes/skins/Skin.php | 7 +++---- .../changes/ChangesListStringOptionsFilterGroupTest.php | 6 ++---- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 20d51c254a..ed00793508 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -274,14 +274,13 @@ class LocalRepo extends FileRepo { ); }; - $that = $this; $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles ) - use ( $that, $fileMatchesSearch, $flags ) + use ( $fileMatchesSearch, $flags ) { global $wgContLang; - $info = $that->getInfo(); + $info = $this->getInfo(); foreach ( $res as $row ) { - $file = $that->newFileFromRow( $row ); + $file = $this->newFileFromRow( $row ); // There must have been a search for this DB key, but this has to handle the // cases were title capitalization is different on the client and repo wikis. $dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ]; diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 460fe51e3f..4ea097369f 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1282,11 +1282,10 @@ abstract class File implements IDBAccessObject { // Thumbnailing a very large file could result in network saturation if // everyone does it at once. if ( $this->getSize() >= 1e7 ) { // 10MB - $that = $this; $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ), [ - 'doWork' => function () use ( $that ) { - return $that->getLocalRefPath(); + 'doWork' => function () { + return $this->getLocalRefPath(); } ] ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 5f6e455e1f..5a0670ca8f 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -878,11 +878,10 @@ class WikiPage implements Page, IDBAccessObject { } // Update the DB post-send if the page has not cached since now - $that = $this; $latest = $this->getLatest(); DeferredUpdates::addCallableUpdate( - function () use ( $that, $retval, $latest ) { - $that->insertRedirectEntry( $retval, $latest ); + function () use ( $retval, $latest ) { + $this->insertRedirectEntry( $retval, $latest ); }, DeferredUpdates::POSTSEND, wfGetDB( DB_MASTER ) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index e1d0034675..df7a9edede 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1251,11 +1251,10 @@ abstract class Skin extends ContextSource { function buildSidebar() { global $wgEnableSidebarCache, $wgSidebarCacheExpiry; - $that = $this; - $callback = function () use ( $that ) { + $callback = function () { $bar = []; - $that->addToSidebar( $bar, 'sidebar' ); - Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] ); + $this->addToSidebar( $bar, 'sidebar' ); + Hooks::run( 'SkinBuildSidebar', [ $this, &$bar ] ); return $bar; }; diff --git a/tests/phpunit/includes/changes/ChangesListStringOptionsFilterGroupTest.php b/tests/phpunit/includes/changes/ChangesListStringOptionsFilterGroupTest.php index 04b7ee00b8..4f917e9d46 100644 --- a/tests/phpunit/includes/changes/ChangesListStringOptionsFilterGroupTest.php +++ b/tests/phpunit/includes/changes/ChangesListStringOptionsFilterGroupTest.php @@ -40,8 +40,6 @@ class ChangesListStringOptionsFilterGroupTest extends MediaWikiTestCase { * @dataProvider provideModifyQuery */ public function testModifyQuery( $filterDefinitions, $expectedValues, $input ) { - $self = $this; - $queryCallable = function ( $className, $ctx, @@ -52,8 +50,8 @@ class ChangesListStringOptionsFilterGroupTest extends MediaWikiTestCase { &$query_options, &$join_conds, $actualSelectedValues - ) use ( $self, $expectedValues ) { - $self->assertSame( + ) use ( $expectedValues ) { + $this->assertSame( $expectedValues, $actualSelectedValues ); -- 2.20.1