getTitle()->getNamespace(); $titles = self::getMatchingTitles( $sourceMessageHandle ); foreach ( $titles as $title ) { $handle = new MessageHandle( $title ); // This takes care of situations where we have two different titles // foo and foo/bar, both will be matched and fetched but the slash // does not represent a language separator if ( $handle->getKey() !== $sourceMessageHandle->getKey() ) { continue; } $targetTitle = Title::makeTitle( $namespace, TranslateUtils::title( $replacement, $handle->getCode(), $namespace ) ); $titlesForMove[] = [ $title, $targetTitle ]; } return $titlesForMove; } /** * @param MessageHandle $handle * @return TitleArrayFromResult */ private static function getMatchingTitles( MessageHandle $handle ) { $dbr = wfGetDB( DB_MASTER ); $tables = [ 'page' ]; $vars = [ 'page_title', 'page_namespace', 'page_id' ]; $comparisonCond = 'page_title ' . $dbr->buildLike( $handle->getTitleForBase()->getDBkey(), '/', $dbr->anyString() ); $conds = [ $comparisonCond, 'page_namespace' => $handle->getTitle()->getNamespace(), ]; $result = $dbr->select( $tables, $vars, $conds, __METHOD__ ); return TitleArray::newFromResult( $result ); } } class_alias( TranslateReplaceTitle::class, '\MediaWiki\Extensions\Translate\TranslateReplaceTitle' );