From: jenkins-bot Date: Sat, 3 Nov 2018 00:43:22 +0000 (+0000) Subject: Merge "Use new ScopedCallback::newScopedIgnoreUserAbort helper function" X-Git-Tag: 1.34.0-rc.0~3570 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=f014bf5276433106763e3b9f71a8ea2040db1ca8;hp=7b2dca9e2acc1f4804b53653f5b070dc48d7cb55;p=lhc%2Fweb%2Fwiklou.git Merge "Use new ScopedCallback::newScopedIgnoreUserAbort helper function" --- diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 2852265cbe..27e6924476 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -427,7 +427,7 @@ abstract class FileBackend implements LoggerAwareInterface { } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doOperationsInternal( $ops, $opts ); } @@ -665,7 +665,7 @@ abstract class FileBackend implements LoggerAwareInterface { } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doQuickOperationsInternal( $ops ); } @@ -812,7 +812,7 @@ abstract class FileBackend implements LoggerAwareInterface { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doPrepare( $params ); } @@ -843,7 +843,7 @@ abstract class FileBackend implements LoggerAwareInterface { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doSecure( $params ); } @@ -876,7 +876,7 @@ abstract class FileBackend implements LoggerAwareInterface { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doPublish( $params ); } @@ -902,7 +902,7 @@ abstract class FileBackend implements LoggerAwareInterface { return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly ); } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForOps(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts return $this->doClean( $params ); } @@ -912,24 +912,6 @@ abstract class FileBackend implements LoggerAwareInterface { */ abstract protected function doClean( array $params ); - /** - * Enter file operation scope. - * This just makes PHP ignore user aborts/disconnects until the return - * value leaves scope. This returns null and does nothing in CLI mode. - * - * @return ScopedCallback|null - */ - final protected function getScopedPHPBehaviorForOps() { - 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; - } - /** * Check if a file exists at a storage path in the backend. * This returns false if only a directory exists at the path. diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 1612f41dca..d213dc9e80 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -257,7 +257,7 @@ abstract class LBFactory implements ILBFactory { ); } /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForCommit(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts // Run pre-commit callbacks and suppress post-commit callbacks, aborting on failure do { $count = 0; // number of callbacks executed this iteration @@ -707,23 +707,6 @@ abstract class LBFactory implements ILBFactory { } } - /** - * Make PHP ignore user aborts/disconnects until the returned - * value leaves scope. This returns null and does nothing in CLI mode. - * - * @return ScopedCallback|null - */ - 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; - } - function __destruct() { $this->destroy(); } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index b2b23917e1..7721707a54 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1395,7 +1395,7 @@ class LoadBalancer implements ILoadBalancer { $failures = []; /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = $this->getScopedPHPBehaviorForCommit(); // try to ignore client aborts + $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts $restore = ( $this->trxRoundId !== false ); $this->trxRoundId = false; @@ -1960,23 +1960,6 @@ class LoadBalancer implements ILoadBalancer { } } - /** - * Make PHP ignore user aborts/disconnects until the returned - * value leaves scope. This returns null and does nothing in CLI mode. - * - * @return ScopedCallback|null - */ - 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; - } - function __destruct() { // Avoid connection leaks for sanity $this->disable();