Merge "TableDiffFormatter: Don't repeatedly call array_shift()"
[lhc/web/wiklou.git] / includes / specials / SpecialWhatlinkshere.php
index 45ef9a2..baa55f0 100644 (file)
@@ -35,7 +35,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
        /** @var Title */
        protected $target;
 
-       protected $limits = array( 20, 50, 100, 250, 500 );
+       protected $limits = [ 20, 50, 100, 250, 500 ];
 
        public function __construct() {
                parent::__construct( 'Whatlinkshere' );
@@ -115,17 +115,17 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                $fetchlinks = ( !$hidelinks || !$hideredirs );
 
                // Build query conds in concert for all three tables...
-               $conds['pagelinks'] = array(
+               $conds['pagelinks'] = [
                        'pl_namespace' => $target->getNamespace(),
                        'pl_title' => $target->getDBkey(),
-               );
-               $conds['templatelinks'] = array(
+               ];
+               $conds['templatelinks'] = [
                        'tl_namespace' => $target->getNamespace(),
                        'tl_title' => $target->getDBkey(),
-               );
-               $conds['imagelinks'] = array(
+               ];
+               $conds['imagelinks'] = [
                        'il_to' => $target->getDBkey(),
-               );
+               ];
 
                $namespace = $this->opts->getValue( 'namespace' );
                $invert = $this->opts->getValue( 'invert' );
@@ -153,32 +153,32 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                ) {
                        // Read an extra row as an at-end check
                        $queryLimit = $limit + 1;
-                       $on = array(
+                       $on = [
                                "rd_from = $fromCol",
                                'rd_title' => $target->getDBkey(),
                                'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL'
-                       );
+                       ];
                        $on['rd_namespace'] = $target->getNamespace();
                        // Inner LIMIT is 2X in case of stale backlinks with wrong namespaces
-                       $subQuery = $dbr->selectSqlText(
-                               array( $table, 'redirect', 'page' ),
-                               array( $fromCol, 'rd_from' ),
+                       $subQuery = $dbr->selectSQLText(
+                               [ $table, 'redirect', 'page' ],
+                               [ $fromCol, 'rd_from' ],
                                $conds[$table],
                                __CLASS__ . '::showIndirectLinks',
                                // Force JOIN order per T106682 to avoid large filesorts
-                               array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ),
-                               array(
-                                       'page' => array( 'INNER JOIN', "$fromCol = page_id" ),
-                                       'redirect' => array( 'LEFT JOIN', $on )
-                               )
+                               [ 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ],
+                               [
+                                       'page' => [ 'INNER JOIN', "$fromCol = page_id" ],
+                                       'redirect' => [ 'LEFT JOIN', $on ]
+                               ]
                        );
                        return $dbr->select(
-                               array( 'page', 'temp_backlink_range' => "($subQuery)" ),
-                               array( 'page_id', 'page_namespace', 'page_title', 'rd_from', 'page_is_redirect' ),
-                               array(),
+                               [ 'page', 'temp_backlink_range' => "($subQuery)" ],
+                               [ 'page_id', 'page_namespace', 'page_title', 'rd_from', 'page_is_redirect' ],
+                               [],
                                __CLASS__ . '::showIndirectLinks',
-                               array( 'ORDER BY' => 'page_id', 'LIMIT' => $queryLimit ),
-                               array( 'page' => array( 'INNER JOIN', "$fromCol = page_id" ) )
+                               [ 'ORDER BY' => 'page_id', 'LIMIT' => $queryLimit ],
+                               [ 'page' => [ 'INNER JOIN', "$fromCol = page_id" ] ]
                        );
                };
 
@@ -304,7 +304,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
        }
 
        protected function listStart( $level ) {
-               return Xml::openElement( 'ul', ( $level ? array() : array( 'id' => 'mw-whatlinkshere-list' ) ) );
+               return Xml::openElement( 'ul', ( $level ? [] : [ 'id' => 'mw-whatlinkshere-list' ] ) );
        }
 
        protected function listItem( $row, $nt, $target, $notClose = false ) {
@@ -313,30 +313,30 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                # local message cache
                static $msgcache = null;
                if ( $msgcache === null ) {
-                       static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator',
-                               'whatlinkshere-links', 'isimage', 'editlink' );
-                       $msgcache = array();
+                       static $msgs = [ 'isredirect', 'istemplate', 'semicolon-separator',
+                               'whatlinkshere-links', 'isimage', 'editlink' ];
+                       $msgcache = [];
                        foreach ( $msgs as $msg ) {
                                $msgcache[$msg] = $this->msg( $msg )->escaped();
                        }
                }
 
                if ( $row->rd_from ) {
-                       $query = array( 'redirect' => 'no' );
+                       $query = [ 'redirect' => 'no' ];
                } else {
-                       $query = array();
+                       $query = [];
                }
 
                $link = Linker::linkKnown(
                        $nt,
                        null,
-                       $row->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array(),
+                       $row->page_is_redirect ? [ 'class' => 'mw-redirect' ] : [],
                        $query
                );
 
                // Display properties (redirect or template)
                $propsText = '';
-               $props = array();
+               $props = [];
                if ( $row->rd_from ) {
                        $props[] = $msgcache['isredirect'];
                }
@@ -347,7 +347,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        $props[] = $msgcache['isimage'];
                }
 
-               Hooks::run( 'WhatLinksHereProps', array( $row, $nt, $target, &$props ) );
+               Hooks::run( 'WhatLinksHereProps', [ $row, $nt, $target, &$props ] );
 
                if ( count( $props ) ) {
                        $propsText = $this->msg( 'parentheses' )
@@ -377,14 +377,14 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                }
 
                // always show a "<- Links" link
-               $links = array(
+               $links = [
                        'links' => Linker::linkKnown(
                                $title,
                                $text,
-                               array(),
-                               array( 'target' => $target->getPrefixedText() )
+                               [],
+                               [ 'target' => $target->getPrefixedText() ]
                        ),
-               );
+               ];
 
                // if the page is editable, add an edit link
                if (
@@ -396,8 +396,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        $links['edit'] = Linker::linkKnown(
                                $target,
                                $editText,
-                               array(),
-                               array( 'action' => 'edit' )
+                               [],
+                               [ 'action' => 'edit' ]
                        );
                }
 
@@ -409,7 +409,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                return Linker::linkKnown(
                        $this->selfTitle,
                        $text,
-                       array(),
+                       [],
                        $query
                );
        }
@@ -423,19 +423,19 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                unset( $changed['target'] ); // Already in the request title
 
                if ( 0 != $prevId ) {
-                       $overrides = array( 'from' => $this->opts->getValue( 'back' ) );
+                       $overrides = [ 'from' => $this->opts->getValue( 'back' ) ];
                        $prev = $this->makeSelfLink( $prev, array_merge( $changed, $overrides ) );
                }
                if ( 0 != $nextId ) {
-                       $overrides = array( 'from' => $nextId, 'back' => $prevId );
+                       $overrides = [ 'from' => $nextId, 'back' => $prevId ];
                        $next = $this->makeSelfLink( $next, array_merge( $changed, $overrides ) );
                }
 
-               $limitLinks = array();
+               $limitLinks = [];
                $lang = $this->getLanguage();
                foreach ( $this->limits as $limit ) {
                        $prettyLimit = htmlspecialchars( $lang->formatNum( $limit ) );
-                       $overrides = array( 'limit' => $limit );
+                       $overrides = [ 'limit' => $limit ];
                        $limitLinks[] = $this->makeSelfLink( $prettyLimit, array_merge( $changed, $overrides ) );
                }
 
@@ -448,14 +448,14 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                // We get nicer value from the title object
                $this->opts->consumeValue( 'target' );
                // Reset these for new requests
-               $this->opts->consumeValues( array( 'back', 'from' ) );
+               $this->opts->consumeValues( [ 'back', 'from' ] );
 
                $target = $this->target ? $this->target->getPrefixedText() : '';
                $namespace = $this->opts->consumeValue( 'namespace' );
                $nsinvert = $this->opts->consumeValue( 'invert' );
 
                # Build up the form
-               $f = Xml::openElement( 'form', array( 'action' => wfScript() ) );
+               $f = Xml::openElement( 'form', [ 'action' => wfScript() ] );
 
                # Values that should not be forgotten
                $f .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
@@ -467,21 +467,21 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
 
                # Target input (.mw-searchInput enables suggestions)
                $f .= Xml::inputLabel( $this->msg( 'whatlinkshere-page' )->text(), 'target',
-                       'mw-whatlinkshere-target', 40, $target, array( 'class' => 'mw-searchInput' ) );
+                       'mw-whatlinkshere-target', 40, $target, [ 'class' => 'mw-searchInput' ] );
 
                $f .= ' ';
 
                # Namespace selector
                $f .= Html::namespaceSelector(
-                       array(
+                       [
                                'selected' => $namespace,
                                'all' => '',
                                'label' => $this->msg( 'namespace' )->text()
-                       ), array(
+                       ], [
                                'name' => 'namespace',
                                'id' => 'namespace',
                                'class' => 'namespaceselector',
-                       )
+                       ]
                );
 
                $f .= '&#160;' .
@@ -490,7 +490,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                                'invert',
                                'nsinvert',
                                $nsinvert,
-                               array( 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() )
+                               [ 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() ]
                        );
 
                $f .= ' ';
@@ -516,8 +516,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                $changed = $this->opts->getChangedValues();
                unset( $changed['target'] ); // Already in the request title
 
-               $links = array();
-               $types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
+               $links = [];
+               $types = [ 'hidetrans', 'hidelinks', 'hideredirs' ];
                if ( $this->target->getNamespace() == NS_FILE ) {
                        $types[] = 'hideimages';
                }
@@ -528,7 +528,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                foreach ( $types as $type ) {
                        $chosen = $this->opts->getValue( $type );
                        $msg = $chosen ? $show : $hide;
-                       $overrides = array( $type => !$chosen );
+                       $overrides = [ $type => !$chosen ];
                        $links[] = $this->msg( "whatlinkshere-{$type}" )->rawParams(
                                $this->makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped();
                }