Page MenuHomePhabricator

getScopedPHPBehaviorForCommit is copied 3 times in MediaWiki
Closed, ResolvedPublic


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

	final protected function getScopedPHPBehaviorForCommit() {
		if ( PHP_SAPI != 'cli' ) { //
			$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

Legoktm created this task.Jan 3 2018, 6:49 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 3 2018, 6:49 AM
Legoktm updated the task description. (Show Details)

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

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

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

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

Legoktm closed this task as Resolved.Nov 3 2018, 1:44 AM
Legoktm assigned this task to Stibba.