API: Update ApiOptions docs for I45f69997
[lhc/web/wiklou.git] / maintenance / Maintenance.php
index 2216de1..1cb5eef 100644 (file)
@@ -553,8 +553,19 @@ abstract class Maintenance {
         * Set triggers like when to try to run deferred updates
         * @since 1.28
         */
-       public function setTriggers() {
+       public function setAgentAndTriggers() {
+               if ( function_exists( 'posix_getpwuid' ) ) {
+                       $agent = posix_getpwuid( posix_geteuid() )['name'];
+               } else {
+                       $agent = 'sysadmin';
+               }
+               $agent .= '@' . wfHostname();
+
                $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+               // Add a comment for easy SHOW PROCESSLIST interpretation
+               $lbFactory->setAgentName(
+                       mb_strlen( $agent ) > 15 ? mb_substr( $agent, 0, 15 ) . '...' : $agent
+               );
                self::setLBFactoryTriggers( $lbFactory );
        }
 
@@ -1091,7 +1102,7 @@ abstract class Maintenance {
                                $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser;
                                $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword;
                        }
-                       LBFactory::destroyInstance();
+                       MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->destroy();
                }
 
                // Per-script profiling; useful for debugging
@@ -1230,7 +1241,7 @@ abstract class Maintenance {
         * @param integer $db DB index (DB_REPLICA/DB_MASTER)
         * @param array $groups; default: empty array
         * @param string|bool $wiki; default: current wiki
-        * @return IDatabase
+        * @return Database
         */
        protected function getDB( $db, $groups = [], $wiki = false ) {
                if ( is_null( $this->mDb ) ) {
@@ -1305,7 +1316,7 @@ abstract class Maintenance {
 
        /**
         * Lock the search index
-        * @param DatabaseBase &$db
+        * @param Database &$db
         */
        private function lockSearchindex( $db ) {
                $write = [ 'searchindex' ];
@@ -1323,7 +1334,7 @@ abstract class Maintenance {
 
        /**
         * Unlock the tables
-        * @param DatabaseBase &$db
+        * @param Database &$db
         */
        private function unlockSearchindex( $db ) {
                $db->unlockTables( __CLASS__ . '::' . __METHOD__ );
@@ -1332,7 +1343,7 @@ abstract class Maintenance {
        /**
         * Unlock and lock again
         * Since the lock is low-priority, queued reads will be able to complete
-        * @param DatabaseBase &$db
+        * @param Database &$db
         */
        private function relockSearchindex( $db ) {
                $this->unlockSearchindex( $db );
@@ -1343,7 +1354,7 @@ abstract class Maintenance {
         * Perform a search index update with locking
         * @param int $maxLockTime The maximum time to keep the search index locked.
         * @param string $callback The function that will update the function.
-        * @param DatabaseBase $dbw
+        * @param Database $dbw
         * @param array $results
         */
        public function updateSearchIndex( $maxLockTime, $callback, $dbw, $results ) {
@@ -1379,7 +1390,7 @@ abstract class Maintenance {
 
        /**
         * Update the searchindex table for a given pageid
-        * @param DatabaseBase $dbw A database write handle
+        * @param Database $dbw A database write handle
         * @param int $pageId The page ID to update.
         * @return null|string
         */