r36790 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36789‎ | r36790 | r36791 >
Date:22:26, 29 June 2008
Author:catrope
Status:old
Tags:
Comment:
Fix regression from r36678: we can't use $this->dieUsageMsg() in a static method, so let's make ApiQueryBase::keyToTitle() and titleToKey() non-static.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryAllCategories.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllimages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllLinks.php
@@ -80,9 +80,9 @@
8181 }
8282
8383 if (!is_null($params['from']))
84 - $this->addWhere('pl_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
 84+ $this->addWhere('pl_title>=' . $db->addQuotes($this->titleToKey($params['from'])));
8585 if (isset ($params['prefix']))
86 - $this->addWhere("pl_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
 86+ $this->addWhere("pl_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'");
8787
8888 if (is_null($resultPageSet)) {
8989 $this->addFields(array (
@@ -108,7 +108,7 @@
109109 if (++ $count > $limit) {
110110 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
111111 // TODO: Security issue - if the user has no right to view next title, it will still be shown
112 - $this->setContinueEnumParameter('continue', ApiQueryBase :: keyToTitle($row->pl_title) . "|" . $row->pl_from);
 112+ $this->setContinueEnumParameter('continue', $this->keyToTitle($row->pl_title) . "|" . $row->pl_from);
113113 break;
114114 }
115115
Index: trunk/phase3/includes/api/ApiQueryAllCategories.php
@@ -57,9 +57,9 @@
5858 $this->addFields('cat_title');
5959
6060 if (!is_null($params['from']))
61 - $this->addWhere('cat_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
 61+ $this->addWhere('cat_title>=' . $db->addQuotes($this->titleToKey($params['from'])));
6262 if (isset ($params['prefix']))
63 - $this->addWhere("cat_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
 63+ $this->addWhere("cat_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'");
6464
6565 $this->addOption('LIMIT', $params['limit']+1);
6666 $this->addOption('ORDER BY', 'cat_title' . ($params['dir'] == 'descending' ? ' DESC' : ''));
@@ -78,7 +78,7 @@
7979 if (++ $count > $params['limit']) {
8080 // We've reached the one extra which shows that there are additional cats to be had. Stop here...
8181 // TODO: Security issue - if the user has no right to view next title, it will still be shown
82 - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->cat_title));
 82+ $this->setContinueEnumParameter('from', $this->keyToTitle($row->cat_title));
8383 break;
8484 }
8585
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -62,10 +62,10 @@
6363 $this->addWhereIf('page_is_redirect = 0', $params['filterredir'] === 'nonredirects');
6464 $this->addWhereFld('page_namespace', $params['namespace']);
6565 $dir = ($params['dir'] == 'descending' ? 'older' : 'newer');
66 - $from = (is_null($params['from']) ? null : ApiQueryBase::titleToKey($params['from']));
 66+ $from = (is_null($params['from']) ? null : $this->titleToKey($params['from']));
6767 $this->addWhereRange('page_title', $dir, $from, null);
6868 if (isset ($params['prefix']))
69 - $this->addWhere("page_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
 69+ $this->addWhere("page_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'");
7070
7171 $forceNameTitleIndex = true;
7272 if (isset ($params['minsize'])) {
@@ -130,7 +130,7 @@
131131 if (++ $count > $limit) {
132132 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
133133 // TODO: Security issue - if the user has no right to view next title, it will still be shown
134 - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->page_title));
 134+ $this->setContinueEnumParameter('from', $this->keyToTitle($row->page_title));
135135 break;
136136 }
137137
Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -323,7 +323,7 @@
324324 * @param string $title Page title with spaces
325325 * @return string Page title with underscores
326326 */
327 - public static function titleToKey($title) {
 327+ public function titleToKey($title) {
328328 $t = Title::newFromText($title);
329329 if(!$t)
330330 $this->dieUsageMsg('invalidtitle', $title);
@@ -335,7 +335,7 @@
336336 * @param string $key Page title with underscores
337337 * @return string Page title with spaces
338338 */
339 - public static function keyToTitle($key) {
 339+ public function keyToTitle($key) {
340340 $t = Title::newFromDbKey($key);
341341 # This really shouldn't happen but we gotta check anyway
342342 if(!$t)
Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -58,10 +58,10 @@
5959 $this->addTables('user', 'u1');
6060
6161 if( !is_null( $params['from'] ) )
62 - $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) );
 62+ $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) );
6363
6464 if( isset( $params['prefix'] ) )
65 - $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' );
 65+ $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( $this->keyToTitle( $params['prefix'] ) ) . '%"' );
6666
6767 if (!is_null($params['group'])) {
6868 // Filter only users that belong to a given group
@@ -132,7 +132,7 @@
133133
134134 if ($count > $limit) {
135135 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
136 - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->user_name));
 136+ $this->setContinueEnumParameter('from', $this->keyToTitle($row->user_name));
137137 break;
138138 }
139139
Index: trunk/phase3/includes/api/ApiQueryAllimages.php
@@ -62,9 +62,9 @@
6363
6464 // Image filters
6565 if (!is_null($params['from']))
66 - $this->addWhere('img_name>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
 66+ $this->addWhere('img_name>=' . $db->addQuotes($this->titleToKey($params['from'])));
6767 if (isset ($params['prefix']))
68 - $this->addWhere("img_name LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
 68+ $this->addWhere("img_name LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'");
6969
7070 if (isset ($params['minsize'])) {
7171 $this->addWhere('img_size>=' . intval($params['minsize']));
@@ -103,7 +103,7 @@
104104 if (++ $count > $limit) {
105105 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
106106 // TODO: Security issue - if the user has no right to view next title, it will still be shown
107 - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->img_name));
 107+ $this->setContinueEnumParameter('from', $this->keyToTitle($row->img_name));
108108 break;
109109 }
110110

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r36678Use the proper Title methods in ApiQueryBase::titleToKey() and keyToTitle(). ...catrope15:48, 26 June 2008

Status & tagging log