Merge "Code style cleanups to parserTest.inc and NewParserTest.php."
[lhc/web/wiklou.git] / includes / logging / LogPager.php
index fad1058..3fb7b89 100644 (file)
@@ -34,15 +34,15 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Constructor
         *
-        * @param $list LogEventsList
-        * @param $types String or Array: log types to show
-        * @param $performer String: the user who made the log entries
-        * @param $title String|Title: the page title the log entries are for
-        * @param $pattern String: do a prefix search rather than an exact title match
-        * @param $conds Array: extra conditions for the query
-        * @param $year Integer: the year to start from
-        * @param $month Integer: the month to start from
-        * @param $tagFilter String: tag
+        * @param LogEventsList $list
+        * @param string $types or Array: log types to show
+        * @param string $performer the user who made the log entries
+        * @param string|Title $title the page title the log entries are for
+        * @param string $pattern do a prefix search rather than an exact title match
+        * @param array $conds extra conditions for the query
+        * @param int $year The year to start from
+        * @param int $month The month to start from
+        * @param string $tagFilter tag
         */
        public function __construct( $list, $types = array(), $performer = '', $title = '', $pattern = '',
                $conds = array(), $year = false, $month = false, $tagFilter = '' ) {
@@ -71,16 +71,17 @@ class LogPager extends ReverseChronologicalPager {
        public function getFilterParams() {
                global $wgFilterLogTypes;
                $filters = array();
-               if( count( $this->types ) ) {
+               if ( count( $this->types ) ) {
                        return $filters;
                }
-               foreach( $wgFilterLogTypes as $type => $default ) {
+               foreach ( $wgFilterLogTypes as $type => $default ) {
                        // Avoid silly filtering
-                       if( $type !== 'patrol' || $this->getUser()->useNPPatrol() ) {
+                       if ( $type !== 'patrol' || $this->getUser()->useNPPatrol() ) {
                                $hide = $this->getRequest()->getInt( "hide_{$type}_log", $default );
                                $filters[$type] = $hide;
-                               if( $hide )
+                               if ( $hide ) {
                                        $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
+                               }
                        }
                }
                return $filters;
@@ -90,7 +91,7 @@ class LogPager extends ReverseChronologicalPager {
         * Set the log reader to return only entries of the given type.
         * Type restrictions enforced here
         *
-        * @param $types String or array: Log types ('upload', 'delete', etc);
+        * @param string $types or array: Log types ('upload', 'delete', etc);
         *   empty string means no restriction
         */
        private function limitType( $types ) {
@@ -98,11 +99,11 @@ class LogPager extends ReverseChronologicalPager {
 
                $user = $this->getUser();
                // If $types is not an array, make it an array
-               $types = ($types === '') ? array() : (array)$types;
+               $types = ( $types === '' ) ? array() : (array)$types;
                // Don't even show header for private logs; don't recognize it...
                $needReindex = false;
                foreach ( $types as $type ) {
-                       if( isset( $wgLogRestrictions[$type] )
+                       if ( isset( $wgLogRestrictions[$type] )
                                && !$user->isAllowed( $wgLogRestrictions[$type] )
                        ) {
                                $needReindex = true;
@@ -119,33 +120,35 @@ class LogPager extends ReverseChronologicalPager {
                // Also, only show them upon specific request to avoid suprises.
                $audience = $types ? 'user' : 'public';
                $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience, $user );
-               if( $hideLogs !== false ) {
+               if ( $hideLogs !== false ) {
                        $this->mConds[] = $hideLogs;
                }
-               if( count( $types ) ) {
+               if ( count( $types ) ) {
                        $this->mConds['log_type'] = $types;
                        // Set typeCGI; used in url param for paging
-                       if( count( $types ) == 1 ) $this->typeCGI = $types[0];
+                       if ( count( $types ) == 1 ) {
+                               $this->typeCGI = $types[0];
+                       }
                }
        }
 
        /**
         * Set the log reader to return only entries by the given user.
         *
-        * @param $name String: (In)valid user name
+        * @param string $name (In)valid user name
         * @return bool
         */
        private function limitPerformer( $name ) {
-               if( $name == '' ) {
+               if ( $name == '' ) {
                        return false;
                }
                $usertitle = Title::makeTitleSafe( NS_USER, $name );
-               if( is_null( $usertitle ) ) {
+               if ( is_null( $usertitle ) ) {
                        return false;
                }
                /* Fetch userid at first, if known, provides awesome query plan afterwards */
                $userid = User::idFromName( $name );
-               if( !$userid ) {
+               if ( !$userid ) {
                        /* It should be nicer to abort query at all,
                           but for now it won't pass anywhere behind the optimizer */
                        $this->mConds[] = "NULL";
@@ -153,9 +156,9 @@ class LogPager extends ReverseChronologicalPager {
                        $this->mConds['log_user'] = $userid;
                        // Paranoia: avoid brute force searches (bug 17342)
                        $user = $this->getUser();
-                       if( !$user->isAllowed( 'deletedhistory' ) ) {
+                       if ( !$user->isAllowed( 'deletedhistory' ) ) {
                                $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0';
-                       } elseif( !$user->isAllowed( 'suppressrevision' ) ) {
+                       } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
                                $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) .
                                        ' != ' . LogPage::SUPPRESSED_USER;
                        }
@@ -167,7 +170,7 @@ class LogPager extends ReverseChronologicalPager {
         * Set the log reader to return only entries affecting the given page.
         * (For the block and rights logs, this is a user page.)
         *
-        * @param $page String or Title object: Title name
+        * @param string $page or Title object: Title name
         * @param $pattern String
         * @return bool
         */
@@ -178,7 +181,7 @@ class LogPager extends ReverseChronologicalPager {
                        $title = $page;
                } else {
                        $title = Title::newFromText( $page );
-                       if( strlen( $page ) == 0 || !$title instanceof Title ) {
+                       if ( strlen( $page ) == 0 || !$title instanceof Title ) {
                                return false;
                        }
                }
@@ -198,7 +201,7 @@ class LogPager extends ReverseChronologicalPager {
                # use the page_time index.  That should have no more than a few hundred
                # log entries for even the busiest pages, so it can be safely scanned
                # in full to satisfy an impossible condition on user or similar.
-               if( $pattern && !$wgMiserMode ) {
+               if ( $pattern && !$wgMiserMode ) {
                        $this->mConds['log_namespace'] = $ns;
                        $this->mConds[] = 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() );
                        $this->pattern = $pattern;
@@ -208,10 +211,10 @@ class LogPager extends ReverseChronologicalPager {
                }
                // Paranoia: avoid brute force searches (bug 17342)
                $user = $this->getUser();
-               if( !$user->isAllowed( 'deletedhistory' ) ) {
-                       $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION) . ' = 0';
-               } elseif( !$user->isAllowed( 'suppressrevision' ) ) {
-                       $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION) .
+               if ( !$user->isAllowed( 'deletedhistory' ) ) {
+                       $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0';
+               } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
+                       $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) .
                                ' != ' . LogPage::SUPPRESSED_ACTION;
                }
        }
@@ -234,7 +237,7 @@ class LogPager extends ReverseChronologicalPager {
                # Add log_search table if there are conditions on it.
                # This filters the results to only include log rows that have
                # log_search records with the specified ls_field and ls_value values.
-               if( array_key_exists( 'ls_field', $this->mConds ) ) {
+               if ( array_key_exists( 'ls_field', $this->mConds ) ) {
                        $tables[] = 'log_search';
                        $index['log_search'] = 'ls_field_val';
                        $index['logging'] = 'PRIMARY';
@@ -249,12 +252,12 @@ class LogPager extends ReverseChronologicalPager {
                # Avoid usage of the wrong index by limiting
                # the choices of available indexes. This mainly
                # avoids site-breaking filesorts.
-               } elseif( $this->title || $this->pattern || $this->performer ) {
+               } elseif ( $this->title || $this->pattern || $this->performer ) {
                        $index['logging'] = array( 'page_time', 'user_time' );
-                       if( count( $this->types ) == 1 ) {
+                       if ( count( $this->types ) == 1 ) {
                                $index['logging'][] = 'log_user_type_time';
                        }
-               } elseif( count( $this->types ) == 1 ) {
+               } elseif ( count( $this->types ) == 1 ) {
                        $index['logging'] = 'type_time';
                } else {
                        $index['logging'] = 'times';
@@ -264,10 +267,10 @@ class LogPager extends ReverseChronologicalPager {
                $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' );
 
                $info = array(
-                       'tables'     => $tables,
-                       'fields'     => $fields,
-                       'conds'      => array_merge( $conds, $this->mConds ),
-                       'options'    => $options,
+                       'tables' => $tables,
+                       'fields' => $fields,
+                       'conds' => array_merge( $conds, $this->mConds ),
+                       'options' => $options,
                        'join_conds' => $joins,
                );
                # Add ChangeTags filter query
@@ -295,7 +298,7 @@ class LogPager extends ReverseChronologicalPager {
        public function getStartBody() {
                wfProfileIn( __METHOD__ );
                # Do a link batch query
-               if( $this->getNumRows() > 0 ) {
+               if ( $this->getNumRows() > 0 ) {
                        $lb = new LinkBatch;
                        foreach ( $this->mResult as $row ) {
                                $lb->add( $row->log_namespace, $row->log_title );