MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/89345
Change subject: WIP: factor out common code
......................................................................
WIP: factor out common code
Change-Id: I6f7f649d6cc6aaadf6fc86bc0de5e970c4b3fb37
---
M includes/specials/SpecialMobileWatchlist.php
1 file changed, 25 insertions(+), 36 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/45/89345/1
diff --git a/includes/specials/SpecialMobileWatchlist.php
b/includes/specials/SpecialMobileWatchlist.php
index 177fc63..85ed00c 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -65,6 +65,28 @@
wfProfileOut( __METHOD__ );
}
+ protected function getNSConditions( $column ) {
+ $conds = array();
+ switch( $this->filter ) {
+ case 'all':
+ // no-op
+ break;
+ case 'articles':
+ // @fixme content namespaces
+ $conds[] = "$column = 0"; // Has to be unquoted
or MySQL will filesort for wl_namespace
+ break;
+ case 'talk':
+ // @fixme associate with content namespaces? or
all talks?
+ $conds[] = "$column = 1";
+ break;
+ case 'other':
+ // @fixme
+ $conds[] = "$column IN (2, 4)";
+ break;
+ }
+ return $conds;
+ }
+
/**
* Add thumbs to a query, if installed and other preconditions are met
*
@@ -176,7 +198,7 @@
$dbr = wfGetDB( DB_SLAVE, 'watchlist' );
# Possible where conditions
- $conds = array();
+ $conds = $this->getNSConditions( 'rc_namespace' );
// snip....
@@ -206,24 +228,6 @@
}
}
- switch( $this->filter ) {
- case 'all':
- // no-op
- break;
- case 'articles':
- // @fixme content namespaces
- $conds['rc_namespace'] = 0;
- break;
- case 'talk':
- // @fixme associate with content namespaces? or all
talks?
- $conds['rc_namespace'] = 1;
- break;
- case 'other':
- // @fixme
- $conds['rc_namespace'] = array(2, 4);
- break;
- }
-
ChangeTags::modifyDisplayQuery( $tables, $fields, $conds,
$join_conds, $options, '' );
$values = array();
wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables,
&$join_conds, &$fields, &$values ) );
@@ -243,9 +247,8 @@
$dbr = wfGetDB( DB_SLAVE, 'watchlist' );
# Possible where conditions
- $conds = array(
- 'wl_user' => $user->getId()
- );
+ $conds = $this->getNSConditions( 'wl_namespace' );
+ $conds['wl_user'] = $user->getId();
$tables = array( 'watchlist', 'page', 'revision' );
$fields = array(
$dbr->tableName( 'watchlist' ) . '.*',
@@ -269,20 +272,6 @@
$this->doPageImages( $tables, $fields, $joinConds, 'page' );
$options['LIMIT'] = self::LIMIT + 1; // add one to decide
whether to show the more button
-
- switch( $this->filter ) {
- case 'all':
- break;
- case 'articles':
- $conds[] = 'wl_namespace = 0'; // Has to be unquoted or
MySQL will filesort
- break;
- case 'talk':
- $conds[] = 'wl_namespace = 1';
- break;
- case 'other':
- $conds['wl_namespace'] = array(2, 4);
- break;
- }
if ( $this->fromPageTitle ) {
$ns = $this->fromPageTitle->getNamespace();
--
To view, visit https://gerrit.wikimedia.org/r/89345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f7f649d6cc6aaadf6fc86bc0de5e970c4b3fb37
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits