Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

SVN: [59258] trunk/phase3

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


reedy at svn

Nov 19, 2009, 9:57 AM

Post #1 of 1 (52 views)
Permalink
SVN: [59258] trunk/phase3

http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59258

Revision: 59258
Author: reedy
Date: 2009-11-19 17:57:27 +0000 (Thu, 19 Nov 2009)

Log Message:
-----------
bug 19523 prop=info&inprop=watched

Modified Paths:
--------------
trunk/phase3/CREDITS
trunk/phase3/HISTORY
trunk/phase3/includes/api/ApiQueryInfo.php

Modified: trunk/phase3/CREDITS
===================================================================
--- trunk/phase3/CREDITS 2009-11-19 17:33:57 UTC (rev 59257)
+++ trunk/phase3/CREDITS 2009-11-19 17:57:27 UTC (rev 59258)
@@ -53,6 +53,7 @@
* Rotem Liss
* Ryan Lane
* Ryan Schmidt
+* Sam Reed
* Shinjiman
* Siebrand Mazeland
* SQL
@@ -107,7 +108,6 @@
* Robert Treat
* RockMFR
* Roi Avinoam
-* Sam Reed
* ST47
* Scott Colcord
* Simon Walker

Modified: trunk/phase3/HISTORY
===================================================================
--- trunk/phase3/HISTORY 2009-11-19 17:33:57 UTC (rev 59257)
+++ trunk/phase3/HISTORY 2009-11-19 17:57:27 UTC (rev 59258)
@@ -333,6 +333,7 @@
* (bug 18617) Add xml:space="preserve" attribute to relevant tags in XML output
* (bug 17611) Provide a sensible error message on install when the SQLite data
directory is wrong.
+* (bug 19523) prop=info&inprop=watched

=== Languages updated in 1.15 ===


Modified: trunk/phase3/includes/api/ApiQueryInfo.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryInfo.php 2009-11-19 17:33:57 UTC (rev 59257)
+++ trunk/phase3/includes/api/ApiQueryInfo.php 2009-11-19 17:57:27 UTC (rev 59258)
@@ -34,10 +34,10 @@
* @ingroup API
*/
class ApiQueryInfo extends ApiQueryBase {
-
+
private $fld_protection = false, $fld_talkid = false,
$fld_subjectid = false, $fld_url = false,
- $fld_readable = false;
+ $fld_readable = false, $fld_watched = false;

public function __construct($query, $moduleName) {
parent :: __construct($query, $moduleName, 'in');
@@ -90,7 +90,7 @@
global $wgUser;
if(!$wgUser->isAllowed('edit'))
return false;
-
+
// The edit token is always the same, let's exploit that
static $cachedEditToken = null;
if(!is_null($cachedEditToken))
@@ -99,12 +99,12 @@
$cachedEditToken = $wgUser->editToken();
return $cachedEditToken;
}
-
+
public static function getDeleteToken($pageid, $title)
{
global $wgUser;
if(!$wgUser->isAllowed('delete'))
- return false;
+ return false;

static $cachedDeleteToken = null;
if(!is_null($cachedDeleteToken))
@@ -175,7 +175,7 @@
$cachedEmailToken = $wgUser->editToken();
return $cachedEmailToken;
}
-
+
public static function getImportToken($pageid, $title)
{
global $wgUser;
@@ -195,6 +195,7 @@
if(!is_null($this->params['prop'])) {
$prop = array_flip($this->params['prop']);
$this->fld_protection = isset($prop['protection']);
+ $this->fld_watched = isset($prop['watched']);
$this->fld_talkid = isset($prop['talkid']);
$this->fld_subjectid = isset($prop['subjectid']);
$this->fld_url = isset($prop['url']);
@@ -240,6 +241,9 @@
if ($this->fld_protection)
$this->getProtectionInfo();

+ if ($this->fld_watched)
+ $this->getWatchedInfo();
+
// Run the talkid/subjectid query if requested
if($this->fld_talkid || $this->fld_subjectid)
$this->getTSIDs();
@@ -296,11 +300,13 @@

if($this->fld_protection) {
$pageInfo['protection'] = array();
- if (isset($this->protections[$title->getNamespace()][$title->getDBkey()]))
+ if (isset($this->protections[$title->getNamespace()][$title->getDBkey()]))
$pageInfo['protection'] =
$this->protections[$title->getNamespace()][$title->getDBkey()];
$this->getResult()->setIndexedTagName($pageInfo['protection'], 'pr');
}
+ if($this->fld_watched && isset($this->watched[$title->getNamespace()][$title->getDBkey()]))
+ $pageInfo['watched'] = '';
if($this->fld_talkid && isset($this->talkids[$title->getNamespace()][$title->getDBkey()]))
$pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()];
if($this->fld_subjectid && isset($this->subjectids[$title->getNamespace()][$title->getDBkey()]))
@@ -309,9 +315,8 @@
$pageInfo['fullurl'] = $title->getFullURL();
$pageInfo['editurl'] = $title->getFullURL('action=edit');
}
- if($this->fld_readable)
- if($title->userCanRead())
- $pageInfo['readable'] = '';
+ if($this->fld_readable && $title->userCanRead())
+ $pageInfo['readable'] = '';
return $pageInfo;
}

@@ -444,7 +449,7 @@
$this->addWhere('pr_page = il_from');
$this->addWhereFld('pr_cascade', 1);
$this->addWhereFld('il_to', $images);
-
+
$res = $this->select(__METHOD__);
while($row = $db->fetchObject($res)) {
$source = Title::makeTitle($row->page_namespace, $row->page_title);
@@ -479,7 +484,7 @@
}
if(!count($getTitles))
return;
-
+
// Construct a custom WHERE clause that matches
// all titles in $getTitles
$lb = new LinkBatch($getTitles);
@@ -499,6 +504,35 @@
}
}

+ /**
+ * Get information about watched status and put it in $watched
+ */
+ private function getWatchedInfo()
+ {
+ global $wgUser;
+
+ if($wgUser->isAnon() || count($this->titles) == 0)
+ return;
+
+ $this->watched = array();
+ $db = $this->getDB();
+
+ $lb = new LinkBatch($this->titles);
+
+ $this->addTables(array('page', 'watchlist'));
+ $this->addFields(array('page_title', 'page_namespace'));
+ $this->addWhere($lb->constructSet('page', $db));
+ $this->addWhere('wl_title=page_title');
+ $this->addWhere('wl_namespace=page_namespace');
+ $this->addWhereFld('wl_user', $wgUser->getID());
+
+ $res = $this->select(__METHOD__);
+
+ while($row = $db->fetchObject($res)) {
+ $this->watched[$row->page_namespace][$row->page_title] = true;
+ }
+ }
+
public function getAllowedParams() {
return array (
'prop' => array (
@@ -507,6 +541,7 @@
ApiBase :: PARAM_TYPE => array (
'protection',
'talkid',
+ 'watched',
'subjectid',
'url',
'readable',
@@ -526,6 +561,7 @@
'Which additional properties to get:',
' protection - List the protection level of each page',
' talkid - The page ID of the talk page for each non-talk page',
+ ' watched - List the watched status of each page',
' subjectid - The page ID of the parent page for each talk page'
),
'token' => 'Request a token to perform a data-modifying action on a page',



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.