Merge "parserTests: Do not check for DjVu support"
[lhc/web/wiklou.git] / includes / libs / rdbms / lbfactory / LBFactory.php
index 85194bc..f5d57c4 100644 (file)
@@ -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();
        }