jenkins-bot has submitted this change and it was merged.

Change subject: Generalize recentChangesFlags rollup
......................................................................


Generalize recentChangesFlags rollup

Flags can be either 'any' or 'all' type, and both core and extension flags will 
be
rolled up into the top-level line of grouped changes.

See Ic49a355a2

Bug: T120921
Bug: T112856
Change-Id: If9fd6af3ac7ac2fbee9aa5536fe94d7574699966
---
M includes/DefaultSettings.php
M includes/changes/EnhancedChangesList.php
2 files changed, 51 insertions(+), 23 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  Jforrester: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 63d04c9..8f41cde 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -6479,6 +6479,10 @@
  *   'legend' => 'legend-msg',
  *   // optional (defaults to 'flag'), CSS class to put on changes lists rows
  *   'class' => 'css-class',
+ *   // optional (defaults to 'any'), how top-level flag is determined.  'any'
+ *   // will set the top-level flag if any line contains the flag, 'all' will
+ *   // only be set if all lines contain the flag.
+ *   'grouping' => 'any',
  * );
  * @endcode
  *
@@ -6489,23 +6493,27 @@
                'letter' => 'newpageletter',
                'title' => 'recentchanges-label-newpage',
                'legend' => 'recentchanges-legend-newpage',
+               'grouping' => 'any',
        ],
        'minor' => [
                'letter' => 'minoreditletter',
                'title' => 'recentchanges-label-minor',
                'legend' => 'recentchanges-legend-minor',
                'class' => 'minoredit',
+               'grouping' => 'all',
        ],
        'bot' => [
                'letter' => 'boteditletter',
                'title' => 'recentchanges-label-bot',
                'legend' => 'recentchanges-legend-bot',
                'class' => 'botedit',
+               'grouping' => 'all',
        ],
        'unpatrolled' => [
                'letter' => 'unpatrolledletter',
                'title' => 'recentchanges-label-unpatrolled',
                'legend' => 'recentchanges-legend-unpatrolled',
+               'grouping' => 'any',
        ],
 ];
 
diff --git a/includes/changes/EnhancedChangesList.php 
b/includes/changes/EnhancedChangesList.php
index 946c6d1..d79f316 100644
--- a/includes/changes/EnhancedChangesList.php
+++ b/includes/changes/EnhancedChangesList.php
@@ -157,8 +157,10 @@
         * Enhanced RC group
         * @param RCCacheEntry[] $block
         * @return string
+        * @throws DomainException
         */
        protected function recentChangesBlockGroup( $block ) {
+               $recentChangesFlags = $this->getConfig()->get( 
'RecentChangesFlags' );
 
                # Add the namespace and title of the block as part of the class
                $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 
'mw-enhanced-rc' ];
@@ -186,20 +188,24 @@
                $namehidden = true;
                $allLogs = true;
                $RCShowChangedSize = $this->getConfig()->get( 
'RCShowChangedSize' );
-               $collectedRcFlags = [
-                       // All are by bots?
-                       'bot' => true,
-                       // Includes a new page?
-                       'newpage' => false,
-                       // All are minor edits?
-                       'minor' => true,
-                       // Contains an unpatrolled edit?
-                       'unpatrolled' => false,
-               ];
-               foreach ( $block as $rcObj ) {
-                       if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
-                               $collectedRcFlags['newpage'] = true;
+
+               # Default values for RC flags
+               $collectedRcFlags = [];
+               foreach ( $recentChangesFlags as $key => $value ) {
+                       $flagGrouping = ( isset( 
$recentChangesFlags[$key]['grouping'] ) ?
+                                       $recentChangesFlags[$key]['grouping'] : 
'any' );
+                       switch ( $flagGrouping ) {
+                               case 'all':
+                                       $collectedRcFlags[$key] = true;
+                                       break;
+                               case 'any':
+                                       $collectedRcFlags[$key] = false;
+                                       break;
+                               default:
+                                       throw new DomainException( "Unknown 
grouping type \"{$flagGrouping}\"" );
                        }
+               }
+               foreach ( $block as $rcObj ) {
                        // If all log actions to this page were hidden, then 
don't
                        // give the name of the affected page for this block!
                        if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION 
) ) {
@@ -209,9 +215,6 @@
                        if ( !isset( $userlinks[$u] ) ) {
                                $userlinks[$u] = 0;
                        }
-                       if ( $rcObj->unpatrolled ) {
-                               $collectedRcFlags['unpatrolled'] = true;
-                       }
                        if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
                                $allLogs = false;
                        }
@@ -219,13 +222,6 @@
                        # since logs may not have these.
                        if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
                                $curId = $rcObj->mAttribs['rc_cur_id'];
-                       }
-
-                       if ( !$rcObj->mAttribs['rc_bot'] ) {
-                               $collectedRcFlags['bot'] = false;
-                       }
-                       if ( !$rcObj->mAttribs['rc_minor'] ) {
-                               $collectedRcFlags['minor'] = false;
                        }
 
                        $userlinks[$u]++;
@@ -267,6 +263,27 @@
                                // completely ignore this RC entry if we don't 
want to render it
                                unset( $block[$i] );
                        }
+
+                       // Roll up flags
+                       foreach ( $line['recentChangesFlagsRaw'] as $key => 
$value ) {
+                               $flagGrouping = ( isset( 
$recentChangesFlags[$key]['grouping'] ) ?
+                                       $recentChangesFlags[$key]['grouping'] : 
'any' );
+                               switch ( $flagGrouping ) {
+                                       case 'all':
+                                               if ( !$value ) {
+                                                       $collectedRcFlags[$key] 
= false;
+                                               }
+                                               break;
+                                       case 'any':
+                                               if ( $value ) {
+                                                       $collectedRcFlags[$key] 
= true;
+                                               }
+                                               break;
+                                       default:
+                                               throw new DomainException( 
"Unknown grouping type \"{$flagGrouping}\"" );
+                               }
+                       }
+
                        $lines[] = $line;
                }
                // Further down are some assumptions that $block is a 0-indexed 
array
@@ -436,8 +453,11 @@
                        return [];
                }
 
+               $lineParams['recentChangesFlagsRaw'] = [];
                if ( isset( $data['recentChangesFlags'] ) ) {
                        $lineParams['recentChangesFlags'] = 
$this->recentChangesFlags( $data['recentChangesFlags'] );
+                       # FIXME: This is used by logic, don't return it in the 
template params.
+                       $lineParams['recentChangesFlagsRaw'] = 
$data['recentChangesFlags'];
                        unset( $data['recentChangesFlags'] );
                }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If9fd6af3ac7ac2fbee9aa5536fe94d7574699966
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to