Krinkle has uploaded a new change for review.

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


Change subject: [WIP] recentchanges: Implement support for pagesets
......................................................................

[WIP] recentchanges: Implement support for pagesets

See bug 55377 for information, implementation is not ready!

Issues:
* Should probably not reuse the ApiQuery's page set, that one
  is for property modules, not list modules. Since these params
  are not prefixed as-is, it might cause a regression if someone
  is combining a prop query with a list query, like:
  action=query titles=Foo prop=categories & list=recentchanges
  Where the recentchanges is not supposed to be filtered.
  This works, but this change would make that recentchanges query
  filtered.
  Could be prefixed with 'rc', but having
  titles/pageids/converttitles/generator is nice, so perhaps find
  a way to use 2 page sets, and prefix one of them.

* Figure out whehter to query by page id, or by page title.
  Doing by page id would require an extra sql index. The old
  implementation (reverted in r46823) did a page title query.
  However that is slightly counterintuitive when working with pages
  that have been renamed, watchlist presumably suffers from this
  as well (though we currently update watchlist manually when
  someone moves a page).

Follows-up r31348, r46823.

Bug: 55377
Change-Id: I1e69966c0f944ca644d977cb18822a8536dafd5a
---
M includes/api/ApiQueryRecentChanges.php
1 file changed, 24 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/54/92654/1

diff --git a/includes/api/ApiQueryRecentChanges.php 
b/includes/api/ApiQueryRecentChanges.php
index 6b10bdc..0561bc4 100644
--- a/includes/api/ApiQueryRecentChanges.php
+++ b/includes/api/ApiQueryRecentChanges.php
@@ -139,8 +139,11 @@
         */
        public function run( $resultPageSet = null ) {
                $user = $this->getUser();
-               /* Get the parameters of the request. */
+               $result = $this->getResult();
                $params = $this->extractRequestParams();
+
+               $pageSet = $this->getPageSet();
+               $pageSet->execute();
 
                /* Build our basic query. Namely, something along the lines of:
                 * SELECT * FROM recentchanges WHERE rc_timestamp > $start
@@ -177,6 +180,26 @@
 
                $this->addWhereFld( 'rc_namespace', $params['namespace'] );
                $this->addWhereFld( 'rc_deleted', 0 );
+
+
+               // Recent changes stores titles separetely from pageids (they 
are a snapshot from the
+               // time the edit was made), therefor we need to adjust the 
query depending on the
+               // data source. E.g. if "Foo" was renamed to "Bar", quering for 
"Foo" would return
+               // edits from before the rename, and edits made to the redirect 
page after the rename.
+               // FIXME: Though using rc_title/rc_namespace performs better 
than rc_cur_id queries,
+               // in most cases this is probably confusing since quering for 
"Bar" should return
+               // all edits made to that page, regardless of whether it was 
named differently in the past.
+               // Maybe turn this into a separate flag that can be enabled by 
the user.
+               // FIXME: rc_cur_id queries like these are not indexed.
+               if ( $pageSet->getDataSource() === 'titles' ) {
+                       $titles = $pageSet->getTitles(); // 0 => Title object
+                       $lb = new LinkBatch( $titles );
+                       // rc_namespace, rc_title
+                       $this->addWhere( $lb->constructSet( 'rc', 
$this->getDB() ) );
+               } else {
+                       $titles = $pageSet->getGoodTitles(); // page_id => 
Title object
+                       $this->addWhereFld( 'rc_cur_id', array_keys( $titles ) 
);
+               }
 
                if ( !is_null( $params['type'] ) ) {
                        $this->addWhereFld( 'rc_type', $this->parseRCType( 
$params['type'] ) );
@@ -307,7 +330,6 @@
 
                $titles = array();
 
-               $result = $this->getResult();
 
                /* Iterate through the rows, adding data extracted from them to 
our query result. */
                foreach ( $res as $row ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e69966c0f944ca644d977cb18822a8536dafd5a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

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

Reply via email to