jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/357865 )
Change subject: Use short array syntax - classes ...................................................................... Use short array syntax - classes Done by phpcbf over composer fix Change-Id: Ia30ef80cc11190297d8652712456d1cf992d8124 --- M classes/DeletionController.php M classes/Dispatch.php M classes/HistoricalThread.php M classes/Hooks.php M classes/LogFormatter.php M classes/NewMessagesController.php M classes/ParserFunctions.php M classes/Thread.php M classes/ThreadHistoryPager.php M classes/ThreadRevision.php M classes/Threads.php M classes/View.php 12 files changed, 463 insertions(+), 463 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/classes/DeletionController.php b/classes/DeletionController.php index 2ee0af1..2b9bed8 100644 --- a/classes/DeletionController.php +++ b/classes/DeletionController.php @@ -9,7 +9,7 @@ return true; } - $threads = Threads::where( array( 'thread_root' => $id ) ); + $threads = Threads::where( [ 'thread_root' => $id ] ); if ( !count( $threads ) ) { wfDebugLog( 'LiquidThreads', __METHOD__ . ": no threads with root $id, ignoring...\n" ); @@ -75,7 +75,7 @@ // TX has not been committed yet, so we must select from the master $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( 'thread', '*', array( 'thread_root' => $pageid ), __METHOD__ ); + $res = $dbw->select( 'thread', '*', [ 'thread_root' => $pageid ], __METHOD__ ); $threads = Threads::loadFromResult( $res, $dbw ); if ( count( $threads ) ) { diff --git a/classes/Dispatch.php b/classes/Dispatch.php index fd64b64..dfaa9e2 100644 --- a/classes/Dispatch.php +++ b/classes/Dispatch.php @@ -2,7 +2,7 @@ class LqtDispatch { /** static cache of per-page LiquidThreads activation setting */ - public static $userLqtOverride = array(); + public static $userLqtOverride = []; public static $primaryView = null; /** @@ -33,7 +33,7 @@ $action = $request->getVal( 'action', 'view' ); // Actions handled by LQT. - $lqt_actions = array( 'view', 'protect', 'unprotect' ); + $lqt_actions = [ 'view', 'protect', 'unprotect' ]; $lqt_action = $request->getVal( 'lqt_method' ); if ( $action == 'edit' && $request->getVal( 'section' ) == 'new' ) { @@ -144,7 +144,7 @@ $isTalkPage = $isTalkPage && !$title->isRedirect(); - Hooks::run( 'LiquidThreadsIsLqtPage', array( $title, &$isTalkPage ) ); + Hooks::run( 'LiquidThreadsIsLqtPage', [ $title, &$isTalkPage ] ); return $isTalkPage; } @@ -186,10 +186,10 @@ $row = $dbr->selectRow( 'page_props', 'pp_value', - array( + [ 'pp_propname' => 'use-liquid-threads', 'pp_page' => $articleid - ), + ], __METHOD__ ); diff --git a/classes/HistoricalThread.php b/classes/HistoricalThread.php index 61cc289..8042030 100644 --- a/classes/HistoricalThread.php +++ b/classes/HistoricalThread.php @@ -24,7 +24,7 @@ $this->revisionNumber = $t->revisionNumber; $this->editedness = $t->editedness; - $this->replies = array(); + $this->replies = []; foreach ( $t->replies() as $r ) { $this->replies[] = new HistoricalThread( $r ); } @@ -44,10 +44,10 @@ $line = $dbr->selectRow( 'historical_thread', 'hthread_contents', - array( + [ 'hthread_id' => $id, 'hthread_revision' => $rev - ), + ], __METHOD__ ); if ( $line ) { return HistoricalThread::fromTextRepresentation( $line->hthread_contents ); diff --git a/classes/Hooks.php b/classes/Hooks.php index 58c623e..340cf2e 100644 --- a/classes/Hooks.php +++ b/classes/Hooks.php @@ -14,19 +14,19 @@ */ public static $editArticle = null; public static $editTalkpage = null; - public static $scriptVariables = array(); + public static $scriptVariables = []; - public static $editedStati = array( + public static $editedStati = [ Threads::EDITED_NEVER => 'never', Threads::EDITED_HAS_REPLY => 'has-reply', Threads::EDITED_BY_AUTHOR => 'by-author', Threads::EDITED_BY_OTHERS => 'by-others' - ); - public static $threadTypes = array( + ]; + public static $threadTypes = [ Threads::TYPE_NORMAL => 'normal', Threads::TYPE_MOVED => 'moved', Threads::TYPE_DELETED => 'deleted' - ); + ]; /** * @param $changeslist ChangesList @@ -69,7 +69,7 @@ $quote = $wgLang->truncate( $quote, 200 ); $s .= ' ' . Linker::commentBlock( $quote ); - $classes = array(); + $classes = []; $changeslist->insertTags( $s, $rc, $classes ); $changeslist->insertExtra( $s, $rc, $classes ); } @@ -122,7 +122,7 @@ if ( !in_array( 'page', $tables ) ) { $tables[] = 'page'; // Yes, this is the correct field to join to. Weird naming. - $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' ); + $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; } $conds[] = "page_namespace != " . $db->addQuotes( NS_LQT_THREAD ); @@ -143,7 +143,7 @@ $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink( $messages_title, new HtmlArmor( $new_messages ), - array( 'class' => 'lqt_watchlist_messages_notice' ) ); + [ 'class' => 'lqt_watchlist_messages_notice' ] ); $wgOut->addHTML( $link ); return true; @@ -154,33 +154,33 @@ if ( $wgEnableEmail ) { $preferences['lqtnotifytalk'] = - array( + [ 'type' => 'toggle', 'label-message' => 'lqt-preference-notify-talk', 'section' => 'personal/email' - ); + ]; } - $preferences['lqt-watch-threads'] = array( + $preferences['lqt-watch-threads'] = [ 'type' => 'toggle', 'label-message' => 'lqt-preference-watch-threads', 'section' => 'watchlist/advancedwatchlist', - ); + ]; // Display depth and count - $preferences['lqtdisplaydepth'] = array( + $preferences['lqtdisplaydepth'] = [ 'type' => 'int', 'label-message' => 'lqt-preference-display-depth', 'section' => 'lqt', 'min' => 1, - ); + ]; - $preferences['lqtdisplaycount'] = array( + $preferences['lqtdisplaycount'] = [ 'type' => 'int', 'label-message' => 'lqt-preference-display-count', 'section' => 'lqt', 'min' => 1, - ); + ]; return true; } @@ -204,7 +204,7 @@ $thread = Thread::newFromRow( $row ); $threadInfo = "\n"; - $attribs = array(); + $attribs = []; $attribs['ThreadSubject'] = $thread->subject(); if ( $thread->hasSuperThread() ) { @@ -241,7 +241,7 @@ static function modifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) { $tables[] = 'thread'; - $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) ); + $join['thread'] = [ 'left join', [ 'thread_root=page_id' ] ]; return true; } @@ -251,7 +251,7 @@ ) { $tables[] = 'thread'; - $join_conds['thread'] = array( 'left join', array( 'thread_root=page_id' ) ); + $join_conds['thread'] = [ 'left join', [ 'thread_root=page_id' ] ]; $db = wfGetDB( DB_SLAVE ); $fields[] = $db->tableName( 'thread' ) . '.*'; @@ -290,10 +290,10 @@ return true; } - private static $userTables = array( - 'thread' => array( 'thread_author_name', 'thread_author_id', 'thread_modified' ), - 'thread_history' => array( 'th_user_text', 'th_user', 'th_timestamp' ) - ); + private static $userTables = [ + 'thread' => [ 'thread_author_name', 'thread_author_id', 'thread_modified' ], + 'thread_history' => [ 'th_user_text', 'th_user', 'th_timestamp' ] + ]; /** * For integration with the UserMerge extension. @@ -304,7 +304,7 @@ public static function onUserMergeAccountFields( &$updateFields ) { // array( tableName, idField, textField ) foreach ( self::$userTables as $table => $fields ) { - $updateFields[] = array( $table, $fields[1], $fields[0] ); + $updateFields[] = [ $table, $fields[1], $fields[0] ]; } return true; } @@ -343,7 +343,7 @@ } static function customiseSearchProfiles( &$profiles ) { - $namespaces = array( NS_LQT_THREAD, NS_LQT_SUMMARY ); + $namespaces = [ NS_LQT_THREAD, NS_LQT_SUMMARY ]; // Add odd namespaces foreach ( SearchEngine::searchableNamespaces() as $ns => $nsName ) { @@ -352,14 +352,14 @@ } } - $insert = array( - 'threads' => array( + $insert = [ + 'threads' => [ 'message' => 'searchprofile-threads', 'tooltip' => 'searchprofile-threads-tooltip', 'namespaces' => $namespaces, 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ), - ), - ); + ], + ]; // Insert translations before 'all' $index = array_search( 'all', array_keys( $profiles ) ); @@ -548,13 +548,13 @@ // Add new messages link. $url = SpecialPage::getTitleFor( 'NewMessages' )->getLocalURL(); $msg = $newMessagesCount ? 'lqt-newmessages-n' : 'lqt_newmessages'; - $newMessagesLink = array( + $newMessagesLink = [ 'href' => $url, 'text' => wfMessage( $msg )->numParams( $newMessagesCount )->text(), 'active' => $newMessagesCount > 0, - ); + ]; - $insertUrls = array( 'newmessages' => $newMessagesLink ); + $insertUrls = [ 'newmessages' => $newMessagesLink ]; // User has viewmywatchlist permission if ( in_array( 'watchlist', array_keys( $personal_urls ) ) ) { @@ -609,12 +609,12 @@ } LqtView::editMetadataUpdates( - array( + [ 'root' => $article, 'thread' => $thread, 'summary' => $summary, 'text' => ContentHandler::getContentText( $content ), - ) ); + ] ); return true; } @@ -689,8 +689,8 @@ return true; } - $pageInfo['DiscussionThreading'] = array(); - $fields = array( + $pageInfo['DiscussionThreading'] = []; + $fields = [ 'ThreadSubject', 'ThreadParent', 'ThreadAncestor', @@ -701,7 +701,7 @@ 'ThreadEditStatus', 'ThreadType', 'ThreadSignature', - ); + ]; $skip = false; @@ -740,7 +740,7 @@ $pendingRelationships = self::loadPendingRelationships(); } - $titlePendingRelationships = array(); + $titlePendingRelationships = []; if ( isset( $pendingRelationships[$title->getPrefixedText()] ) ) { $titlePendingRelationships = $pendingRelationships[$title->getPrefixedText()]; @@ -831,12 +831,12 @@ $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'thread', array( $pendingRelationship['relationship'] => $articleID ), - array( 'thread_id' => $pendingRelationship['thread'] ), + $dbw->update( 'thread', [ $pendingRelationship['relationship'] => $articleID ], + [ 'thread_id' => $pendingRelationship['thread'] ], __METHOD__ ); $dbw->delete( 'thread_pending_relationship', - array( 'tpr_title' => $pendingRelationship['title'] ), __METHOD__ ); + [ 'tpr_title' => $pendingRelationship['title'] ], __METHOD__ ); } /** @@ -844,21 +844,21 @@ */ public static function loadPendingRelationships() { $dbr = wfGetDB( DB_MASTER ); - $arr = array(); + $arr = []; - $res = $dbr->select( 'thread_pending_relationship', '*', array( 1 ), __METHOD__ ); + $res = $dbr->select( 'thread_pending_relationship', '*', [ 1 ], __METHOD__ ); foreach ( $res as $row ) { $title = $row->tpr_title; - $entry = array( + $entry = [ 'thread' => $row->tpr_thread, 'relationship' => $row->tpr_relationship, 'title' => $title, 'type' => $row->tpr_type, - ); + ]; if ( !isset( $arr[$title] ) ) { - $arr[$title] = array(); + $arr[$title] = []; } $arr[$title][] = $entry; @@ -870,14 +870,14 @@ public static function addPendingRelationship( $thread, $relationship, $title, $type, &$array ) { - $entry = array( + $entry = [ 'thread' => $thread, 'relationship' => $relationship, 'title' => $title, 'type' => $type, - ); + ]; - $row = array(); + $row = []; foreach ( $entry as $k => $v ) { $row['tpr_' . $k] = $v; } @@ -886,7 +886,7 @@ $dbw->insert( 'thread_pending_relationship', $row, __METHOD__ ); if ( !isset( $array[$title] ) ) { - $array[$title] = array(); + $array[$title] = []; } $array[$title][] = $entry; @@ -931,19 +931,19 @@ public static function onParserFirstCallInit( $parser ) { $parser->setFunctionHook( 'useliquidthreads', - array( 'LqtParserFunctions', 'useLiquidThreads' ) + [ 'LqtParserFunctions', 'useLiquidThreads' ] ); $parser->setFunctionHook( 'lqtpagelimit', - array( 'LqtParserFunctions', 'lqtPageLimit' ) + [ 'LqtParserFunctions', 'lqtPageLimit' ] ); global $wgLiquidThreadsAllowEmbedding; if ( $wgLiquidThreadsAllowEmbedding ) { - $parser->setHook( 'talkpage', array( 'LqtParserFunctions', 'lqtTalkPage' ) ); - $parser->setHook( 'thread', array( 'LqtParserFunctions', 'lqtThread' ) ); + $parser->setHook( 'talkpage', [ 'LqtParserFunctions', 'lqtTalkPage' ] ); + $parser->setHook( 'thread', [ 'LqtParserFunctions', 'lqtThread' ] ); } return true; @@ -965,9 +965,9 @@ if ( $module instanceof ApiQueryInfo ) { $result = $module->getResult(); - $data = (array)$result->getResultData( array( 'query', 'pages' ), array( + $data = (array)$result->getResultData( [ 'query', 'pages' ], [ 'Strip' => 'base' - ) ); + ] ); foreach ( $data as $pageid => $page ) { if ( $page == 'page' ) { continue; @@ -977,9 +977,9 @@ && LqtDispatch::isLqtPage( Title::newFromText( $page['title'] ) ) ) { $result->addValue( - array( 'query', 'pages' ), + [ 'query', 'pages' ], $pageid, - array( 'islqttalkpage' => '' ) + [ 'islqttalkpage' => '' ] ); } } @@ -990,9 +990,9 @@ public static function onInfoAction( $context, $pageInfo ) { if ( LqtDispatch::isLqtPage( $context->getTitle() ) ) { - $pageInfo['header-basic'][] = array( + $pageInfo['header-basic'][] = [ wfMessage( 'pageinfo-usinglqt' ), wfMessage( 'pageinfo-usinglqt-yes' ) - ); + ]; } return true; diff --git a/classes/LogFormatter.php b/classes/LogFormatter.php index b0feeff..60b6e22 100644 --- a/classes/LogFormatter.php +++ b/classes/LogFormatter.php @@ -27,8 +27,8 @@ $parameters[] = Message::rawParam( $linkRenderer->makeLink( SpecialPage::getTitleFor( 'MoveThread', $title ), wfMessage( 'revertmove' )->text(), - array(), - array( 'dest' => $parameters[0] ) + [], + [ 'dest' => $parameters[0] ] ) ); } else { $parameters[] = ''; diff --git a/classes/NewMessagesController.php b/classes/NewMessagesController.php index 23d953f..6c6e5e5 100644 --- a/classes/NewMessagesController.php +++ b/classes/NewMessagesController.php @@ -26,7 +26,7 @@ $dbw->delete( 'user_message_state', - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id ), + [ 'ums_user' => $user_id, 'ums_thread' => $thread_id ], __METHOD__ ); @@ -46,7 +46,7 @@ $dbw->delete( 'user_message_state', - array( 'ums_user' => $user_id ), + [ 'ums_user' => $user_id ], __METHOD__ ); @@ -74,9 +74,9 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->replace( - 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id, - 'ums_read_timestamp' => $timestamp, 'ums_conversation' => $conversation ), + 'user_message_state', [ [ 'ums_user', 'ums_thread' ] ], + [ 'ums_user' => $user_id, 'ums_thread' => $thread_id, + 'ums_read_timestamp' => $timestamp, 'ums_conversation' => $conversation ], __METHOD__ ); @@ -94,45 +94,45 @@ $rootThread = $t->topmostThread()->root()->getTitle(); // Select any applicable watchlist entries for the thread. - $talkpageWhere = array( + $talkpageWhere = [ 'wl_namespace' => $tpTitle->getNamespace(), 'wl_title' => $tpTitle->getDBkey() - ); - $rootWhere = array( + ]; + $rootWhere = [ 'wl_namespace' => $rootThread->getNamespace(), 'wl_title' => $rootThread->getDBkey() - ); + ]; $talkpageWhere = $dbw->makeList( $talkpageWhere, LIST_AND ); $rootWhere = $dbw->makeList( $rootWhere, LIST_AND ); - return $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR ); + return $dbw->makeList( [ $talkpageWhere, $rootWhere ], LIST_OR ); } private static function getRowsObject( $t ) { - $tables = array( 'watchlist', 'user_message_state', 'user_properties' ); - $joins = array( + $tables = [ 'watchlist', 'user_message_state', 'user_properties' ]; + $joins = [ 'user_message_state' => - array( + [ 'LEFT JOIN', - array( + [ 'ums_user=wl_user', 'ums_thread' => $t->id() - ) - ), + ] + ], 'user_properties' => - array( + [ 'LEFT JOIN', - array( + [ 'up_user=wl_user', 'up_property' => 'lqtnotifytalk', - ) - ) - ); - $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp', 'up_value' ); + ] + ] + ]; + $fields = [ 'wl_user', 'ums_user', 'ums_read_timestamp', 'up_value' ]; $dbr = wfGetDB( DB_SLAVE ); - return $dbr->select( $tables, $fields, self::getWhereClause( $t ), __METHOD__, array(), $joins ); + return $dbr->select( $tables, $fields, self::getWhereClause( $t ), __METHOD__, [], $joins ); } /** @@ -149,18 +149,18 @@ // Do the actual updates if ( count( $userIds ) ) { foreach ( $userIds as $u ) { - $insertRows[] = array( + $insertRows[] = [ 'ums_user' => $u, 'ums_thread' => $t->id(), 'ums_read_timestamp' => null, 'ums_conversation' => $t->topmostThread()->id(), - ); + ]; } $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'user_message_state', - array( array( 'ums_user', 'ums_thread' ) ), + [ [ 'ums_user', 'ums_thread' ] ], $insertRows, __METHOD__ ); } @@ -175,8 +175,8 @@ // Pull users to update the message state for, including whether or not a // user_message_state row exists for them, and whether or not to send an email // notification. - $userIds = array(); - $notifyUsers = array(); + $userIds = []; + $notifyUsers = []; $res = self::getRowsObject( $t ); foreach ( $res as $row ) { // Don't notify yourself @@ -216,19 +216,19 @@ } } - return array( + return [ 'notify' => $userIds, 'email' => $notifyUsers, - ); + ]; } // Would refactor User::decodeOptions, but the whole point is that this is // compatible with old code :) static function decodeUserOptions( $str ) { - $opts = array(); + $opts = []; $a = explode( "\n", $str ); foreach ( $a as $s ) { - $m = array(); + $m = []; if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) { $opts[$m[1]] = $m[2]; } @@ -238,14 +238,14 @@ } static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) { - $messages = array( + $messages = [ Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-newthread', - ); - $subjects = array( + ]; + $subjects = [ Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread', - ); + ]; if ( !isset( $messages[$type] ) || !isset( $subjects[$type] ) ) { wfDebugLog( 'LiquidThreads', "Email notification failed: type $type unrecognised" ); @@ -258,39 +258,39 @@ // Send email notification, fetching all the data in one go $dbr = wfGetDB( DB_SLAVE ); - $tables = array( + $tables = [ 'user', 'tc_prop' => 'user_properties', 'l_prop' => 'user_properties' - ); + ]; - $fields = array( + $fields = [ $dbr->tableName( 'user' ) . '.*', 'tc_prop.up_value AS timecorrection', 'l_prop.up_value as language' - ); + ]; - $join_conds = array( - 'tc_prop' => array( + $join_conds = [ + 'tc_prop' => [ 'LEFT JOIN', - array( + [ 'tc_prop.up_user=user_id', 'tc_prop.up_property' => 'timecorrection', - ) - ), - 'l_prop' => array( + ] + ], + 'l_prop' => [ 'LEFT JOIN', - array( + [ 'l_prop.up_user=user_id', 'l_prop.up_property' => 'language', - ) - ) - ); + ] + ] + ]; $res = $dbr->select( $tables, $fields, - array( 'user_id' => $watching_users ), __METHOD__, - array(), $join_conds + [ 'user_id' => $watching_users ], __METHOD__, + [], $join_conds ); // Set up one-time data. @@ -323,7 +323,7 @@ $date = $lang->date( $adjustedTimestamp ); $time = $lang->time( $adjustedTimestamp ); - $params = array( + $params = [ $u->getName(), $t->subjectWithoutIncrement(), $date, @@ -332,7 +332,7 @@ $permalink, ContentHandler::getContentText( $t->root()->getPage()->getContent() ), $t->author()->getName() - ); + ]; // Get message in user's own language, bug 20645 $msg = wfMessage( $msgName, $params )->inLanguage( $langCode )->text(); @@ -349,29 +349,29 @@ $dbr = wfGetDB( DB_SLAVE ); - $joinConds = array( 'ums_user' => null ); + $joinConds = [ 'ums_user' => null ]; $joinConds[] = $dbr->makeList( - array( + [ 'ums_user' => $user->getId(), 'ums_thread=thread_id' - ), + ], LIST_AND ); $joinClause = $dbr->makeList( $joinConds, LIST_OR ); $res = $dbr->select( - array( 'thread', 'user_message_state' ), + [ 'thread', 'user_message_state' ], '*', - array( + [ 'ums_read_timestamp' => null, Threads::articleClause( $talkPage ) - ), + ], __METHOD__, - array(), - array( + [], + [ 'thread' => - array( 'LEFT JOIN', $joinClause ) - ) + [ 'LEFT JOIN', $joinClause ] + ] ); return Threads::loadFromResult( $res, $dbr ); @@ -388,8 +388,8 @@ $dbr = wfGetDB( $db ); - $cond = array( 'ums_user' => $user->getId(), 'ums_read_timestamp' => null ); - $options = array( 'LIMIT' => 500 ); + $cond = [ 'ums_user' => $user->getId(), 'ums_read_timestamp' => null ]; + $options = [ 'LIMIT' => 500 ]; $res = $dbr->select( 'user_message_state', '1', $cond, __METHOD__, $options ); @@ -422,19 +422,19 @@ $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'thread', 'user_message_state' ), + [ 'thread', 'user_message_state' ], '*', - array( + [ 'ums_read_timestamp' => null, 'ums_user' => $user->getId(), 'not (' . Threads::articleClause( $talkPage ) . ')', - ), + ], __METHOD__, - array(), - array( + [], + [ 'user_message_state' => - array( 'INNER JOIN', 'ums_thread=thread_id' ), - ) + [ 'INNER JOIN', 'ums_thread=thread_id' ], + ] ); return Threads::loadFromResult( $res, $dbr ); diff --git a/classes/ParserFunctions.php b/classes/ParserFunctions.php index 2dcfedc..50060b6 100644 --- a/classes/ParserFunctions.php +++ b/classes/ParserFunctions.php @@ -1,7 +1,7 @@ <?php class LqtParserFunctions { static function useLiquidThreads( &$parser, $param = '1' ) { - $offParams = array( 'no', 'off', 'disable' ); + $offParams = [ 'no', 'off', 'disable' ]; // Figure out if they want to turn it off or on. $param = trim( strtolower( $param ) ); @@ -39,16 +39,16 @@ $talkpage = new Article( $title, 0 ); $article = new Article( $parser->getTitle(), 0 ); - $data = array( + $data = [ 'type' => 'talkpage', 'args' => $args, 'article' => $article, 'title' => $article->getTitle(), 'talkpage' => $talkpage, - ); + ]; if ( !isset( $pout->mLqtReplacements ) ) { - $pout->mLqtReplacements = array(); + $pout->mLqtReplacements = []; } // Generate a token @@ -78,15 +78,15 @@ return ''; } - $data = array( + $data = [ 'type' => 'thread', 'args' => $args, 'thread' => $thread->id(), 'title' => $thread->title(), - ); + ]; if ( !isset( $pout->mLqtReplacements ) ) { - $pout->mLqtReplacements = array(); + $pout->mLqtReplacements = []; } // Generate a token @@ -155,7 +155,7 @@ } if ( !isset( $out->mLqtReplacements ) ) { - $out->mLqtReplacements = array(); + $out->mLqtReplacements = []; } foreach ( $pout->mLqtReplacements as $text => $details ) { diff --git a/classes/Thread.php b/classes/Thread.php index c6da7e4..a8abbae 100644 --- a/classes/Thread.php +++ b/classes/Thread.php @@ -48,13 +48,13 @@ public $dbVersion; // A copy of the thread as it exists in the database. - public static $titleCacheById = array(); - public static $replyCacheById = array(); - public static $articleCacheById = array(); - public static $reactionCacheById = array(); + public static $titleCacheById = []; + public static $replyCacheById = []; + public static $articleCacheById = []; + public static $reactionCacheById = []; - public static $VALID_TYPES = array( - Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED ); + public static $VALID_TYPES = [ + Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED ]; public function isHistorical() { return $this->isHistorical; @@ -206,18 +206,18 @@ switch ( $change_type ) { case Threads::CHANGE_MOVED_TALKPAGE: $log->addEntry( 'move', $this->title(), $reason, - array( $original->getTitle(), - $this->getTitle() ) ); + [ $original->getTitle(), + $this->getTitle() ] ); break; case Threads::CHANGE_SPLIT: $log->addEntry( 'split', $this->title(), $reason, - array( $this->subject(), + [ $this->subject(), $original->superthread()->title() - ) ); + ] ); break; case Threads::CHANGE_EDITED_SUBJECT: $log->addEntry( 'subjectedit', $this->title(), $reason, - array( $original->subject(), $this->subject() ) ); + [ $original->subject(), $this->subject() ] ); break; case Threads::CHANGE_MERGED_TO: $oldParent = $change_object->dbVersion->isTopmostThread() @@ -225,14 +225,14 @@ : $change_object->dbVersion->superthread()->title(); $log->addEntry( 'merge', $this->title(), $reason, - array( $oldParent, $change_object->superthread()->title() ) ); + [ $oldParent, $change_object->superthread()->title() ] ); break; case Threads::CHANGE_ADJUSTED_SORTKEY: $log->addEntry( 'resort', $this->title(), $reason, - array( $original->sortkey(), $this->sortkey() ) ); + [ $original->sortkey(), $this->sortkey() ] ); case Threads::CHANGE_EDITED_SIGNATURE: $log->addEntry( 'signatureedit', $this->title(), $reason, - array( $original->signature(), $this->signature() ) ); + [ $original->signature(), $this->signature() ] ); break; } } @@ -269,7 +269,7 @@ $dbr->update( 'thread', /* SET */ $this->getRow(), - /* WHERE */ array( 'thread_id' => $this->id, ), + /* WHERE */ [ 'thread_id' => $this->id, ], $fname ); // Touch the root @@ -308,7 +308,7 @@ // Reflect schema changes here. - return array( + return [ 'thread_id' => $id, 'thread_root' => $this->rootId, 'thread_parent' => $this->parentId, @@ -327,7 +327,7 @@ 'thread_sortkey' => $this->sortkey, 'thread_replies' => $this->replyCount, 'thread_signature' => $this->signature, - ); + ]; } public function author() { @@ -357,7 +357,7 @@ $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'user_message_state', array( 'ums_thread' => $this->id() ), + $dbw->delete( 'user_message_state', [ 'ums_thread' => $this->id() ], __METHOD__ ); // Fix reply count. @@ -408,12 +408,12 @@ // Update on *all* subthreads. $dbr->update( 'thread', - array( + [ 'thread_article_namespace' => $new_articleNamespace, 'thread_article_title' => $new_articleTitle, 'thread_article_id' => $new_articleID, - ), - array( 'thread_ancestor' => $this->id() ), + ], + [ 'thread_ancestor' => $this->id() ], __METHOD__ ); @@ -468,7 +468,7 @@ $dbr = wfGetDB( DB_SLAVE ); $count = $dbr->selectField( 'thread', 'count(*)', - array( 'thread_ancestor' => $this->id() ), __METHOD__ ); + [ 'thread_ancestor' => $this->id() ], __METHOD__ ); } else { $count = self::recursiveGetReplyCount( $this ); } @@ -523,7 +523,7 @@ return; } - $dataLoads = array( + $dataLoads = [ 'thread_id' => 'id', 'thread_root' => 'rootId', 'thread_article_namespace' => 'articleNamespace', @@ -542,7 +542,7 @@ 'thread_sortkey' => 'sortkey', 'thread_replies' => 'replyCount', 'thread_signature' => 'signature', - ); + ]; foreach ( $dataLoads as $db_field => $member_field ) { if ( isset( $line->$db_field ) ) { @@ -569,7 +569,7 @@ Threads::$cache_by_id[$line->thread_id] = $this; if ( $line->thread_parent ) { if ( !isset( self::$replyCacheById[$line->thread_parent] ) ) { - self::$replyCacheById[$line->thread_parent] = array(); + self::$replyCacheById[$line->thread_parent] = []; } self::$replyCacheById[$line->thread_parent][$line->thread_id] = $this; } @@ -587,17 +587,17 @@ // Load a list of threads in bulk, including all subthreads. public static function bulkLoad( $rows ) { // Preload subthreads - $top_thread_ids = array(); + $top_thread_ids = []; $all_thread_rows = $rows; - $pageIds = array(); + $pageIds = []; $linkBatch = new LinkBatch(); - $userIds = array(); - $loadEditorsFor = array(); + $userIds = []; + $loadEditorsFor = []; $dbr = wfGetDB( DB_SLAVE ); if ( !is_array( self::$replyCacheById ) ) { - self::$replyCacheById = array(); + self::$replyCacheById = []; } // Build a list of threads for which to pull replies, and page IDs to pull data for. @@ -617,7 +617,7 @@ $pageIds[] = $row->thread_summary_page; } if ( !isset( self::$replyCacheById[$row->thread_id] ) ) { - self::$replyCacheById[$row->thread_id] = array(); + self::$replyCacheById[$row->thread_id] = []; } } @@ -627,8 +627,8 @@ // pre-initialise the reply cache, and stash the row object for later use. if ( count( $top_thread_ids ) ) { $res = $dbr->select( 'thread', '*', - array( 'thread_ancestor' => $top_thread_ids, - 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ), + [ 'thread_ancestor' => $top_thread_ids, + 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ], __METHOD__ ); foreach ( $res as $row ) { @@ -647,27 +647,27 @@ // Pull thread reactions if ( count( $all_thread_ids ) ) { $res = $dbr->select( 'thread_reaction', '*', - array( 'tr_thread' => $all_thread_ids ), + [ 'tr_thread' => $all_thread_ids ], __METHOD__ ); foreach ( $res as $row ) { $thread_id = $row->tr_thread; - $info = array( + $info = [ 'type' => $row->tr_type, 'user-id' => $row->tr_user, 'user-name' => $row->tr_user_text, 'value' => $row->tr_value, - ); + ]; $type = $info['type']; $user = $info['user-name']; if ( ! isset( self::$reactionCacheById[$thread_id] ) ) { - self::$reactionCacheById[$thread_id] = array(); + self::$reactionCacheById[$thread_id] = []; } if ( ! isset( self::$reactionCacheById[$thread_id][$type] ) ) { - self::$reactionCacheById[$thread_id][$type] = array(); + self::$reactionCacheById[$thread_id][$type] = []; } self::$reactionCacheById[$thread_id][$type][$user] = $info; @@ -676,18 +676,18 @@ // Preload page data (restrictions, and preload Article object with everything from // the page table. Also, precache the title and article objects for pulling later. - $articlesById = array(); + $articlesById = []; if ( count( $pageIds ) ) { // Pull restriction info. Needs to come first because otherwise it's done per // page by loadPageData. - $restrictionRows = array_fill_keys( $pageIds, array() ); - $res = $dbr->select( 'page_restrictions', '*', array( 'pr_page' => $pageIds ), + $restrictionRows = array_fill_keys( $pageIds, [] ); + $res = $dbr->select( 'page_restrictions', '*', [ 'pr_page' => $pageIds ], __METHOD__ ); foreach ( $res as $row ) { $restrictionRows[$row->pr_page][] = $row; } - $res = $dbr->select( 'page', '*', array( 'page_id' => $pageIds ), __METHOD__ ); + $res = $dbr->select( 'page', '*', [ 'page_id' => $pageIds ], __METHOD__ ); foreach ( $res as $row ) { $t = Title::newFromRow( $row ); @@ -704,7 +704,7 @@ $articlesById[$article->getId()] = $article; if ( count( self::$titleCacheById ) > 10000 ) { - self::$titleCacheById = array(); + self::$titleCacheById = []; } } } @@ -730,15 +730,15 @@ if ( $row->thread_editedness > Threads::EDITED_BY_AUTHOR ) { $loadEditorsFor[$row->thread_root] = $thread; - $thread->setEditors( array() ); + $thread->setEditors( [] ); } } // Pull list of users who have edited if ( count( $loadEditorsFor ) ) { - $res = $dbr->select( 'revision', array( 'rev_user_text', 'rev_page' ), - array( 'rev_page' => array_keys( $loadEditorsFor ), - 'rev_parent_id != ' . $dbr->addQuotes( 0 ) ), + $res = $dbr->select( 'revision', [ 'rev_user_text', 'rev_page' ], + [ 'rev_page' => array_keys( $loadEditorsFor ), + 'rev_parent_id != ' . $dbr->addQuotes( 0 ) ], __METHOD__ ); foreach ( $res as $row ) { $pageid = $row->rev_page; @@ -752,7 +752,7 @@ // Pull link batch data. $linkBatch->execute(); - $threads = array(); + $threads = []; // Fill and return an array with the threads that were actually requested. foreach ( $rows as $row ) { @@ -776,12 +776,12 @@ $line = $dbr->selectRow( 'revision', 'rev_user_text', - array( 'rev_page' => $article->getID() ), + [ 'rev_page' => $article->getID() ], __METHOD__, - array( + [ 'ORDER BY' => 'rev_timestamp', 'LIMIT' => '1' - ) + ] ); if ( $line ) { return User::newFromName( $line->rev_user_text, false ); @@ -830,7 +830,7 @@ $ancestor = $this->topmostThread(); - $set = array(); + $set = []; // Fix missing subject information // (this information only started to be added later) @@ -957,7 +957,7 @@ if ( count( $set ) ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'thread', $set, array( 'thread_id' => $this->id() ), __METHOD__ ); + $dbw->update( 'thread', $set, [ 'thread_id' => $this->id() ], __METHOD__ ); } // Done @@ -1016,7 +1016,7 @@ public function replies() { if ( !$this->id() ) { - return array(); + return []; } if ( !is_null( $this->replies ) ) { @@ -1031,16 +1031,16 @@ return $this->replies = self::$replyCacheById[$this->id()]; } - $this->replies = array(); + $this->replies = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'thread', '*', - array( 'thread_parent' => $this->id(), - 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ), + [ 'thread_parent' => $this->id(), + 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ], __METHOD__ ); - $rows = array(); + $rows = []; foreach ( $res as $row ) { $rows[] = $row; } @@ -1129,8 +1129,8 @@ $this->ancestorId = $thread->id(); $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ), - array( 'thread_id' => $this->id() ), __METHOD__ ); + $dbw->update( 'thread', [ 'thread_ancestor' => $thread->id() ], + [ 'thread_id' => $this->id() ], __METHOD__ ); return $thread; } @@ -1401,8 +1401,8 @@ $fields = array_keys( get_object_vars( $this ) ); // Filter out article objects, there be dragons (or unserialization problems) - $fields = array_diff( $fields, array( 'root', 'article', 'summary', 'sleeping', - 'dbVersion' ) ); + $fields = array_diff( $fields, [ 'root', 'article', 'summary', 'sleeping', + 'dbVersion' ] ); return $fields; } @@ -1433,16 +1433,16 @@ $revision = $this->topmostThread()->threadRevision; $timestamp = $dbr->timestamp( $revision->getTimestamp() ); - $conds = array( + $conds = [ 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ), 'page_namespace' => $this->root()->getTitle()->getNamespace(), 'page_title' => $this->root()->getTitle()->getDBKey(), - ); + ]; - $join_conds = array( 'page' => array( 'JOIN', 'rev_page=page_id' ) ); + $join_conds = [ 'page' => [ 'JOIN', 'rev_page=page_id' ] ]; - $row = $dbr->selectRow( array( 'revision', 'page' ), '*', $conds, __METHOD__, - array( 'ORDER BY' => 'rev_timestamp DESC' ), $join_conds ); + $row = $dbr->selectRow( [ 'revision', 'page' ], '*', $conds, __METHOD__, + [ 'ORDER BY' => 'rev_timestamp DESC' ], $join_conds ); return $row->rev_id; } @@ -1616,7 +1616,7 @@ public static function canUserCreateThreads( $user, $rigor = 'secure' ) { $userText = $user->getName(); - static $canCreateNew = array(); + static $canCreateNew = []; if ( !isset( $canCreateNew[$userText] ) ) { $title = Title::makeTitleSafe( NS_LQT_THREAD, 'Test title for LQT thread creation check' ); @@ -1639,18 +1639,18 @@ public function editors() { if ( is_null( $this->editors ) ) { if ( $this->editedness() < Threads::EDITED_BY_AUTHOR ) { - return array(); + return []; } elseif ( $this->editedness == Threads::EDITED_BY_AUTHOR ) { - return array( $this->author()->getName() ); + return [ $this->author()->getName() ]; } // Load editors - $this->editors = array(); + $this->editors = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'revision', 'rev_user_text', - array( 'rev_page' => $this->root()->getId(), - 'rev_parent_id != ' . $dbr->addQuotes( 0 ) ), __METHOD__ ); + [ 'rev_page' => $this->root()->getId(), + 'rev_parent_id != ' . $dbr->addQuotes( 0 ) ], __METHOD__ ); foreach ( $res as $row ) { $this->editors[$row->rev_user_text] = 1; @@ -1683,26 +1683,26 @@ if ( isset( self::$reactionCacheById[$this->id()] ) ) { $this->reactions = self::$reactionCacheById[$this->id()]; } else { - $reactions = array(); + $reactions = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'thread_reaction', - array( 'tr_thread' => $this->id() ), + [ 'tr_thread' => $this->id() ], __METHOD__ ); foreach ( $res as $row ) { $user = $row->tr_user_text; $type = $row->tr_type; - $info = array( + $info = [ 'type' => $type, 'user-id' => $row->tr_user, 'user-name' => $row->tr_user_text, 'value' => $row->tr_value, - ); + ]; if ( ! isset( $reactions[$type] ) ) { - $reactions[$type] = array(); + $reactions[$type] = []; } $reactions[$type][$user] = $info; @@ -1720,26 +1720,26 @@ } public function addReaction( $user, $type, $value ) { - $info = array( + $info = [ 'type' => $type, 'user-id' => $user->getId(), 'user-name' => $user->getName(), 'value' => $value, - ); + ]; if ( ! isset( $this->reactions[$type] ) ) { - $this->reactions[$type] = array(); + $this->reactions[$type] = []; } $this->reactions[$type][$user->getName()] = $info; - $row = array( + $row = [ 'tr_type' => $type, 'tr_thread' => $this->id(), 'tr_user' => $user->getId(), 'tr_user_text' => $user->getName(), 'tr_value' => $value, - ); + ]; $dbw = wfGetDB( DB_MASTER ); @@ -1754,9 +1754,9 @@ } $dbw->delete( 'thread_reaction', - array( 'tr_thread' => $this->id(), + [ 'tr_thread' => $this->id(), 'tr_user' => $user->getId(), - 'tr_type' => $type ), + 'tr_type' => $type ], __METHOD__ ); } } diff --git a/classes/ThreadHistoryPager.php b/classes/ThreadHistoryPager.php index 12102cc..285db0c 100644 --- a/classes/ThreadHistoryPager.php +++ b/classes/ThreadHistoryPager.php @@ -13,7 +13,7 @@ $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); self::$change_names = - array( + [ Threads::CHANGE_EDITED_ROOT => wfMessage( 'lqt_hist_comment_edited' )->plain(), Threads::CHANGE_EDITED_SUMMARY => wfMessage( 'lqt_hist_summary_changed' )->plain(), Threads::CHANGE_REPLY_CREATED => wfMessage( 'lqt_hist_reply_created' )->plain(), @@ -28,27 +28,27 @@ Threads::CHANGE_SPLIT_FROM => wfMessage( 'lqt_hist_split_from' )->plain(), Threads::CHANGE_ROOT_BLANKED => wfMessage( 'lqt_hist_root_blanked' )->plain(), Threads::CHANGE_ADJUSTED_SORTKEY => wfMessage( 'lqt_hist_adjusted_sortkey' )->plain() - ); + ]; } public function getQueryInfo() { - $queryInfo = array( - 'tables' => array( 'thread_history' ), + $queryInfo = [ + 'tables' => [ 'thread_history' ], 'fields' => '*', - 'conds' => array( 'th_thread' => $this->thread->id() ), - 'options' => array( 'order by' => 'th_timestamp desc' ), - ); + 'conds' => [ 'th_thread' => $this->thread->id() ], + 'options' => [ 'order by' => 'th_timestamp desc' ], + ]; return $queryInfo; } public function getFieldMessages() { - $headers = array( + $headers = [ 'th_timestamp' => $this->msg( 'lqt-history-time' )->text(), 'th_user_text' => $this->msg( 'lqt-history-user' )->text(), 'th_change_type' => $this->msg( 'lqt-history-action' )->text(), 'th_change_comment' => $this->msg( 'lqt-history-comment' )->text(), - ); + ]; return $headers; } @@ -74,8 +74,8 @@ return $this->linkRenderer->makeLink( $wgTitle, $formatted, - array(), - array( 'lqt_oldid' => $row->th_id ) + [], + [ 'lqt_oldid' => $row->th_id ] ); case 'th_user_text': return Linker::userLink( @@ -96,7 +96,7 @@ public function getActionDescription( $type ) { global $wgOut; - $args = array(); + $args = []; $revision = ThreadRevision::loadFromRow( $this->mCurrentRow ); $changeObject = $revision->getChangeObject(); @@ -144,7 +144,7 @@ $content = wfMsgReplaceArgs( $msg, $args ); return Html::rawElement( - 'span', array( 'class' => 'plainlinks' ), $wgOut->parseInline( $content ) + 'span', [ 'class' => 'plainlinks' ], $wgOut->parseInline( $content ) ); } @@ -157,7 +157,7 @@ } public function isFieldSortable( $name ) { - $sortable_fields = array( 'th_timestamp', 'th_user_text', 'th_change_type' ); + $sortable_fields = [ 'th_timestamp', 'th_user_text', 'th_change_type' ]; return in_array( $name, $sortable_fields ); } diff --git a/classes/ThreadRevision.php b/classes/ThreadRevision.php index 266e510..313d40b 100644 --- a/classes/ThreadRevision.php +++ b/classes/ThreadRevision.php @@ -2,7 +2,7 @@ class ThreadRevision { public static $load = - array( + [ 'th_id' => 'mId', 'th_thread' => 'mThreadId', @@ -15,14 +15,14 @@ 'th_change_object' => 'mChangeObjectId', 'th_change_comment' => 'mChangeComment', 'th_content' => 'mObjSer', - ); + ]; protected $mId, $mThreadId, $mTimestamp, $mUserId, $mUserText, $mChangeType, $mChangeObjectId, $mChangeObject, $mChangeComment, $mObjSer, $mThreadObj; public static function loadFromId( $id ) { $dbr = wfGetDB( DB_SLAVE ); - $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' => $id ), __METHOD__ ); + $row = $dbr->selectRow( 'thread_history', '*', [ 'th_id' => $id ], __METHOD__ ); if ( !$row ) { return null; @@ -114,11 +114,11 @@ $dbw = wfGetDB( DB_MASTER ); - $dbw->replace( 'thread_history', array( 'th_thread' ), $row, __METHOD__ ); + $dbw->replace( 'thread_history', [ 'th_thread' ], $row, __METHOD__ ); } public function getRow() { - $row = array(); + $row = []; // First, prep the data for insertion $dbw = wfGetDB( DB_MASTER ); @@ -195,7 +195,7 @@ $cond = 'th_id<' . $dbr->addQuotes( intval( $this->getId() ) ); $row = $dbr->selectRow( 'thread_history', '*', - array( $cond, 'th_thread' => $this->mThreadId ), + [ $cond, 'th_thread' => $this->mThreadId ], __METHOD__ ); return self::loadFromRow( $row ); @@ -206,7 +206,7 @@ $cond = 'th_id>' . $dbr->addQuotes( intval( $this->getId() ) ); $row = $dbr->selectRow( 'thread_history', '*', - array( $cond, 'th_thread' => $this->mThreadId ), + [ $cond, 'th_thread' => $this->mThreadId ], __METHOD__ ); return self::loadFromRow( $row ); diff --git a/classes/Threads.php b/classes/Threads.php index 6da8c88..b31ff90 100644 --- a/classes/Threads.php +++ b/classes/Threads.php @@ -24,7 +24,7 @@ const CHANGE_ADJUSTED_SORTKEY = 14; const CHANGE_EDITED_SIGNATURE = 15; - public static $VALID_CHANGE_TYPES = array( + public static $VALID_CHANGE_TYPES = [ self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT, self::CHANGE_REPLY_CREATED, @@ -41,7 +41,7 @@ self::CHANGE_ROOT_BLANKED, self::CHANGE_ADJUSTED_SORTKEY, self::CHANGE_EDITED_SIGNATURE, - ); + ]; // Possible values of Thread->editedness. const EDITED_NEVER = 0; @@ -49,9 +49,9 @@ const EDITED_BY_AUTHOR = 2; const EDITED_BY_OTHERS = 3; - public static $cache_by_root = array(); - public static $cache_by_id = array(); - public static $occupied_titles = array(); + public static $cache_by_root = []; + public static $cache_by_id = []; + public static $occupied_titles = []; /** * Create the talkpage if it doesn't exist so that links to it @@ -76,8 +76,8 @@ } public static function loadFromResult( $res, $db, $bulkLoad = false ) { - $rows = array(); - $threads = array(); + $rows = []; + $threads = []; foreach ( $res as $row ) { $rows[] = $row; @@ -94,7 +94,7 @@ return Thread::bulkLoad( $rows ); } - public static function where( $where, $options = array(), $bulkLoad = true ) { + public static function where( $where, $options = [], $bulkLoad = true ) { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'thread', '*', $where, __METHOD__, $options ); @@ -151,7 +151,7 @@ return self::$cache_by_root[$post->getId()]; } - $ts = Threads::where( array( 'thread_root' => $post->getId() ), array(), $bulkLoad ); + $ts = Threads::where( [ 'thread_root' => $post->getId() ], [], $bulkLoad ); return self::assertSingularity( $ts, 'thread_root', $post->getId() ); } @@ -166,7 +166,7 @@ return self::$cache_by_id[$id]; } - $ts = Threads::where( array( 'thread_id' => $id ), array(), $bulkLoad ); + $ts = Threads::where( [ 'thread_id' => $id ], [], $bulkLoad ); return self::assertSingularity( $ts, 'thread_id', $id ); } @@ -177,22 +177,22 @@ * @return Thread */ public static function withSummary( $article, $bulkLoad = true ) { - $ts = Threads::where( array( 'thread_summary_page' => $article->getId() ), - array(), $bulkLoad ); + $ts = Threads::where( [ 'thread_summary_page' => $article->getId() ], + [], $bulkLoad ); return self::assertSingularity( $ts, 'thread_summary_page', $article->getId() ); } public static function articleClause( $article ) { $dbr = wfGetDB( DB_SLAVE ); - $titleCond = array( 'thread_article_title' => $article->getTitle()->getDBKey(), - 'thread_article_namespace' => $article->getTitle()->getNamespace() ); + $titleCond = [ 'thread_article_title' => $article->getTitle()->getDBKey(), + 'thread_article_namespace' => $article->getTitle()->getNamespace() ]; $titleCond = $dbr->makeList( $titleCond, LIST_AND ); - $conds = array( $titleCond ); + $conds = [ $titleCond ]; if ( $article->getId() ) { - $idCond = array( 'thread_article_id' => $article->getId() ); + $idCond = [ 'thread_article_id' => $article->getId() ]; $conds[] = $dbr->makeList( $idCond, LIST_AND ); } @@ -202,7 +202,7 @@ public static function topLevelClause() { $dbr = wfGetDB( DB_SLAVE ); - $arr = array( 'thread_ancestor=thread_id', 'thread_parent' => null ); + $arr = [ 'thread_ancestor=thread_id', 'thread_parent' => null ]; return $dbr->makeList( $arr, LIST_OR ); } @@ -238,7 +238,7 @@ if ( is_callable( 'MediaWikiTitleCodec::getTitleInvalidRegex' ) ) { $rxTc = MediaWikiTitleCodec::getTitleInvalidRegex(); - } elseif ( is_callable( array( 'Title', 'getTitleInvalidRegex' ) ) ) { // Pre-1.25 compat + } elseif ( is_callable( [ 'Title', 'getTitleInvalidRegex' ] ) ) { // Pre-1.25 compat $rxTc = Title::getTitleInvalidRegex(); } elseif ( !$rxTc ) { // Back-compat $rxTc = '/' . @@ -322,18 +322,18 @@ $title = $article->getTitle(); $id = $article->getId(); - $titleCond = array( 'thread_article_namespace' => $title->getNamespace(), - 'thread_article_title' => $title->getDBkey() ); + $titleCond = [ 'thread_article_namespace' => $title->getNamespace(), + 'thread_article_title' => $title->getDBkey() ]; $titleCondText = $dbr->makeList( $titleCond, LIST_AND ); - $idCond = array( 'thread_article_id' => $id ); + $idCond = [ 'thread_article_id' => $id ]; $idCondText = $dbr->makeList( $idCond, LIST_AND ); - $fixTitleCond = array( $idCondText, "NOT ($titleCondText)" ); - $fixIdCond = array( $titleCondText, "NOT ($idCondText)" ); + $fixTitleCond = [ $idCondText, "NOT ($titleCondText)" ]; + $fixIdCond = [ $titleCondText, "NOT ($idCondText)" ]; // Try to hit the most recent threads first. - $options = array( 'LIMIT' => 500, 'ORDER BY' => 'thread_id DESC' ); + $options = [ 'LIMIT' => 500, 'ORDER BY' => 'thread_id DESC' ]; // Batch in 500s if ( $limit ) { @@ -364,7 +364,7 @@ } if ( $limit && ( $rowsAffected >= $limit ) && $queueMore ) { - $jobParams = array( 'limit' => $limit, 'cascade' => true ); + $jobParams = [ 'limit' => $limit, 'cascade' => true ]; JobQueueGroup::singleton()->push( new SynchroniseThreadArticleDataJob( $article->getTitle(), diff --git a/classes/View.php b/classes/View.php index 67c1c70..6593f6d 100644 --- a/classes/View.php +++ b/classes/View.php @@ -49,7 +49,7 @@ $this->user = $user; $this->title = $title; $this->request = $request; - $this->user_colors = array(); + $this->user_colors = []; $this->user_color_index = 1; } @@ -72,7 +72,7 @@ } static function permalinkUrl( $thread, $method = null, $operand = null, - $uquery = array(), $relative = true ) { + $uquery = [], $relative = true ) { list ( $title, $query ) = self::permalinkData( $thread, $method, $operand ); $query = array_merge( $query, $uquery ); @@ -95,7 +95,7 @@ * @return array */ static function permalinkData( $thread, $method = null, $operand = null ) { - $query = array(); + $query = []; if ( $method ) { $query['lqt_method'] = $method; @@ -113,7 +113,7 @@ throw new MWException( "No root in " . __METHOD__ ); } - return array( $root->getTitle(), $query ); + return [ $root->getTitle(), $query ]; } /* @@ -129,7 +129,7 @@ } static function permalink( $thread, $text = null, $method = null, $operand = null, - $linker = null, $attribs = array(), $uquery = array() ) { + $linker = null, $attribs = [], $uquery = [] ) { list( $title, $query ) = self::permalinkData( $thread, $method, $operand ); $query = array_merge( $query, $uquery ); @@ -149,7 +149,7 @@ * @return array */ static function linkInContextData( $thread, $contextType = 'page' ) { - $query = array(); + $query = []; if ( ! $thread ) { throw new Exception( "Null thread passed to linkInContextData" ); @@ -171,7 +171,7 @@ $title->setFragment( '#' . $thread->getAnchorName() ); - return array( $title, $query ); + return [ $title, $query ]; } /** @@ -190,7 +190,7 @@ return MediaWikiServices::getInstance()->getLinkRenderer()->makeLink( $title, $text, - array(), + [], $query ); } @@ -229,11 +229,11 @@ $oldid = $prev_rev ? $prev_rev->getId() : ''; } - $query = array( + $query = [ 'lqt_method' => 'diff', 'diff' => $curr_rev_id, 'oldid' => $oldid - ); + ]; return $query; } @@ -245,12 +245,12 @@ static function diffPermalink( $thread, $text, $revision ) { $query = self::diffQuery( $thread, $revision ); - return self::permalink( $thread, $text, null, null, null, array(), $query ); + return self::permalink( $thread, $text, null, null, null, [], $query ); } static function talkpageLink( $title, $text = null , $method = null, $operand = null, - $includeFragment = true, $attribs = array(), - $options = array(), $perpetuateOffset = true + $includeFragment = true, $attribs = [], + $options = [], $perpetuateOffset = true ) { list( $title, $query ) = self::talkpageLinkData( $title, $method, $operand, @@ -276,7 +276,7 @@ $includeFragment = true, $perpetuateOffset = true ) { global $wgRequest; - $query = array(); + $query = []; if ( $method ) { $query['lqt_method'] = $method; @@ -312,7 +312,7 @@ $title->mFragment = $operand->getAnchorName(); } - return array( $title, $query ); + return [ $title, $query ]; } /** @@ -411,11 +411,11 @@ $wgTitle = $this->title; $hookResult = Hooks::run( 'LiquidThreadsDoInlineEditForm', - array( + [ $thread, $this->request, &$this->output - ) ); + ] ); if ( !$hookResult ) { // Handled by a hook. @@ -464,7 +464,7 @@ static function getInlineEditForm( $talkpage, $method, $operand ) { $req = new RequestContext; $output = $req->getOutput(); - $request = new FauxRequest( array() ); + $request = new FauxRequest( [] ); // Workaround for loss of session data when using FauxRequest global $wgRequest; @@ -529,7 +529,7 @@ } $html = Xml::openElement( 'div', - array( 'class' => 'lqt-edit-form lqt-new-thread' ) ); + [ 'class' => 'lqt-edit-form lqt-new-thread' ] ); $this->output->addHTML( $html ); $article = new Article( $t, 0 ); @@ -541,7 +541,7 @@ LqtHooks::$editAppliesTo = null; $e = new EditPage( $article ); - Hooks::run( 'LiquidThreadsShowNewThreadForm', array( &$e, $talkpage ) ); + Hooks::run( 'LiquidThreadsShowNewThreadForm', [ &$e, $talkpage ] ); global $wgRequest; // Quietly force a preview if no subject has been specified. @@ -557,7 +557,7 @@ } $e->editFormPageTop .= - Xml::tags( 'div', array( 'class' => 'error' ), + Xml::tags( 'div', [ 'class' => 'error' ], wfMessage( $msg )->parseAsBlock() ); } } @@ -582,7 +582,7 @@ $e->editFormTextBeforeContent .= $this->getSubjectEditor( '', $subject ); - Hooks::run( 'LiquidThreadsAfterShowNewThreadForm', array( &$e, $talkpage ) ); + Hooks::run( 'LiquidThreadsAfterShowNewThreadForm', [ &$e, $talkpage ] ); $e->edit(); @@ -590,17 +590,17 @@ $signature = $this->request->getVal( 'wpLqtSignature', null ); $info = - array( + [ 'talkpage' => $talkpage, 'text' => $e->textbox1, 'summary' => $e->summary, 'signature' => $signature, 'root' => $article, 'subject' => $subject, - ); + ]; Hooks::run( 'LiquidThreadsSaveNewThread', - array( &$info, &$e, &$talkpage ) ); + [ &$info, &$e, &$talkpage ] ); $thread = LqtView::newPostMetadataUpdates( $info ); @@ -640,7 +640,7 @@ } $html = Xml::openElement( 'div', - array( 'class' => 'lqt-reply-form lqt-edit-form' ) ); + [ 'class' => 'lqt-reply-form lqt-edit-form' ] ); $this->output->addHTML( $html ); try { @@ -694,7 +694,7 @@ $wgRequest->setVal( 'wpWatchThis', false ); - Hooks::run( 'LiquidThreadsShowReplyForm', array( &$e, $thread ) ); + Hooks::run( 'LiquidThreadsShowReplyForm', [ &$e, $thread ] ); $e->edit(); @@ -703,17 +703,17 @@ $this->request->getBool( 'wpBumpThread' ); $signature = $this->request->getVal( 'wpLqtSignature', null ); - $info = array( + $info = [ 'replyTo' => $thread, 'text' => $e->textbox1, 'summary' => $e->summary, 'bump' => $bump, 'signature' => $signature, 'root' => $article, - ); + ]; Hooks::run( 'LiquidThreadsSaveReply', - array( &$info, &$e, &$thread ) ); + [ &$info, &$e, &$thread ] ); $newThread = LqtView::replyMetadataUpdates( $info ); @@ -746,7 +746,7 @@ } $html = Xml::openElement( 'div', - array( 'class' => 'lqt-edit-form' ) ); + [ 'class' => 'lqt-edit-form' ] ); $this->output->addHTML( $html ); $subject = $this->request->getVal( 'lqt_subject_field', '' ); @@ -765,7 +765,7 @@ $article = $thread->root(); $talkpage = $thread->article(); - Hooks::run( 'LiquidThreadsEditFormContent', array( $thread, &$article, $talkpage ) ); + Hooks::run( 'LiquidThreadsEditFormContent', [ $thread, &$article, $talkpage ] ); LqtHooks::$editTalkpage = $talkpage; LqtHooks::$editArticle = $article; @@ -783,7 +783,7 @@ if ( $this->request->wasPosted() ) { $e->editFormPageTop .= - Xml::tags( 'div', array( 'class' => 'error' ), + Xml::tags( 'div', [ 'class' => 'error' ], wfMessage( 'lqt_invalid_subject' )->parse() ); } } @@ -821,7 +821,7 @@ $signature = $this->request->getVal( 'wpLqtSignature', null ); LqtView::editMetadataUpdates( - array( + [ 'thread' => $thread, 'text' => $e->textbox1, 'summary' => $e->summary, @@ -829,7 +829,7 @@ 'subject' => $subject, 'signature' => $signature, 'root' => $article, - ) + ] ); if ( $submitted_nonce && $nonce_key ) { @@ -865,7 +865,7 @@ } $html = Xml::openElement( 'div', - array( 'class' => 'lqt-edit-form lqt-summarize-form' ) ); + [ 'class' => 'lqt-edit-form lqt-summarize-form' ] ); $this->output->addHTML( $html ); $this->output->addWikiMsg( 'lqt-summarize-intro' ); @@ -900,12 +900,12 @@ $this->request->getBool( 'wpBumpThread' ); LqtView::summarizeMetadataUpdates( - array( + [ 'thread' => $thread, 'article' => $article, 'summary' => $e->summary, 'bump' => $bump, - ) + ] ); if ( $submitted_nonce && $nonce_key ) { @@ -946,7 +946,7 @@ $subject_label = wfMessage( 'lqt_subject' )->text(); - $attr = array( 'tabindex' => 1 ); + $attr = [ 'tabindex' => 1 ]; return Xml::inputLabel( $subject_label, 'lqt_subject_field', 'lqt_subject_field', 60, $subject, $attr ) . @@ -969,24 +969,24 @@ // Signature edit box $signaturePreview = Xml::tags( 'span', - array( + [ 'class' => 'lqt-signature-preview', 'style' => 'display: none;' - ), + ], $signatureHTML ); $signatureEditBox = Xml::input( 'wpLqtSignature', 45, $signatureText, - array( 'class' => 'lqt-signature-edit' ) + [ 'class' => 'lqt-signature-edit' ] ); $signatureEditor = $signaturePreview . $signatureEditBox; - return array( $signatureEditor, $signatureHTML ); + return [ $signatureEditor, $signatureHTML ]; } - static function replyMetadataUpdates( $data = array() ) { - $requiredFields = array( 'replyTo', 'root', 'text' ); + static function replyMetadataUpdates( $data = [] ) { + $requiredFields = [ 'replyTo', 'root', 'text' ]; foreach ( $requiredFields as $f ) { if ( !isset( $data[$f] ) ) { @@ -1015,13 +1015,13 @@ $summary, $bump, $signature ); - Hooks::run( 'LiquidThreadsAfterReplyMetadataUpdates', array( &$thread ) ); + Hooks::run( 'LiquidThreadsAfterReplyMetadataUpdates', [ &$thread ] ); return $thread; } - static function summarizeMetadataUpdates( $data = array() ) { - $requiredFields = array( 'thread', 'article', 'summary' ); + static function summarizeMetadataUpdates( $data = [] ) { + $requiredFields = [ 'thread', 'article', 'summary' ]; foreach ( $requiredFields as $f ) { if ( !isset( $data[$f] ) ) { @@ -1042,8 +1042,8 @@ return $thread; } - static function editMetadataUpdates( $data = array() ) { - $requiredFields = array( 'thread', 'text', 'summary' ); + static function editMetadataUpdates( $data = [] ) { + $requiredFields = [ 'thread', 'text', 'summary' ]; foreach ( $requiredFields as $f ) { if ( !isset( $data[$f] ) ) { @@ -1082,7 +1082,7 @@ } static function newPostMetadataUpdates( $data ) { - $requiredFields = array( 'talkpage', 'root', 'text', 'subject' ); + $requiredFields = [ 'talkpage', 'root', 'text', 'subject' ]; foreach ( $requiredFields as $f ) { if ( !isset( $data[$f] ) ) { @@ -1109,7 +1109,7 @@ $summary, null, $signature ); - Hooks::run( 'LiquidThreadsAfterNewPostMetadataUpdates', array( &$thread ) ); + Hooks::run( 'LiquidThreadsAfterNewPostMetadataUpdates', [ &$thread ] ); return $thread; } @@ -1198,24 +1198,24 @@ * ) */ function threadCommands( $thread ) { - $commands = array(); + $commands = []; $isLqtPage = LqtDispatch::isLqtPage( $thread->getTitle() ); - $history_url = self::permalinkUrlWithQuery( $thread, array( 'action' => 'history' ) ); - $commands['history'] = array( + $history_url = self::permalinkUrlWithQuery( $thread, [ 'action' => 'history' ] ); + $commands['history'] = [ 'label' => wfMessage( 'history_short' )->parse(), 'href' => $history_url, 'enabled' => true - ); + ]; if ( $thread->isHistorical() ) { - return array(); + return []; } $user_can_edit = $thread->root()->getTitle()->quickUserCan( 'edit' ); $editMsg = $user_can_edit ? 'edit' : 'viewsource'; if ( $isLqtPage ) { - $commands['edit'] = array( + $commands['edit'] = [ 'label' => wfMessage( $editMsg )->parse(), 'href' => $this->talkpageUrl( $this->title, @@ -1224,29 +1224,29 @@ $this->request ), 'enabled' => true - ); + ]; } if ( $this->user->isAllowed( 'delete' ) ) { $delete_url = $thread->title()->getLocalURL( 'action=delete' ); $deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete'; - $commands['delete'] = array( + $commands['delete'] = [ 'label' => wfMessage( $deleteMsg )->parse(), 'href' => $delete_url, 'enabled' => true - ); + ]; } if ( $isLqtPage ) { if ( !$thread->isTopmostThread() && $this->user->isAllowed( 'lqt-split' ) ) { $splitUrl = SpecialPage::getTitleFor( 'SplitThread', $thread->title()->getPrefixedText() )->getLocalURL(); - $commands['split'] = array( + $commands['split'] = [ 'label' => wfMessage( 'lqt-thread-split' )->parse(), 'href' => $splitUrl, 'enabled' => true - ); + ]; } if ( $this->user->isAllowed( 'lqt-merge' ) ) { @@ -1258,23 +1258,23 @@ $mergeUrl = $this->title->getLocalURL( wfArrayToCgi( $mergeParams ) ); $label = wfMessage( 'lqt-thread-merge' )->parse(); - $commands['merge'] = array( + $commands['merge'] = [ 'label' => $label, 'href' => $mergeUrl, 'enabled' => true - ); + ]; } } - $commands['link'] = array( + $commands['link'] = [ 'label' => wfMessage( 'lqt_permalink' )->parse(), 'href' => $thread->title()->getLocalURL(), 'enabled' => true, 'showlabel' => true, 'tooltip' => wfMessage( 'lqt_permalink' )->parse() - ); + ]; - Hooks::run( 'LiquidThreadsThreadCommands', array( $thread, &$commands ) ); + Hooks::run( 'LiquidThreadsThreadCommands', [ $thread, &$commands ] ); return $commands; } @@ -1289,18 +1289,18 @@ if ( $thread->isHistorical() ) { // No links for historical threads. $history_url = self::permalinkUrlWithQuery( $thread, - array( 'action' => 'history' ) ); - $commands = array(); + [ 'action' => 'history' ] ); + $commands = []; - $commands['history'] = array( + $commands['history'] = [ 'label' => wfMessage( 'history_short' )->parse(), 'href' => $history_url, - 'enabled' => true ); + 'enabled' => true ]; return $commands; } - $commands = array(); + $commands = []; if ( $isLqtPage ) { if ( $this->user->isAllowed( 'lqt-merge' ) && @@ -1312,16 +1312,16 @@ $mergeUrl = $mergeTitle->getLocalURL( 'dest=' . $thread->id() ); $label = wfMessage( 'lqt-thread-merge-to' )->parse(); - $commands['merge-to'] = array( + $commands['merge-to'] = [ 'label' => $label, 'href' => $mergeUrl, 'enabled' => true, 'tooltip' => $label - ); + ]; } if ( $thread->canUserReply( $this->user, 'quick' ) === true ) { - $commands['reply'] = array( + $commands['reply'] = [ 'label' => wfMessage( 'lqt_reply' )->parse(), 'href' => $this->talkpageUrl( $this->title, 'reply', $thread, true /* include fragment */, $this->request ), @@ -1329,7 +1329,7 @@ 'showlabel' => 1, 'tooltip' => wfMessage( 'lqt_reply' )->parse(), 'icon' => 'reply.png', - ); + ]; } } @@ -1338,16 +1338,16 @@ $parent = $thread->superthread(); $anchor = $parent->getAnchorName(); - $commands['parent'] = array( + $commands['parent'] = [ 'label' => wfMessage( 'lqt-parent' )->parse(), 'href' => '#' . $anchor, 'enabled' => true, 'showlabel' => 1, - ); + ]; } Hooks::run( 'LiquidThreadsThreadMajorCommands', - array( $thread, &$commands ) ); + [ $thread, &$commands ] ); return $commands; } @@ -1356,22 +1356,22 @@ * @param $thread Thread */ function topLevelThreadCommands( $thread ) { - $commands = array(); + $commands = []; - $commands['history'] = array( + $commands['history'] = [ 'label' => wfMessage( 'history_short' )->parse(), 'href' => self::permalinkUrl( $thread, 'thread_history' ), 'enabled' => true - ); + ]; if ( $this->user->isAllowed( 'move' ) ) { $move_href = SpecialPage::getTitleFor( 'MoveThread', $thread->title()->getPrefixedText() )->getLocalURL(); - $commands['move'] = array( + $commands['move'] = [ 'label' => wfMessage( 'lqt-movethread' )->parse(), 'href' => $move_href, 'enabled' => true - ); + ]; } if ( $this->user->isAllowed( 'protect' ) ) { @@ -1384,51 +1384,51 @@ $label = wfMessage( 'unprotect' )->parse(); } - $commands['protect'] = array( + $commands['protect'] = [ 'label' => $label, 'href' => $protect_href, 'enabled' => true - ); + ]; } if ( !$this->user->isAnon() && !$this->user->isWatched( $thread->title() ) ) { - $commands['watch'] = array( + $commands['watch'] = [ 'label' => wfMessage( 'watch' )->parse(), 'href' => self::permalinkUrlWithQuery( $thread, - array( + [ 'action' => 'watch', 'token' => WatchAction::getWatchToken( $thread->title(), $this->user, 'watch' ) - ) + ] ), 'enabled' => true - ); + ]; } elseif ( !$this->user->isAnon() ) { - $commands['unwatch'] = array( + $commands['unwatch'] = [ 'label' => wfMessage( 'unwatch' )->parse(), 'href' => self::permalinkUrlWithQuery( $thread, - array( + [ 'action' => 'unwatch', 'token' => WatchAction::getWatchToken( $thread->title(), $this->user, 'unwatch' ) - ) + ] ), 'enabled' => true - ); + ]; } if ( LqtDispatch::isLqtPage( $thread->getTitle() ) ) { $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() ); - $commands['summarize'] = array( + $commands['summarize'] = [ 'label' => wfMessage( 'lqt_summarize_link' )->parse(), 'href' => $summarizeUrl, 'enabled' => true, - ); + ]; } - Hooks::run( 'LiquidThreadsTopLevelCommands', array( $thread, &$commands ) ); + Hooks::run( 'LiquidThreadsTopLevelCommands', [ $thread, &$commands ] ); return $commands; } @@ -1465,54 +1465,54 @@ function showThreadToolbar( $thread ) { $html = ''; - $headerParts = array(); + $headerParts = []; foreach ( $this->threadMajorCommands( $thread ) as $key => $cmd ) { $content = $this->contentForCommand( $cmd, false /* No icon divs */ ); $headerParts[] = Xml::tags( 'li', - array( 'class' => "lqt-command lqt-command-$key" ), + [ 'class' => "lqt-command lqt-command-$key" ], $content ); } // Drop-down menu $commands = $this->threadCommands( $thread ); - $menuHTML = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-command-list' ), + $menuHTML = Xml::tags( 'ul', [ 'class' => 'lqt-thread-toolbar-command-list' ], $this->listItemsForCommands( $commands ) ); - $triggerText = Xml::tags( 'a', array( + $triggerText = Xml::tags( 'a', [ 'class' => 'lqt-thread-actions-icon', 'href' => '#' - ), + ], wfMessage( 'lqt-menu-trigger' )->escaped() ); $dropDownTrigger = Xml::tags( 'div', - array( 'class' => 'lqt-thread-actions-trigger ' . - 'lqt-command-icon', 'style' => 'display: none;' ), + [ 'class' => 'lqt-thread-actions-trigger ' . + 'lqt-command-icon', 'style' => 'display: none;' ], $triggerText ); if ( count( $commands ) ) { $headerParts[] = Xml::tags( 'li', - array( 'class' => 'lqt-thread-toolbar-menu' ), + [ 'class' => 'lqt-thread-toolbar-menu' ], $dropDownTrigger ); } $html .= implode( ' ', $headerParts ); - $html = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-commands' ), $html ); + $html = Xml::tags( 'ul', [ 'class' => 'lqt-thread-toolbar-commands' ], $html ); - $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-toolbar' ), $html ) . + $html = Xml::tags( 'div', [ 'class' => 'lqt-thread-toolbar' ], $html ) . $menuHTML; return $html; } function listItemsForCommands( $commands ) { - $result = array(); + $result = []; foreach ( $commands as $key => $command ) { $thisCommand = $this->contentForCommand( $command ); $thisCommand = Xml::tags( 'li', - array( 'class' => 'lqt-command lqt-command-' . $key ), + [ 'class' => 'lqt-command lqt-command-' . $key ], $thisCommand ); @@ -1528,8 +1528,8 @@ $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : ''; if ( isset( $command['icon'] ) ) { - $icon = Xml::tags( 'div', array( 'title' => $label, - 'class' => 'lqt-command-icon' ), ' ' ); + $icon = Xml::tags( 'div', [ 'title' => $label, + 'class' => 'lqt-command-icon' ], ' ' ); if ( $icon_divs ) { if ( !empty( $command['showlabel'] ) ) { $label = $icon . ' ' . $label; @@ -1544,11 +1544,11 @@ } if ( $enabled ) { - $thisCommand = Xml::tags( 'a', array( 'href' => $href, 'title' => $tooltip ), + $thisCommand = Xml::tags( 'a', [ 'href' => $href, 'title' => $tooltip ], $label ); } else { - $thisCommand = Xml::tags( 'span', array( 'class' => 'lqt_command_disabled', - 'title' => $tooltip ), $label ); + $thisCommand = Xml::tags( 'span', [ 'class' => 'lqt_command_disabled', + 'title' => $tooltip ], $label ); } return $thisCommand; @@ -1584,9 +1584,9 @@ // If we're editing the thread, show the editing form. $showAnything = Hooks::run( 'LiquidThreadsShowThreadBody', - array( $thread ) ); + [ $thread ] ); if ( $this->methodAppliesToThread( 'edit', $thread ) && $showAnything ) { - $html = Xml::openElement( 'div', array( 'class' => $divClass ) ); + $html = Xml::openElement( 'div', [ 'class' => $divClass ] ); $this->output->addHTML( $html ); $html = ''; @@ -1595,16 +1595,16 @@ $this->showPostEditingForm( $thread ); $html .= Xml::closeElement( 'div' ); } elseif ( $showAnything ) { - $html .= Xml::openElement( 'div', array( 'class' => $divClass ) ); + $html .= Xml::openElement( 'div', [ 'class' => $divClass ] ); $show = Hooks::run( 'LiquidThreadsShowPostContent', - array( $thread, &$post ) ); + [ $thread, &$post ] ); if ( $show ) { $html .= $this->showPostBody( $post, $oldid ); } $html .= Xml::closeElement( 'div' ); Hooks::run( 'LiquidThreadsShowPostThreadBody', - array( $thread, $this->request, &$html ) ); + [ $thread, $this->request, &$html ] ); $html .= $this->showThreadToolbar( $thread ); $html .= $this->threadSignature( $thread ); @@ -1625,19 +1625,19 @@ $signature = $thread->signature(); $signature = LqtView::parseSignature( $signature ); - $signature = Xml::tags( 'span', array( 'class' => 'lqt-thread-user-signature' ), + $signature = Xml::tags( 'span', [ 'class' => 'lqt-thread-user-signature' ], $signature ); $signature .= $wgLang->getDirMark(); $timestamp = $wgLang->timeanddate( $thread->created(), true ); $signature .= Xml::element( 'span', - array( 'class' => 'lqt-thread-toolbar-timestamp' ), + [ 'class' => 'lqt-thread-toolbar-timestamp' ], $timestamp ); - Hooks::run( 'LiquidThreadsThreadSignature', array( $thread, &$signature ) ); + Hooks::run( 'LiquidThreadsThreadSignature', [ $thread, &$signature ] ); - $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ), + $signature = Xml::tags( 'div', [ 'class' => 'lqt-thread-signature' ], $signature ); return $signature; @@ -1649,12 +1649,12 @@ function threadInfoPanel( $thread ) { global $wgLang; - $infoElements = array(); + $infoElements = []; // Check for edited flag. $editedFlag = $thread->editedness(); - $ebLookup = array( Threads::EDITED_BY_AUTHOR => 'author', - Threads::EDITED_BY_OTHERS => 'others' ); + $ebLookup = [ Threads::EDITED_BY_AUTHOR => 'author', + Threads::EDITED_BY_OTHERS => 'others' ]; $lastEdit = $thread->root()->getTimestamp(); $lastEditTime = $wgLang->time( $lastEdit, false, true, true ); $lastEditDate = $wgLang->date( $lastEdit, false, true, true ); @@ -1665,7 +1665,7 @@ if ( $editedFlag > Threads::EDITED_BY_AUTHOR ) { $editors = $thread->editors(); $editorCount = count( $editors ); - $formattedEditors = array(); + $formattedEditors = []; foreach ( $editors as $ed ) { $id = IP::isIPAddress( $ed ) ? 0 : 1; @@ -1686,18 +1686,18 @@ ->params( $lastEditTime, $lastEditDate ) ->params( $user->getName() )->parse(); $editedNotice = str_replace( '$3', $editors, $editedNotice ); - $infoElements[] = Xml::tags( 'div', array( 'class' => - "lqt-thread-toolbar-edited-$editedBy" ), + $infoElements[] = Xml::tags( 'div', [ 'class' => + "lqt-thread-toolbar-edited-$editedBy" ], $editedNotice ); } - Hooks::run( 'LiquidThreadsThreadInfoPanel', array( $thread, &$infoElements ) ); + Hooks::run( 'LiquidThreadsThreadInfoPanel', [ $thread, &$infoElements ] ); if ( ! count( $infoElements ) ) { return ''; } - return Xml::tags( 'div', array( 'class' => 'lqt-thread-info-panel' ), + return Xml::tags( 'div', [ 'class' => 'lqt-thread-info-panel' ], implode( "\n", $infoElements ) ); } @@ -1716,8 +1716,8 @@ $lis = $this->listItemsForCommands( $commands ); $id = 'lqt-threadlevel-commands-' . $thread->id(); $commands_html = Xml::tags( 'ul', - array( 'class' => 'lqt_threadlevel_commands', - 'id' => $id ), + [ 'class' => 'lqt_threadlevel_commands', + 'id' => $id ], $lis ); } @@ -1726,19 +1726,19 @@ $html = $thread->formattedSubject(); $show = Hooks::run( 'LiquidThreadsShowThreadHeading', - array( $thread, &$html ) ); + [ $thread, &$html ] ); if ( $show ) { - $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html ); + $html = Xml::tags( 'span', [ 'class' => 'mw-headline' ], $html ); $html .= Html::hidden( 'raw-header', $thread->subject() ); $html = Xml::tags( 'h' . $this->headerLevel, - array( 'class' => 'lqt_header', 'id' => $id, 'dir' => $wgContLang->getDir() ), + [ 'class' => 'lqt_header', 'id' => $id, 'dir' => $wgContLang->getDir() ], $html ) . $commands_html; } // wrap it all in a container $html = Xml::tags( 'div', - array( 'class' => 'lqt_thread_heading' ), + [ 'class' => 'lqt_thread_heading' ], $html ); return $html; } @@ -1856,7 +1856,7 @@ $this->showThreadBody( $thread ); } - function getMustShowThreads( $threads = array() ) { + function getMustShowThreads( $threads = [] ) { if ( $this->request->getCheck( 'lqt_operand' ) ) { $operands = explode( ',', $this->request->getVal( 'lqt_operand' ) ); $threads = array_merge( $threads, $operands ); @@ -1902,12 +1902,12 @@ $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink( $linkTitle, $linkText, - array( + [ 'class' => 'lqt-show-more-posts', - ) + ] ); $link .= Html::hidden( 'lqt-thread-start-at', $i, - array( 'class' => 'lqt-thread-start-at' ) ); + [ 'class' => 'lqt-thread-start-at' ] ); return $link; } @@ -1929,11 +1929,11 @@ $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink( $linkTitle, $linkText, - array( + [ 'class' => 'lqt-show-replies', - ) + ] ); - $link = Xml::tags( 'div', array( 'class' => 'lqt-thread-replies' ), $link ); + $link = Xml::tags( 'div', [ 'class' => 'lqt-thread-replies' ], $link ); return $link; } @@ -1985,7 +1985,7 @@ $repliesClass .= ' lqt-thread-replies-interruption'; } - $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) ); + $div = Xml::openElement( 'div', [ 'class' => $repliesClass ] ); $subthreadCount = count( $thread->subthreads() ); $i = 0; @@ -1995,7 +1995,7 @@ $mustShowThreads = $cascadeOptions['mustShowThreads']; $replies = $thread->subthreads(); - usort( $replies, array( 'Thread', 'createdSortCallback' ) ); + usort( $replies, [ 'Thread', 'createdSortCallback' ] ); foreach ( $replies as $st ) { ++$i; @@ -2041,7 +2041,7 @@ $finishDiv = ''; $finishDiv .= Xml::tags( 'div', - array( 'class' => 'lqt-replies-finish' ), + [ 'class' => 'lqt-replies-finish' ], ' ' ); @@ -2056,7 +2056,7 @@ * @throws Exception */ function showThread( $thread, $levelNum = 1, $totalInLevel = 1, - $options = array() + $options = [] ) { // Safeguard if ( $thread->type() & Threads::TYPE_DELETED || @@ -2068,7 +2068,7 @@ // Figure out which threads *need* to be shown because they're involved in an // operation - $mustShowOption = array(); + $mustShowOption = []; if ( isset( $options['mustShowThreads'] ) ) { $mustShowOption = $options['mustShowThreads' ]; } @@ -2131,7 +2131,7 @@ $this->output->addModules( 'ext.liquidThreads' ); $html = ''; - Hooks::run( 'EditPageBeforeEditToolbar', array( &$html ) ); + Hooks::run( 'EditPageBeforeEditToolbar', [ &$html ] ); $class = $this->threadDivClass( $thread ); if ( $levelNum == 1 ) { @@ -2156,13 +2156,13 @@ $html .= Xml::openElement( 'div', - array( + [ 'class' => $class, 'id' => 'lqt_thread_id_' . $thread->id() - ) + ] ); - $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' ); + $html .= Xml::element( 'a', [ 'name' => $this->anchorName( $thread ) ], ' ' ); $html .= $this->showThreadHeading( $thread ); // Metadata stuck in the top of the lqt_thread div. @@ -2171,23 +2171,23 @@ $html .= Html::hidden( 'lqt-thread-modified-' . $thread->id(), wfTimestamp( TS_MW, $thread->modified() ), - array( + [ 'id' => 'lqt-thread-modified-' . $thread->id(), 'class' => 'lqt-thread-modified' - ) + ] ); $html .= Html::hidden( 'lqt-thread-sortkey', $thread->sortkey(), - array( 'id' => 'lqt-thread-sortkey-' . $thread->id() ) + [ 'id' => 'lqt-thread-sortkey-' . $thread->id() ] ); $html .= Html::hidden( 'lqt-thread-talkpage-' . $thread->id(), $thread->article()->getTitle()->getPrefixedText(), - array( + [ 'class' => 'lqt-thread-talkpage-metadata', - ) + ] ); } @@ -2199,16 +2199,16 @@ $html .= Html::hidden( 'lqt-thread-title-' . $thread->id(), $thread->title()->getPrefixedText(), - array( + [ 'id' => 'lqt-thread-title-' . $thread->id(), 'class' => 'lqt-thread-title-metadata' - ) + ] ); // Flush output to display thread $this->output->addHTML( $html ); $this->output->addHTML( Xml::openElement( 'div', - array( 'class' => 'lqt-post-wrapper' ) ) ); + [ 'class' => 'lqt-post-wrapper' ] ) ); $this->showSingleThread( $thread ); $this->output->addHTML( Xml::closeElement( 'div' ) ); @@ -2235,24 +2235,24 @@ if ( $levelNum < $totalInLevel ) { $this->output->addHTML( - Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); + Xml::tags( 'div', [ 'class' => 'lqt-post-sep' ], ' ' ) ); } } elseif ( $levelNum < $totalInLevel ) { // If we have no replies, and we're not at the end of this level, add the post separator // and a reply box if necessary. $this->output->addHTML( - Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); + Xml::tags( 'div', [ 'class' => 'lqt-post-sep' ], ' ' ) ); if ( $replyTo ) { $class = 'lqt-thread-replies lqt-thread-replies-' . $this->threadNestingLevel; - $html = Xml::openElement( 'div', array( 'class' => $class ) ); + $html = Xml::openElement( 'div', [ 'class' => $class ] ); $this->output->addHTML( $html ); $this->showReplyForm( $thread ); $finishDiv = Xml::tags( 'div', - array( 'class' => 'lqt-replies-finish' ), + [ 'class' => 'lqt-replies-finish' ], ' ' ); // Layout plus close div.lqt-thread-replies @@ -2266,17 +2266,17 @@ // show the reply box. $class = 'lqt-thread-replies lqt-thread-replies-' . $this->threadNestingLevel; - $html = Xml::openElement( 'div', array( 'class' => $class ) ); + $html = Xml::openElement( 'div', [ 'class' => $class ] ); $this->output->addHTML( $html ); $this->showReplyForm( $thread ); $html = Xml::tags( 'div', - array( 'class' => 'lqt-replies-finish' ), + [ 'class' => 'lqt-replies-finish' ], Xml::tags( 'div', - array( 'class' => + [ 'class' => 'lqt-replies-finish-corner' - ), ' ' ) ); + ], ' ' ) ); $html .= Xml::closeElement( 'div' ); $this->output->addHTML( $html ); } @@ -2311,8 +2311,8 @@ $html = ''; $html .= Xml::tags( 'div', - array( 'class' => 'lqt-reply-form lqt-edit-form', - 'style' => 'display: none;' ), + [ 'class' => 'lqt-reply-form lqt-edit-form', + 'style' => 'display: none;' ], '' ); @@ -2352,7 +2352,7 @@ $html .= Xml::tags( 'span', - array( 'class' => 'lqt_thread_permalink_summary_title' ), + [ 'class' => 'lqt_thread_permalink_summary_title' ], $label ); @@ -2360,29 +2360,29 @@ $link = $linkRenderer->makeLink( $t->summary()->getTitle(), $link_text, - array( + [ 'class' => 'lqt-summary-link', - ) + ] ); $link .= Html::hidden( 'summary-title', $t->summary()->getTitle()->getPrefixedText() ); $edit_link = self::permalink( $t, $edit_text, 'summarize', $t->id() ); $links = "[$link]\n[$edit_link]"; $html .= Xml::tags( 'span', - array( 'class' => 'lqt_thread_permalink_summary_actions' ), + [ 'class' => 'lqt_thread_permalink_summary_actions' ], $links ); $summary_body = $this->showPostBody( $t->summary() ); $html .= Xml::tags( 'div', - array( 'class' => 'lqt_thread_permalink_summary_body' ), + [ 'class' => 'lqt_thread_permalink_summary_body' ], $summary_body ); $html = Xml::tags( 'div', - array( 'class' => 'lqt_thread_permalink_summary' ), + [ 'class' => 'lqt_thread_permalink_summary' ], $html ); @@ -2430,7 +2430,7 @@ static function parseSignature( $sig ) { global $wgOut; - static $parseCache = array(); + static $parseCache = []; $sigKey = md5( $sig ); if ( isset( $parseCache[$sigKey] ) ) { -- To view, visit https://gerrit.wikimedia.org/r/357865 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia30ef80cc11190297d8652712456d1cf992d8124 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/LiquidThreads Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits