Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120805

Change subject: Handle miscounting of coalesced changes in client recent changes
......................................................................

Handle miscounting of coalesced changes in client recent changes

This normalises the count of coalesced changes.

In several months, the "normalisation" can be removed as such entries
will eventually be purged from recent changes table on Wikidata.

Bug: 45812
Change-Id: I4c82c610d2316450451fe97d0f490e0342f9d4e9
---
M client/includes/recentchanges/ExternalChangeFactory.php
1 file changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/05/120805/1

diff --git a/client/includes/recentchanges/ExternalChangeFactory.php 
b/client/includes/recentchanges/ExternalChangeFactory.php
index 900f06c..ef2f174 100644
--- a/client/includes/recentchanges/ExternalChangeFactory.php
+++ b/client/includes/recentchanges/ExternalChangeFactory.php
@@ -192,7 +192,7 @@
                //        Combine all the comments! Up to some max length?
                if ( array_key_exists( 'composite-comment', $changeParams ) ) {
                        $comment['key'] = 'wikibase-comment-multi';
-                       $comment['numparams'] = count( 
$changeParams['composite-comment'] );
+                       $comment['numparams'] = $this->countCompositeComments( 
$changeParams['composite-comment'] );
                } elseif ( array_key_exists( 'comment', $changeParams  ) ) {
                        $comment = $this->parseComment( 
$changeParams['comment'], $changeParams['type'] );
                }
@@ -200,4 +200,23 @@
                return $comment;
        }
 
+       /**
+        * @param array $comments
+        *
+        * @return int
+        */
+       private function countCompositeComments( $comments ) {
+               $compositeComments = array();
+
+               // normalizes for extra empty comment in rc_params (see bug 
45812)
+               // @fixme: can remove at some point in the future
+               foreach( $comments as $comment ) {
+                       if ( $comment !== array() ) {
+                               $compositeComments[] = $comment;
+                       }
+               }
+
+               return count( $compositeComments );
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c82c610d2316450451fe97d0f490e0342f9d4e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

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

Reply via email to