Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / includes / logging / BlockLogFormatter.php
index 6bc3f39..ead290f 100644 (file)
@@ -77,12 +77,34 @@ class BlockLogFormatter extends LogFormatter {
                        // block restrictions
                        if ( isset( $params[6] ) ) {
                                $pages = $params[6]['pages'] ?? [];
-                               $pages = array_map( function ( $page ){
-                                       return $this->makePageLink( Title::newFromText( ( $page ) ) );
+                               $pages = array_map( function ( $page ) {
+                                       return $this->makePageLink( Title::newFromText( $page ) );
                                }, $pages );
 
-                               $params[6] = Message::rawParam( $this->context->getLanguage()->listToText( $pages ) );
-                               $params[7] = count( $pages );
+                               $namespaces = $params[6]['namespaces'] ?? [];
+                               $namespaces = array_map( function ( $ns ) {
+                                       $text = (int)$ns === NS_MAIN
+                                               ? $this->msg( 'blanknamespace' )->text()
+                                               : $this->context->getLanguage()->getFormattedNsText( $ns );
+                                       $params = [ 'namespace' => $ns ];
+
+                                       return $this->makePageLink( SpecialPage::getTitleFor( 'Allpages' ), $params, $text );
+                               }, $namespaces );
+
+                               $restrictions = [];
+                               if ( $pages ) {
+                                       $restrictions[] = $this->msg( 'logentry-partialblock-block-page' )
+                                               ->numParams( count( $pages ) )
+                                               ->rawParams( $this->context->getLanguage()->listToText( $pages ) )->text();
+                               }
+
+                               if ( $namespaces ) {
+                                       $restrictions[] = $this->msg( 'logentry-partialblock-block-ns' )
+                                               ->numParams( count( $namespaces ) )
+                                               ->rawParams( $this->context->getLanguage()->listToText( $namespaces ) )->text();
+                               }
+
+                               $params[6] = Message::rawParam( $this->context->getLanguage()->listToText( $restrictions ) );
                        }
                }
 
@@ -105,7 +127,7 @@ class BlockLogFormatter extends LogFormatter {
        public function getPreloadTitles() {
                $title = $this->entry->getTarget();
                // Preload user page for non-autoblocks
-               if ( substr( $title->getText(), 0, 1 ) !== '#' ) {
+               if ( substr( $title->getText(), 0, 1 ) !== '#' && $title->isValid() ) {
                        return [ $title->getTalkPage() ];
                }
                return [];
@@ -253,6 +275,10 @@ class BlockLogFormatter extends LogFormatter {
                        ApiResult::setIndexedTagName( $ret['restrictions']['pages'], 'p' );
                }
 
+               if ( isset( $ret['restrictions']['namespaces'] ) ) {
+                       ApiResult::setIndexedTagName( $ret['restrictions']['namespaces'], 'ns' );
+               }
+
                return $ret;
        }