[MediaWiki-commits] [Gerrit] Batchload all data required to fix Special:EditWatchlist titles - change (mediawiki...Flow)

2014-09-02 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Batchload all data required to fix Special:EditWatchlist titles
..


Batchload all data required to fix Special:EditWatchlist titles

This will batchload all the data needed for fetch the topic titles'
text when changing how Flow topics are linked to in
Special:EditWatchlist. All data being requested in that particular
hook will already be in memory because we've already fetched it here.

This depends on a core change: I30b3bbb2c5ef131f069a5aabfad8b88bc2cf09df
While this won't break when the core change isn't yet merged, we should
probably just hold off until it is.

Change-Id: Iec21012d15db53e23013aa6c36fed0e24e0ce6fe
---
M Flow.php
M Hooks.php
2 files changed, 35 insertions(+), 0 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, but someone else must approve
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Flow.php b/Flow.php
index 26bab26..5210258 100755
--- a/Flow.php
+++ b/Flow.php
@@ -343,6 +343,7 @@
 $wgHooks['AbortMove'][] = 'FlowHooks::onAbortMove';
 $wgHooks['TitleSquidURLs'][] = 'FlowHooks::onTitleSquidURLs';
 $wgHooks['WatchlistEditorBuildRemoveLine'][] = 
'FlowHooks::onWatchlistEditorBuildRemoveLine';
+$wgHooks['WatchlistEditorBeforeFormRender'][] = 
'FlowHooks::onWatchlistEditorBeforeFormRender';
 
 // Extension initialization
 $wgExtensionFunctions[] = 'FlowHooks::initFlowExtension';
diff --git a/Hooks.php b/Hooks.php
index 2212f47..78d9a18 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -927,4 +927,38 @@
 
return true;
}
+
+   /**
+* @param array $watchlistInfo Watchlisted pages
+* @return bool
+*/
+   public static function onWatchlistEditorBeforeFormRender( 
$watchlistInfo ) {
+   if ( !isset( $watchlistInfo[NS_TOPIC] ) ) {
+   // No topics watchlisted
+   return true;
+   }
+
+   $ids = array_keys( $watchlistInfo[NS_TOPIC] );
+
+   // build array of queries to be executed all at once
+   $queries = array();
+   foreach( $ids as $id ) {
+   $uuid = UUID::create( strtolower( $id ) );
+   $queries[] = array( 'rev_type_id' = $uuid );
+   }
+
+   /*
+* Now, finally find all requested topics - this will be stored 
in
+* local cache so subsequent calls (in 
onWatchlistEditorBuildRemoveLine)
+* will just find these in memory, instead of doing a bunch of 
network
+* requests.
+*/
+   Container::get( 'storage' )-findMulti(
+   'PostRevision',
+   $queries,
+   array( 'sort' = 'rev_id', 'order' = 'DESC', 'limit' 
= 1 )
+   );
+
+   return true;
+   }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iec21012d15db53e23013aa6c36fed0e24e0ce6fe
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie mmul...@wikimedia.org
Gerrit-Reviewer: Bsitu bs...@wikimedia.org
Gerrit-Reviewer: EBernhardson ebernhard...@wikimedia.org
Gerrit-Reviewer: Jdlrobson jrob...@wikimedia.org
Gerrit-Reviewer: Matthias Mullie mmul...@wikimedia.org
Gerrit-Reviewer: SG shah...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Batchload all data required to fix Special:EditWatchlist titles - change (mediawiki...Flow)

2014-08-25 Thread Matthias Mullie (Code Review)
Matthias Mullie has uploaded a new change for review.

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

Change subject: Batchload all data required to fix Special:EditWatchlist titles
..

Batchload all data required to fix Special:EditWatchlist titles

This will batchload all the data needed for fetch the topic titles'
text when changing how Flow topics are linked to in
Special:EditWatchlist. All data being requested in that particular
hook will already be in memory because we've already fetched it here.

This depends on a core change: I30b3bbb2c5ef131f069a5aabfad8b88bc2cf09df
While this won't break when the core change isn't yet merged, we should
probably just hold off until it is.

Change-Id: Iec21012d15db53e23013aa6c36fed0e24e0ce6fe
---
M Flow.php
M Hooks.php
2 files changed, 35 insertions(+), 0 deletions(-)


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

diff --git a/Flow.php b/Flow.php
index cabfc65..64c8634 100755
--- a/Flow.php
+++ b/Flow.php
@@ -341,6 +341,7 @@
 $wgHooks['CanonicalNamespaces'][] = 'FlowHooks::onCanonicalNamespaces';
 $wgHooks['AbortMove'][] = 'FlowHooks::onAbortMove';
 $wgHooks['WatchlistEditorBuildRemoveLine'][] = 
'FlowHooks::onWatchlistEditorBuildRemoveLine';
+$wgHooks['WatchlistEditorBeforeFormRender'][] = 
'FlowHooks::onWatchlistEditorBeforeFormRender';
 
 // Extension initialization
 $wgExtensionFunctions[] = 'FlowHooks::initFlowExtension';
diff --git a/Hooks.php b/Hooks.php
index 26e43e8..1f3cae2 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -892,4 +892,38 @@
 
return true;
}
+
+   /**
+* @param array $watchlistInfo Watchlisted pages
+* @return bool
+*/
+   public static function onWatchlistEditorBeforeFormRender( 
$watchlistInfo ) {
+   if ( !isset( $watchlistInfo[NS_TOPIC] ) ) {
+   // No topics watchlisted
+   return true;
+   }
+
+   $ids = array_keys( $watchlistInfo[NS_TOPIC] );
+
+   // build array of queries to be executed all at once
+   $queries = array();
+   foreach( $ids as $id ) {
+   $uuid = UUID::create( $id );
+   $queries[] = array( 'rev_type_id' = strtolower( $uuid 
) );
+   }
+
+   /*
+* Now, finally find all requested topics - this will be stored 
in
+* local cache so subsequent calls (in 
onWatchlistEditorBuildRemoveLine)
+* will just find these in memory, instead of doing a bunch of 
network
+* requests.
+*/
+   Container::get( 'storage' )-findMulti(
+   'PostRevision',
+   $queries,
+   array( 'sort' = 'rev_id', 'order' = 'DESC', 'limit' 
= 1 )
+   );
+
+   return true;
+   }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec21012d15db53e23013aa6c36fed0e24e0ce6fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie mmul...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits