2declare( strict_types = 1 );
4namespace MediaWiki\Extension\Translate\MessageProcessing;
8use MediaWiki\MediaWikiServices;
9use MediaWiki\Title\Title;
10use MediaWiki\Title\TitleArrayFromResult;
29 $namespace = $sourceMessageHandle->
getTitle()->getNamespace();
31 $titles = self::getMatchingTitles( $sourceMessageHandle );
33 foreach ( $titles as $title ) {
38 if ( $handle->getKey() !== $sourceMessageHandle->
getKey() ) {
41 $targetTitle = Title::makeTitle(
43 Utilities::title( $replacement, $handle->getCode(), $namespace )
45 $titlesForMove[] = [ $title, $targetTitle ];
48 return $titlesForMove;
51 private static function getMatchingTitles( MessageHandle $handle ): TitleArrayFromResult {
52 $dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY );
53 $result = $dbr->newSelectQueryBuilder()
54 ->select( [
'page_title',
'page_namespace',
'page_id' ] )
57 'page_namespace' => $handle->getTitle()->getNamespace(),
58 'page_title ' . $dbr->buildLike(
59 $handle->getTitleForBase()->getDBkey(),
'/', $dbr->anyString()
62 ->caller( __METHOD__ )
65 return new TitleArrayFromResult( $result );