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

Change subject: Fix 'cur' and 'prev' links for topic summary
......................................................................


Fix 'cur' and 'prev' links for topic summary

* Fix caching of topic summary current revision.

* Fix extraction of oldRevision parameter.

* Make 'create-topic-summary' generate a 'diff-post-summary' link.

Bug: T113261
Change-Id: Ie7c179e73cc405e75d0011be2cc9300cc0c27c8b
---
M FlowActions.php
M includes/Block/TopicSummary.php
M includes/Formatter/AbstractQuery.php
3 files changed, 16 insertions(+), 7 deletions(-)

Approvals:
  Sbisson: Looks good to me, approved
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/FlowActions.php b/FlowActions.php
index 3e696b9..472037f 100644
--- a/FlowActions.php
+++ b/FlowActions.php
@@ -133,7 +133,7 @@
                        PostRevision::MODERATED_NONE => '',
                        PostRevision::MODERATED_LOCKED => '',
                ),
-               'links' => array( 'topic', 'topic-history', 'watch-topic', 
'unwatch-topic', 'summary-revision' ),
+               'links' => array( 'topic', 'topic-history', 
'diff-post-summary', 'watch-topic', 'unwatch-topic', 'summary-revision' ),
                'actions' => array( 'edit-topic-summary', 'lock-topic', 
'restore-topic' ),
                'history' => array(
                        'i18n-message' => 
'flow-rev-message-create-topic-summary',
diff --git a/includes/Block/TopicSummary.php b/includes/Block/TopicSummary.php
index 476b6c0..3080606 100644
--- a/includes/Block/TopicSummary.php
+++ b/includes/Block/TopicSummary.php
@@ -278,7 +278,7 @@
                                }
                                $oldRevision = null;
                                if ( isset( $options['oldRevision'] ) ) {
-                                       $oldRevision = $options['newRevision'];
+                                       $oldRevision = $options['oldRevision'];
                                }
                                list( $new, $old ) = Container::get( 
'query.postsummary.view' )->getDiffViewResult( UUID::create( 
$options['newRevision'] ), UUID::create( $oldRevision ) );
                                if (
diff --git a/includes/Formatter/AbstractQuery.php 
b/includes/Formatter/AbstractQuery.php
index 5c0cd36..0bbd072 100644
--- a/includes/Formatter/AbstractQuery.php
+++ b/includes/Formatter/AbstractQuery.php
@@ -177,7 +177,8 @@
                        /** @var AbstractRevision[] $result */
                        foreach ( $found as $result ) {
                                $rev = reset( $result );
-                               
$this->currentRevisionsCache[$rev->getCollectionId()->getAlphadecimal()] = 
$rev->getRevisionId();
+                               $cacheKey = $this->getCurrentRevisionCacheKey( 
$rev );
+                               $this->currentRevisionsCache[$cacheKey] = 
$rev->getRevisionId();
                                
$revisions[$rev->getRevisionId()->getAlphadecimal()] = $rev;
                        }
                }
@@ -328,15 +329,15 @@
         * @return AbstractRevision|null      AbstractRevision of the current 
revision.
         */
        protected function getCurrentRevision( AbstractRevision $revision ) {
-               $collectionId = $revision->getCollectionId();
-               if ( !isset( 
$this->currentRevisionsCache[$collectionId->getAlphadecimal()] ) ) {
+               $cacheKey = $this->getCurrentRevisionCacheKey( $revision );
+               if ( !isset( $this->currentRevisionsCache[$cacheKey] ) ) {
                        $currentRevision = 
$revision->getCollection()->getLastRevision();
 
-                       
$this->currentRevisionsCache[$collectionId->getAlphadecimal()] = 
$currentRevision->getRevisionId();
+                       $this->currentRevisionsCache[$cacheKey] = 
$currentRevision->getRevisionId();
                        
$this->revisionCache[$currentRevision->getRevisionId()->getAlphadecimal()] = 
$currentRevision;
                }
 
-               $currentRevisionId = 
$this->currentRevisionsCache[$collectionId->getAlphadecimal()];
+               $currentRevisionId = $this->currentRevisionsCache[$cacheKey];
                return 
$this->revisionCache[$currentRevisionId->getAlphaDecimal()];
        }
 
@@ -397,6 +398,14 @@
                        return $this->workflowCache[$alpha] = 
$this->storage->get( 'Workflow', $workflowId );
                }
        }
+
+       /**
+        * @param AbstractRevision $revision
+        * @return string
+        */
+       protected function getCurrentRevisionCacheKey( AbstractRevision 
$revision ) {
+               return $revision->getRevisionType() . '-' . 
$revision->getCollectionId()->getAlphadecimal();
+       }
 }
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7c179e73cc405e75d0011be2cc9300cc0c27c8b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to