Page MenuHomePhabricator

Many users have a gu_home_db in deleted.dblist
Open, Needs TriagePublic

Description

MariaDB [centralauth]> select count(*), gu_home_db from globaluser where gu_home_db IN ('alswikibooks', 'alswikiquote', 'alswiktionary', 'bawiktionary', 'chwikimedia', 'closed_zh_twwiki', 'comcomwiki', 'de_labswikimedia', 'dkwiki', 'dkwikibooks', 'dkwiktionary', 'en_labswikimedia', 'fixcopyrightwiki', 'flaggedrevs_labswikimedia', 'langcomwiki', 'liquidthreads_labswikimedia', 'mowiki', 'mowiktionary', 'noboardwiki', 'nomcomwiki', 'readerfeedback_labswikimedia', 'rel13testwiki', 'ru_sibwiki', 'sep11wiki', 'strategyappswiki', 'tlhwiki', 'tlhwiktionary', 'tokiponawiki', 'tokiponawikibooks', 'tokiponawikiquote', 'tokiponawikisource', 'tokiponawiktionary', 'ukwikimedia', 'vewikimedia', 'zerowiki', 'zh_cnwiki', 'zh_twwiki') GROUP BY gu_home_db;
+----------+------------------------------+
| count(*) | gu_home_db                   |
+----------+------------------------------+
|       12 | alswikibooks                 |
|       10 | alswikiquote                 |
|       17 | alswiktionary                |
|        2 | chwikimedia                  |
|       12 | de_labswikimedia             |
|       93 | en_labswikimedia             |
|       36 | flaggedrevs_labswikimedia    |
|      187 | mowiki                       |
|       21 | mowiktionary                 |
|       10 | readerfeedback_labswikimedia |
|     1682 | ukwikimedia                  |
+----------+------------------------------+
11 rows in set (1 min 22.56 sec)

While I don't thinks has many practical issues... It does seem messy

Event Timeline

It looks like we can trivially enough fix this though. List from above filtered to those where they have users (to simpliy the query)

UPDATE globaluser
SET gu_home_db = ''
WHERE gu_home_db IN ('alswikibooks', 'alswikiquote', 'alswiktionary', 'chwikimedia', 'de_labswikimedia', 'en_labswikimedia', 'flaggedrevs_labswikimedia', 'mowiki', 'mowiktionary', 'readerfeedback_labswikimedia', 'ukwikimedia')

Then just run CentralAuth's populateHomeDB.php which will re-pick a new home DB based on the same criteria we used originally

	/**
	 * Return the id of the user's home wiki.
	 *
	 * @return string|null Null if the account has no attached wikis
	 */
	public function getHomeWiki() {
		$this->loadState();

		if ( $this->mHomeWiki !== null && $this->mHomeWiki !== '' ) {
			return $this->mHomeWiki;
		}

		$attached = $this->queryAttachedBasic();

		if ( !count( $attached ) ) {
			return null;
		}

		foreach ( $attached as $wiki => $acc ) {
			if ( $acc['attachedMethod'] == 'primary' || $acc['attachedMethod'] == 'new' ) {
				$this->mHomeWiki = $wiki;
				break;
			}
		}

		if ( $this->mHomeWiki === null || $this->mHomeWiki === '' ) {
			// Still null... try harder.
			$attached = $this->queryAttached();
			$this->mHomeWiki = key( $attached ); // Make sure we always have some value
			$maxEdits = -1;
			foreach ( $attached as $wiki => $acc ) {
				if ( isset( $acc['editCount'] ) && $acc['editCount'] > $maxEdits ) {
					$this->mHomeWiki = $wiki;
					$maxEdits = $acc['editCount'];
				}
			}
		}

		return $this->mHomeWiki;
	}

Ref https://wikitech.wikimedia.org/wiki/Delete_a_wiki

Once we have a direction, also update that page accordingly :)