Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357692 )

Change subject: Always use braces after if
......................................................................

Always use braces after if

Makes if blocks more readable

Change-Id: I1d5943c0de5a11cdedc21fc28ae64a15b6887b9e
---
M api/ApiQueryLQTThreads.php
M api/ApiThreadAction.php
M classes/Dispatch.php
M classes/HistoricalThread.php
M classes/Hooks.php
M classes/NewMessagesController.php
M classes/Thread.php
M classes/ThreadRevision.php
M classes/View.php
M pages/NewUserMessagesView.php
M pages/SpecialMoveThread.php
M pages/TalkpageView.php
M pages/ThreadPermalinkView.php
13 files changed, 107 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LiquidThreads 
refs/changes/92/357692/1

diff --git a/api/ApiQueryLQTThreads.php b/api/ApiQueryLQTThreads.php
index be0614d..14bf7d0 100644
--- a/api/ApiQueryLQTThreads.php
+++ b/api/ApiQueryLQTThreads.php
@@ -232,12 +232,15 @@
                $rendercount = $params['renderthreadcount'];
 
                $options = array();
-               if ( isset( $params['rendermaxthreadcount'] ) )
+               if ( isset( $params['rendermaxthreadcount'] ) ) {
                        $options['maxCount'] = $params['rendermaxthreadcount'];
-               if ( isset( $params['rendermaxdepth'] ) )
+               }
+               if ( isset( $params['rendermaxdepth'] ) ) {
                        $options['maxDepth'] = $params['rendermaxdepth'];
-               if ( isset( $params['renderstartrepliesat'] ) )
+               }
+               if ( isset( $params['renderstartrepliesat'] ) ) {
                        $options['startAt' ] = $params['renderstartrepliesat'];
+               }
 
                $view->showThread( $thread, $renderpos, $rendercount, $options 
);
 
diff --git a/api/ApiThreadAction.php b/api/ApiThreadAction.php
index 3f66907..109da28 100644
--- a/api/ApiThreadAction.php
+++ b/api/ApiThreadAction.php
@@ -827,7 +827,9 @@
 
                $ts = $params['sortkey'];
 
-               if ( $ts == 'now' ) $ts = wfTimestampNow();
+               if ( $ts == 'now' ) {
+                       $ts = wfTimestampNow();
+               }
 
                $ts = wfTimestamp( TS_MW, $ts );
 
diff --git a/classes/Dispatch.php b/classes/Dispatch.php
index 3555240..faeef52 100644
--- a/classes/Dispatch.php
+++ b/classes/Dispatch.php
@@ -229,7 +229,9 @@
        }
 
        public static function onSkinTemplateNavigation( $skinTemplate, &$links 
) {
-               if ( !self::$primaryView ) return true;
+               if ( !self::$primaryView ) {
+                       return true;
+               }
 
                self::$primaryView->customizeNavigation( $skinTemplate, $links 
);
 
diff --git a/classes/HistoricalThread.php b/classes/HistoricalThread.php
index 2922a99..6d25622 100644
--- a/classes/HistoricalThread.php
+++ b/classes/HistoricalThread.php
@@ -49,10 +49,11 @@
                                'hthread_revision' => $rev
                        ),
                        __METHOD__ );
-               if ( $line )
+               if ( $line ) {
                        return HistoricalThread::fromTextRepresentation( 
$line->hthread_contents );
-               else
+               } else {
                        return null;
+               }
        }
 
        function isHistorical() {
diff --git a/classes/Hooks.php b/classes/Hooks.php
index c8b09cf..0b43ca9 100644
--- a/classes/Hooks.php
+++ b/classes/Hooks.php
@@ -132,8 +132,9 @@
                $watch_messages = NewMessages::watchedThreadsForUser( $wgUser );
                $wn = count( $watch_messages );
 
-               if ( $tn == 0 && $wn == 0 )
+               if ( $tn == 0 && $wn == 0 ) {
                        return true;
+               }
 
                $wgOut->addModules( 'ext.liquidThreads' );
                $messages_title = SpecialPage::getTitleFor( 'NewMessages' );
@@ -899,8 +900,9 @@
         * @return bool
         */
        public static function onGetUserPermissionsErrors( $title, $user, 
$action, &$result ) {
-               if ( $title->getNamespace() != NS_LQT_THREAD || $action != 
'read' )
+               if ( $title->getNamespace() != NS_LQT_THREAD || $action != 
'read' ) {
                        return true;
+               }
 
                $thread = Threads::withRoot( new Article( $title, 0 ) );
 
@@ -965,7 +967,9 @@
                                'Strip' => 'base'
                        ) );
                        foreach ( $data as $pageid => $page ) {
-                               if ( $page == 'page' ) continue;
+                               if ( $page == 'page' ) {
+                                       continue;
+                               }
 
                                if ( isset( $page['title'] )
                                        && LqtDispatch::isLqtPage( 
Title::newFromText( $page['title'] ) )
diff --git a/classes/NewMessagesController.php 
b/classes/NewMessagesController.php
index 93635d2..23d953f 100644
--- a/classes/NewMessagesController.php
+++ b/classes/NewMessagesController.php
@@ -180,8 +180,9 @@
                $res = self::getRowsObject( $t );
                foreach ( $res as $row ) {
                        // Don't notify yourself
-                       if ( $changeUser->getId() == $row->wl_user )
+                       if ( $changeUser->getId() == $row->wl_user ) {
                                continue;
+                       }
 
                        if ( !$row->ums_user || $row->ums_read_timestamp ) {
                                $userIds[] = $row->wl_user;
diff --git a/classes/Thread.php b/classes/Thread.php
index b1dfc8d..d483b31 100644
--- a/classes/Thread.php
+++ b/classes/Thread.php
@@ -183,7 +183,9 @@
 
                $topmost = $this->topmostThread();
                $topmost->modified = wfTimestampNow();
-               if ( $bump ) $topmost->setSortkey( wfTimestamp( TS_MW ) );
+               if ( $bump ) {
+                       $topmost->setSortkey( wfTimestamp( TS_MW ) );
+               }
                $topmost->save();
 
                ThreadRevision::create( $this, $change_type, $change_object, 
$reason );
@@ -383,8 +385,9 @@
        public function moveToPage( $title, $reason, $leave_trace ) {
                global $wgUser;
 
-               if ( !$this->isTopmostThread() )
+               if ( !$this->isTopmostThread() ) {
                        throw new Exception( "Attempt to move non-toplevel 
thread to another page" );
+               }
 
                $this->dieIfHistorical();
 
@@ -566,8 +569,9 @@
 
                Threads::$cache_by_id[$line->thread_id] = $this;
                if ( $line->thread_parent ) {
-                       if ( !isset( 
self::$replyCacheById[$line->thread_parent] ) )
+                       if ( !isset( 
self::$replyCacheById[$line->thread_parent] ) ) {
                                self::$replyCacheById[$line->thread_parent] = 
array();
+                       }
                        
self::$replyCacheById[$line->thread_parent][$line->thread_id] = $this;
                }
 
@@ -607,11 +611,12 @@
                        }
 
                        // Grab page data while we're here.
-                       if ( $row->thread_root )
+                       if ( $row->thread_root ) {
                                $pageIds[] = $row->thread_root;
-                       if ( $row->thread_summary_page )
+                       }
+                       if ( $row->thread_summary_page ) {
                                $pageIds[] = $row->thread_summary_page;
-
+                       }
                        if ( !isset( self::$replyCacheById[$row->thread_id] ) ) 
{
                                self::$replyCacheById[$row->thread_id] = 
array();
                        }
@@ -711,8 +716,9 @@
                foreach ( $all_thread_rows as $row ) {
                        $thread = Thread::newFromRow( $row, null );
 
-                       if ( isset( $articlesById[$thread->rootId] ) )
+                       if ( isset( $articlesById[$thread->rootId] ) ) {
                                $thread->root = $articlesById[$thread->rootId];
+                       }
 
                        // User cache data
                        $t = Title::makeTitleSafe( NS_USER, 
$row->thread_author_name );
@@ -778,10 +784,11 @@
                                'LIMIT'   => '1'
                        )
                );
-               if ( $line )
+               if ( $line ) {
                        return User::newFromName( $line->rev_user_text, false );
-               else
+               } else {
                        return null;
+               }
        }
 
        public static function recursiveGetReplyCount( $thread, $level = 1 ) {
@@ -1144,7 +1151,9 @@
        }
 
        public function article() {
-               if ( $this->article ) return $this->article;
+               if ( $this->article ) {
+                       return $this->article;
+               }
 
                if ( !is_null( $this->articleId ) ) {
                        if ( isset( self::$articleCacheById[$this->articleId] ) 
) {
@@ -1182,7 +1191,9 @@
 
        // The 'root' is the page in the Thread namespace corresponding to this 
thread.
        public function root( ) {
-               if ( !$this->rootId ) return null;
+               if ( !$this->rootId ) {
+                       return null;
+               }
                if ( !$this->root ) {
                        if ( isset( self::$articleCacheById[$this->rootId] ) ) {
                                $this->root = 
self::$articleCacheById[$this->rootId];
@@ -1217,8 +1228,9 @@
        }
 
        public function summary() {
-               if ( !$this->summaryId )
+               if ( !$this->summaryId ) {
                        return null;
+               }
 
                if ( !$this->summary ) {
                        $title = Title::newFromID( $this->summaryId );
@@ -1258,12 +1270,13 @@
 
        public static function splitIncrementFromSubject( $subject_string ) {
                preg_match( '/^(.*) \((\d+)\)$/', $subject_string, $matches );
-               if ( count( $matches ) != 3 )
+               if ( count( $matches ) != 3 ) {
                        throw new Exception(
                                __METHOD__ . ": thread subject has no 
increment: " . $subject_string
                        );
-               else
+               } else {
                        return $matches;
+               }
        }
 
        public function subject() {
@@ -1324,7 +1337,9 @@
                        null,
                        CONTENT_MODEL_WIKITEXT
                )->getRedirectTarget();
-               if ( !$rtitle ) return null;
+               if ( !$rtitle ) {
+                       return null;
+               }
 
                $this->dieIfHistorical();
                $rthread = Threads::withRoot( new Article( $rtitle, 0 ) );
@@ -1544,8 +1559,9 @@
                                        $t = Threads::newReplyTitle( $replyTo, 
$wgUser );
                                }
 
-                               if ( $t )
+                               if ( $t ) {
                                        break;
+                               }
                        } catch ( Exception $e ) { }
 
                        $subject = md5( mt_rand() ); // Just a random title
@@ -1569,7 +1585,9 @@
                $restrictions = array_merge( $threadRestrictions, 
$talkpageRestrictions );
 
                foreach ( $restrictions as $right => $source ) {
-                       if ( $right == 'sysop' ) $right = 'protect';
+                       if ( $right == 'sysop' ) {
+                               $right = 'protect';
+                       }
                        if ( !$user->isAllowed( $right ) ) {
                                return $source;
                        }
diff --git a/classes/ThreadRevision.php b/classes/ThreadRevision.php
index 1262434..266e510 100644
--- a/classes/ThreadRevision.php
+++ b/classes/ThreadRevision.php
@@ -24,13 +24,17 @@
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' 
=> $id ), __METHOD__ );
 
-               if ( !$row ) return null;
+               if ( !$row ) {
+                       return null;
+               }
 
                return self::loadFromRow( $row );
        }
 
        public static function loadFromRow( $row ) {
-               if ( !$row ) return null;
+               if ( !$row ) {
+                       return null;
+               }
 
                $rev = new ThreadRevision;
 
diff --git a/classes/View.php b/classes/View.php
index a0027d7..99dbdc0 100644
--- a/classes/View.php
+++ b/classes/View.php
@@ -507,7 +507,9 @@
        function showNewThreadForm( $talkpage ) {
                $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
                $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, 
$this->user->getName() );
-               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) 
return;
+               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) {
+                       return;
+               }
 
                if ( Thread::canUserPost( $this->user, $this->article ) !== 
true ) {
                        $this->output->addWikiMsg( 'lqt-protected-newthread' );
@@ -628,7 +630,9 @@
 
                $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
                $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, 
$this->user->getName() );
-               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) 
return;
+               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) {
+                       return;
+               }
 
                $perm_result = $thread->canUserReply( $this->user, 'quick' );
                if ( $perm_result !== true ) {
@@ -739,7 +743,9 @@
        function showPostEditingForm( $thread ) {
                $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
                $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, 
$this->user->getName() );
-               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) 
return;
+               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) {
+                       return;
+               }
 
                $html = Xml::openElement( 'div',
                        array( 'class' => 'lqt-edit-form' ) );
@@ -849,7 +855,9 @@
        function showSummarizeForm( $thread ) {
                $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
                $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, 
$this->user->getName() );
-               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) 
return;
+               if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) {
+                       return;
+               }
 
                if ( $thread->summary() ) {
                        $article = $thread->summary();
@@ -934,7 +942,9 @@
        }
 
        public function getSubjectEditor( $db_subject, $subject ) {
-               if ( $subject === false ) $subject = $db_subject;
+               if ( $subject === false ) {
+                       $subject = $db_subject;
+               }
 
                $subject_label = wfMessage( 'lqt_subject' )->text();
 
@@ -1831,7 +1841,9 @@
                } elseif ( $thread->type() == Threads::TYPE_DELETED ) {
                        $res = $this->showDeletedThread( $thread );
 
-                       if ( !$res ) return;
+                       if ( !$res ) {
+                               return;
+                       }
                }
 
                $this->output->addHTML( $this->threadInfoPanel( $thread ) );
diff --git a/pages/NewUserMessagesView.php b/pages/NewUserMessagesView.php
index 50a9c61..1a864f8 100644
--- a/pages/NewUserMessagesView.php
+++ b/pages/NewUserMessagesView.php
@@ -37,8 +37,9 @@
 
                if ( count( $ids ) == 1 ) {
                        $t = Threads::withId( $ids[0] );
-                       if ( !$t )
+                       if ( !$t ) {
                                return; // empty or just bogus operand.
+                       }
                        $msg = wfMessage( 'lqt-marked-read', 
LqtView::formatSubject( $t->subject() )  )->parse();
                } else {
                        $msg = wfMessage( 'lqt-count-marked-read' )->numParams( 
count( $ids ) )->parse();
@@ -69,8 +70,9 @@
        function postDivClass( $thread ) {
                $origClass = parent::postDivClass( $thread );
 
-               if ( in_array( $thread->id(), $this->highlightThreads ) )
+               if ( in_array( $thread->id(), $this->highlightThreads ) ) {
                        return "$origClass lqt_post_new_message";
+               }
 
                return $origClass;
        }
@@ -89,8 +91,9 @@
                        if ( $ids !== false ) {
                                foreach ( $ids as $id ) {
                                        $tmp_thread = Threads::withId( $id );
-                                       if ( $tmp_thread )
+                                       if ( $tmp_thread ) {
                                                
NewMessages::markThreadAsUnReadByUser( $tmp_thread, $this->user );
+                                       }
                                }
                                $this->output->redirect( 
$this->title->getLocalURL() );
                        }
@@ -102,8 +105,9 @@
                                                NewMessages::markAllReadByUser( 
$this->user );
                                        } else {
                                                $tmp_thread = Threads::withId( 
$id );
-                                               if ( $tmp_thread )
+                                               if ( $tmp_thread ) {
                                                        
NewMessages::markThreadAsReadByUser( $tmp_thread, $this->user );
+                                               }
                                        }
                                }
                                $query = 
'lqt_method=undo_mark_as_read&lqt_operand=' . implode( ',', $ids );
diff --git a/pages/SpecialMoveThread.php b/pages/SpecialMoveThread.php
index 77200ab..3030afc 100644
--- a/pages/SpecialMoveThread.php
+++ b/pages/SpecialMoveThread.php
@@ -104,8 +104,9 @@
 
                $rightsResult = $this->checkUserRights( 
$this->mThread->title(), $newtitle );
 
-               if ( $rightsResult !== true )
+               if ( $rightsResult !== true ) {
                        return $rightsResult;
+               }
 
                // @todo No status code from this method.
                $this->mThread->moveToPage( $newtitle, $reason, true );
diff --git a/pages/TalkpageView.php b/pages/TalkpageView.php
index c68eabf..359f80c 100644
--- a/pages/TalkpageView.php
+++ b/pages/TalkpageView.php
@@ -462,7 +462,9 @@
                if ( $article->exists() ) {
                        $pout = $article->getParserOutput();
                        $setLimit = $pout->getProperty( 'lqt-page-limit' );
-                       if ( $setLimit ) return $setLimit;
+                       if ( $setLimit ) {
+                               return $setLimit;
+                       }
                }
 
                global $wgLiquidThreadsDefaultPageLimit;
diff --git a/pages/ThreadPermalinkView.php b/pages/ThreadPermalinkView.php
index 9b7b78e..343bf25 100644
--- a/pages/ThreadPermalinkView.php
+++ b/pages/ThreadPermalinkView.php
@@ -68,12 +68,17 @@
                $talkTitle = $view->thread->getTitle()->getTalkPage();
 
                $articleClasses = array();
-               if ( !$articleTitle->exists() ) $articleClasses[] = 'new';
-               if ( $articleTitle->equals( $view->thread->getTitle() ) )
+               if ( !$articleTitle->exists() ) {
+                       $articleClasses[] = 'new';
+               }
+               if ( $articleTitle->equals( $view->thread->getTitle() ) ) {
                        $articleClasses[] = 'selected';
+               }
 
                $talkClasses = array();
-               if ( !$talkTitle->exists() ) $talkClasses[] = 'new';
+               if ( !$talkTitle->exists() ) {
+                       $talkClasses[] = 'new';
+               }
 
                if ( wfMessage( $articleTitle->getNamespaceKey() )->exists() ) {
                        $articleNamespaceText = wfMessage( 
$articleTitle->getNamespaceKey() )->text();
@@ -187,10 +192,11 @@
 
                $this->output->setSubtitle( $this->getSubtitle() );
 
-               if ( $this->methodApplies( 'summarize' ) )
+               if ( $this->methodApplies( 'summarize' ) ) {
                        $this->showSummarizeForm( $this->thread );
-               elseif ( $this->methodApplies( 'split' ) )
+               } elseif ( $this->methodApplies( 'split' ) ) {
                        $this->showSplitForm( $this->thread );
+               }
 
                $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => - 
1, 'maxCount' => - 1 ) );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/357692
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d5943c0de5a11cdedc21fc28ae64a15b6887b9e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LiquidThreads
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to