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

Change subject: Fix some issues for "sort by last activity"
......................................................................


Fix some issues for "sort by last activity"

* The result from topicListLastUpdatedStorage should convert UUID from binary 
to alpha
  ( missed rebase from UUID improvement patch )

* TopicListStorage::insert() takes array of arrays instead of an array
  ( missed rebase from Multiput patch )

* topic last activity timestamp should be always the same as topic workflow
  last modified timestamp.  We should not use wfTimestampNow() but use
  the time from topicworkflow.  If they are not the same, update to topKIndex
  would not be able to remove the old record

Change-Id: I637da2350d62f8a86b3263db8039b9475ee0f88b
---
M includes/Data/TopicListLastUpdatedStorage.php
M includes/Data/TopicListStorage.php
M includes/Data/WorkflowTopicListListener.php
M includes/Model/TopicListEntry.php
4 files changed, 38 insertions(+), 8 deletions(-)

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



diff --git a/includes/Data/TopicListLastUpdatedStorage.php 
b/includes/Data/TopicListLastUpdatedStorage.php
index 0d5ae39..49587d5 100644
--- a/includes/Data/TopicListLastUpdatedStorage.php
+++ b/includes/Data/TopicListLastUpdatedStorage.php
@@ -2,6 +2,8 @@
 
 namespace Flow\Data;
 
+use Flow\Model\UUID;
+
 /**
  * Storage class for topic list ordered by last updated
  */
@@ -32,7 +34,7 @@
 
                $result = array();
                foreach ( $res as $row ) {
-                       $result[] = (array) $row;
+                       $result[] = UUID::convertUUIDs( (array) $row, 
'alphadecimal' );
                }
 
                return $result;
diff --git a/includes/Data/TopicListStorage.php 
b/includes/Data/TopicListStorage.php
index 1282eb2..45f9285 100644
--- a/includes/Data/TopicListStorage.php
+++ b/includes/Data/TopicListStorage.php
@@ -11,12 +11,18 @@
         * We need workflow_last_update_timestamp for updating
         * the ordering in cache
         */
-       public function insert( array $row ) {
-               $row = parent::insert( $row );
-               if ( $row !== false ) {
-                       $row['workflow_last_update_timestamp'] = 
wfTimestampNow();
+       public function insert( array $rows ) {
+               $updateRows = array();
+               foreach ( $rows as $i => $row ) {
+                       unset( $row['workflow_last_update_timestamp'] );
+                       $updateRows[$i] = $row;
                }
-               return $row;
+               $res = parent::insert( $updateRows );
+               if ( $res ) {
+                       return $rows;
+               } else {
+                       return false;
+               }
        }
 
 }
diff --git a/includes/Data/WorkflowTopicListListener.php 
b/includes/Data/WorkflowTopicListListener.php
index 3cd5910..d8d3f20 100644
--- a/includes/Data/WorkflowTopicListListener.php
+++ b/includes/Data/WorkflowTopicListListener.php
@@ -57,7 +57,9 @@
                        $row = TopicListEntry::toStorageRow( $entry );
                        $this->topicListLastUpdatedIndex->onAfterUpdate(
                                $entry,
-                               $row,
+                               $row + array(
+                                       'workflow_last_update_timestamp' => 
$old['workflow_last_update_timestamp']
+                               ),
                                $row + array(
                                        'workflow_last_update_timestamp' => 
$new['workflow_last_update_timestamp']
                                )
diff --git a/includes/Model/TopicListEntry.php 
b/includes/Model/TopicListEntry.php
index 1c0d5d9..4967739 100644
--- a/includes/Model/TopicListEntry.php
+++ b/includes/Model/TopicListEntry.php
@@ -18,6 +18,11 @@
        protected $topicId;
 
        /**
+        * @var string|null
+        */
+       protected $topicWorkflowLastUpdated;
+
+       /**
         * @param Workflow $topicList
         * @param Workflow $topic
         * @return TopicListEntry
@@ -30,6 +35,7 @@
                $obj = new self;
                $obj->topicListId = $topicList->getId();
                $obj->topicId = $topic->getId();
+               $obj->topicWorkflowLastUpdated = $topic->getLastModified();
                return $obj;
        }
 
@@ -47,6 +53,9 @@
                }
                $obj->topicListId = UUID::create( $row['topic_list_id'] );
                $obj->topicId = UUID::create( $row['topic_id'] );
+               if ( isset( $row['workflow_last_update_timestamp'] ) ) {
+                       $obj->topicWorkflowLastUpdated = 
$row['workflow_last_update_timestamp'];
+               }
                return $obj;
        }
 
@@ -55,10 +64,14 @@
         * @return array
         */
        static public function toStorageRow( TopicListEntry $obj ) {
-               return array(
+               $row = array(
                        'topic_list_id' => $obj->topicListId->getAlphadecimal(),
                        'topic_id' => $obj->topicId->getAlphadecimal(),
                );
+               if ( $obj->topicWorkflowLastUpdated ) {
+                       $row['workflow_last_update_timestamp'] = 
$obj->topicWorkflowLastUpdated;
+               }
+               return $row;
        }
 
        /**
@@ -74,5 +87,12 @@
        public function getListId() {
                return $this->topicListId;
        }
+
+       /**
+        * @return timestamp|null
+        */
+       public function getTopicWorkflowLastUpdated() {
+               return $this->topicWorkflowLastUpdated;
+       }
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I637da2350d62f8a86b3263db8039b9475ee0f88b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <bs...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@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