X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Flbfactory%2FLBFactory.php;h=f5d57c4c0d70c8ca9d9de3f22ba22c8255a6f9c9;hb=bcd377cd008f8a8628ab727c3fa90090725d6c10;hp=85194bc009c9e3890475dab12dc0ecb5f121fafb;hpb=1319754d6633db31ba03ab69bc2e6d347f2f67fc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 85194bc009..f5d57c4c0d 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -135,6 +135,36 @@ abstract class LBFactory implements ILBFactory { $this->commitMasterChanges( __METHOD__ ); // sanity } + /** + * @see ILBFactory::newMainLB() + * @param bool $domain + * @return LoadBalancer + */ + abstract public function newMainLB( $domain = false ); + + /** + * @see ILBFactory::getMainLB() + * @param bool $domain + * @return mixed + */ + abstract public function getMainLB( $domain = false ); + + /** + * @see ILBFactory::newExternalLB() + * @param string $cluster + * @param bool $domain + * @return LoadBalancer + */ + abstract public function newExternalLB( $cluster, $domain = false ); + + /** + * @see ILBFactory::getExternalLB() + * @param string $cluster + * @param bool $domain + * @return mixed + */ + abstract public function getExternalLB( $cluster, $domain = false ); + /** * Call a method of each tracked load balancer * @@ -178,6 +208,8 @@ abstract class LBFactory implements ILBFactory { "$fname: transaction round '{$this->trxRoundId}' still running." ); } + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = $this->getScopedPHPBehaviorForCommit(); // try to ignore client aborts // Run pre-commit callbacks and suppress post-commit callbacks, aborting on failure $this->forEachLBCallMethod( 'finalizeMasterChanges' ); $this->trxRoundId = false; @@ -516,6 +548,23 @@ abstract class LBFactory implements ILBFactory { $this->requestInfo = $info + $this->requestInfo; } + /** + * 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' ) { // http://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(); }