Page MenuHomePhabricator

getScopedPHPBehaviorForCommit is copied 3 times in MediaWiki
Closed, ResolvedPublic

Description

Basically the same code has been copied and pasted in three places:

	final protected function getScopedPHPBehaviorForCommit() {
		if ( PHP_SAPI != 'cli' ) { // https://bugs.php.net/bug.php?id=47540
			$old = ignore_user_abort( true ); // avoid half-finished operations
			return new ScopedCallback( function () use ( $old ) {
				ignore_user_abort( $old );
			} );
		}

		return null;
	}
  • FileBackend::getScopedPHPBehaviorForOps()
  • LBFactory::getScopedPHPBehaviorForCommit()
  • LoadBalancer::getScopedPHPBehaviorForCommit()

Let's just have it in one place, maybe it can go in the ScopedCallback library?

GCI Mentors: @Legoktm

For this task you'll need to introduce a newScopedIgnoreUserAbort function with the above code for the ScopedCallback library (mediawiki/libs/ScopedCallback in Gerrit), and then submit a second patch to the above places in MediaWiki core to use your new function.

Event Timeline

Change 470471 had a related patch set uploaded (by Stibba; owner: Stibba):
[mediawiki/libs/ScopedCallback@master] Add function newScopedIgnoreUserAbort to ScopedCallback

https://gerrit.wikimedia.org/r/470471

Change 470501 had a related patch set uploaded (by Stibba; owner: Stibba):
[mediawiki/core@master] Update FileBackend, LoadBalancer and LBFactory to use public function in ScopedCallback

https://gerrit.wikimedia.org/r/470501

Change 470471 merged by jenkins-bot:
[mediawiki/libs/ScopedCallback@master] Add ScopedCallback::newScopedIgnoreUserAbort helper function

https://gerrit.wikimedia.org/r/470471

Change 470501 merged by jenkins-bot:
[mediawiki/core@master] Use new ScopedCallback::newScopedIgnoreUserAbort helper function

https://gerrit.wikimedia.org/r/470501

Legoktm assigned this task to Stibba.