2declare( strict_types = 1 );
4namespace MediaWiki\Extension\Translate\MessageGroupProcessing;
7use MediaWiki\MediaWikiServices;
8use MediaWiki\Page\PageReference;
9use MediaWiki\Title\Title;
54 protected function getTranslationUnitPagesByTitle( PageReference $title, ?
string $code =
null ): array {
55 $mwServices = MediaWikiServices::getInstance();
57 $dbw = $mwServices->getDBLoadBalancer()->getConnection( DB_PRIMARY );
58 $base = $mwServices->getTitleFormatter()->getPrefixedDBkey( $title );
60 $baseLength = strlen( $base ) + 1;
62 if ( $code ===
null ) {
63 $like = $dbw->buildLike(
"$base/", $dbw->anyString() );
65 $like = $dbw->buildLike(
"$base/", $dbw->anyString(),
"/$code" );
68 $res = $dbw->newSelectQueryBuilder()
69 ->select( [
'page_namespace',
'page_title' ] )
72 'page_namespace' => NS_TRANSLATIONS,
75 ->caller( __METHOD__ )
83 foreach ( $res as $row ) {
84 $title = Title::newFromRow( $row );
89 $key = substr( $handle->getKey(), $baseLength );
90 if ( str_contains( $key,
'/' ) ) {