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

Change subject: Show most recent items for watchlist but recentchanges
......................................................................


Show most recent items for watchlist but recentchanges

(cherry picked from commit 82ae7c0018633e364514a4ceed2783c691cb9d94)

Change-Id: Ia87d94d43034e54317eac5e352062afe7c8827fa
---
M Hooks.php
M includes/RecentChanges/Formatter.php
2 files changed, 30 insertions(+), 4 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 896de24..a576534 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -101,8 +101,15 @@
                        return true;
                }
 
-               $line = Container::get( 'recentchanges.formatter' )->format( 
$changesList, $rc );
-
+               try {
+                       $formatter = Container::get( 'recentchanges.formatter' 
);
+                       $watchlist = $formatter->isWatchlist( $classes );
+                       $line = $formatter->format( $changesList, $rc, 
$watchlist );
+               } catch ( FlowException $e ) {
+                       wfWarn( __METHOD__ . ': Exception formatting rc ' . 
$rc->getAttribute( 'rc_id' ) . ' ' . $e );
+                       \MWExceptionHandler::logException( $e );
+                       return false;
+               }
                if ( $line === false ) {
                        return false;
                }
diff --git a/includes/RecentChanges/Formatter.php 
b/includes/RecentChanges/Formatter.php
index 7f34473..2d998c7 100644
--- a/includes/RecentChanges/Formatter.php
+++ b/includes/RecentChanges/Formatter.php
@@ -16,7 +16,13 @@
         */
        protected $displayStatus = array();
 
-       public function format( ChangesList $cl, RecentChange $rc ) {
+       /**
+        * @param ChangesList $cl
+        * @param RecentChange $rc
+        * @param bool $watchlist
+        * @return string|bool Output line, or false on failure
+        */
+       public function format( ChangesList $cl, RecentChange $rc, $watchlist = 
false ) {
                $params = unserialize( $rc->getAttribute( 'rc_params' ) );
                $changeData = $params['flow-workflow-change'];
 
@@ -58,7 +64,7 @@
                        return false;
                }
 
-               if ( $this->hideRecord( $revision, $changeData ) ) {
+               if ( $watchlist && $this->hideRecord( $revision, $changeData ) 
) {
                        return false;
                }
 
@@ -147,6 +153,19 @@
                return false;
        }
 
+       // @todo:
+       // This is a temporary fix.
+       // We will add a param to core hook to determine if this is watchlist 
page
+       // Or add a method to the ChangesList to test for its $watchlist 
property
+       public function isWatchList( array $classes ) {
+               foreach ( $classes as $class ) {
+                       if ( substr( $class, 0, 10 ) === 'watchlist-' ) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
        protected function changeSeparator() {
                return ' <span class="mw-changeslist-separator">. .</span> ';
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia87d94d43034e54317eac5e352062afe7c8827fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: wmf/1.23wmf14
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Bsitu <bs...@wikimedia.org>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
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