Bsitu has uploaded a new change for review.

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


Change subject: Topic history has different cache key for loading and saving
......................................................................

Topic history has different cache key for loading and saving

Action from post editing/moderation would not reflect in the history till cache 
flush,
this is mainly due to some constraint in Index::cacheKey().  It wouldn't 
convert a
binary string to hex unless the key has an _id suffix.  In Topic block, we are 
passing
in UUID object, which would generate a cache key with hex value.  In insert 
hook, only
the binary string is passed and the key doesn't have _id suffix, which would 
generate a
cache key with binary value.

bug: 56688

Change-Id: Iea3aff55b15a22adc14f1fd6c5044bc7901896fa
---
M container.php
M includes/Block/Topic.php
M includes/Data/RevisionStorage.php
3 files changed, 9 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/00/95300/1

diff --git a/container.php b/container.php
index 528e0e2..c7372b1 100644
--- a/container.php
+++ b/container.php
@@ -271,7 +271,7 @@
                // belongs to, not just its parent. TopicHistoryIndex is a 
slight tweak to TopKIndex
                // using TreeRepository for extra information and stuffing it 
into topic_root while indexing
                new TopicHistoryIndex( $cache, $storage, $c['repository.tree'], 
'flow_revision:topic',
-                       array( 'topic_root' ),
+                       array( 'topic_root_id' ),
                        array(
                                'limit' => 500,
                                'sort' => 'rev_id',
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index def59d9..bcdb526 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -637,7 +637,7 @@
        protected function loadTopicHistory() {
                $found = $this->storage->find(
                        'PostRevision',
-                       array( 'topic_root' => $this->workflow->getId() ),
+                       array( 'topic_root_id' => $this->workflow->getId() ),
                        array( 'sort' => 'rev_id', 'order' => 'DESC', 'limit' 
=> 100 )
                );
                if ( $found ) {
diff --git a/includes/Data/RevisionStorage.php 
b/includes/Data/RevisionStorage.php
index 2540e16..b8b0547 100644
--- a/includes/Data/RevisionStorage.php
+++ b/includes/Data/RevisionStorage.php
@@ -452,25 +452,25 @@
        protected $treeRepository;
 
        public function __construct( BufferedCache $cache, PostRevisionStorage 
$storage, TreeRepository $treeRepo, $prefix, array $indexed, array $options = 
array() ) {
-               if ( $indexed !== array( 'topic_root' ) ) {
-                       throw new \MWException( __CLASS__ . ' is hardcoded to 
only index topic_root: ' . print_r( $indexed, true ) );
+               if ( $indexed !== array( 'topic_root_id' ) ) {
+                       throw new \MWException( __CLASS__ . ' is hardcoded to 
only index topic_root_id: ' . print_r( $indexed, true ) );
                }
                parent::__construct( $cache, $storage, $prefix, $indexed, 
$options );
                $this->treeRepository = $treeRepo;
        }
 
        public function onAfterInsert( $object, array $new ) {
-               $new['topic_root'] = $this->treeRepository->findRoot( 
UUID::create( $new['tree_rev_descendant_id'] ) )->getBinary();
+               $new['topic_root_id'] = $this->treeRepository->findRoot( 
UUID::create( $new['tree_rev_descendant_id'] ) )->getBinary();
                parent::onAfterInsert( $object, $new );
        }
 
        public function onAfterUpdate( $object, array $old, array $new ) {
-               $old['topic_root'] = $new['topic_root'] = 
$this->treeRepository->findRoot( UUID::create( $old['tree_rev_descendant_id'] ) 
)->getBinary();
+               $old['topic_root_id'] = $new['topic_root_id'] = 
$this->treeRepository->findRoot( UUID::create( $old['tree_rev_descendant_id'] ) 
)->getBinary();
                parent::onAfterUpdate( $object, $old, $new );
        }
 
        public function onAfterRemove( $object, array $old ) {
-               $old['topic_root'] = $this->treeRepository->findRoot( 
UUID::create( $old['tree_rev_descendant_id'] ) );
+               $old['topic_root_id'] = $this->treeRepository->findRoot( 
UUID::create( $old['tree_rev_descendant_id'] ) );
                parent::onAfterRemove( $object, $old );
        }
 
@@ -485,7 +485,7 @@
 
                $roots = array();
                foreach ( $queries as $idx => $features ) {
-                       $roots[] = UUID::create( $features['topic_root'] );
+                       $roots[] = UUID::create( $features['topic_root_id'] );
                }
                $nodeList = $this->treeRepository->fetchSubtreeNodeList( $roots 
);
                if ( $nodeList === false ) {
@@ -495,7 +495,7 @@
 
                $descendantQueries = array();
                foreach ( $queries as $idx => $features ) {
-                       $nodes = $nodeList[$features['topic_root']->getHex()];
+                       $nodes = 
$nodeList[$features['topic_root_id']->getHex()];
                        $descendantQueries[$idx] = array(
                                'tree_rev_descendant_id' => UUID::convertUUIDs( 
$nodes ),
                        );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea3aff55b15a22adc14f1fd6c5044bc7901896fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

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

Reply via email to