From 826bcef0faf712a94d57555b687c713b7e3d8e58 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 29 Jun 2008 22:26:23 +0000 Subject: [PATCH] Fix regression from r36678: we can't use $this->dieUsageMsg() in a static method, so let's make ApiQueryBase::keyToTitle() and titleToKey() non-static. --- includes/api/ApiQueryAllCategories.php | 6 +++--- includes/api/ApiQueryAllLinks.php | 6 +++--- includes/api/ApiQueryAllUsers.php | 6 +++--- includes/api/ApiQueryAllimages.php | 6 +++--- includes/api/ApiQueryAllpages.php | 6 +++--- includes/api/ApiQueryBase.php | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index 4e675b0301..fe33eae05c 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -57,9 +57,9 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $this->addFields('cat_title'); if (!is_null($params['from'])) - $this->addWhere('cat_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); + $this->addWhere('cat_title>=' . $db->addQuotes($this->titleToKey($params['from']))); if (isset ($params['prefix'])) - $this->addWhere("cat_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); + $this->addWhere("cat_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'"); $this->addOption('LIMIT', $params['limit']+1); $this->addOption('ORDER BY', 'cat_title' . ($params['dir'] == 'descending' ? ' DESC' : '')); @@ -78,7 +78,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { if (++ $count > $params['limit']) { // We've reached the one extra which shows that there are additional cats to be had. Stop here... // TODO: Security issue - if the user has no right to view next title, it will still be shown - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->cat_title)); + $this->setContinueEnumParameter('from', $this->keyToTitle($row->cat_title)); break; } diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 6a77778e91..452b9ec91c 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -80,9 +80,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { } if (!is_null($params['from'])) - $this->addWhere('pl_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); + $this->addWhere('pl_title>=' . $db->addQuotes($this->titleToKey($params['from']))); if (isset ($params['prefix'])) - $this->addWhere("pl_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); + $this->addWhere("pl_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'"); if (is_null($resultPageSet)) { $this->addFields(array ( @@ -108,7 +108,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if (++ $count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... // TODO: Security issue - if the user has no right to view next title, it will still be shown - $this->setContinueEnumParameter('continue', ApiQueryBase :: keyToTitle($row->pl_title) . "|" . $row->pl_from); + $this->setContinueEnumParameter('continue', $this->keyToTitle($row->pl_title) . "|" . $row->pl_from); break; } diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 6f1fe0c567..220327d9c6 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -58,10 +58,10 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addTables('user', 'u1'); if( !is_null( $params['from'] ) ) - $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) ); + $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) ); if( isset( $params['prefix'] ) ) - $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' ); + $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( $this->keyToTitle( $params['prefix'] ) ) . '%"' ); if (!is_null($params['group'])) { // Filter only users that belong to a given group @@ -132,7 +132,7 @@ class ApiQueryAllUsers extends ApiQueryBase { if ($count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->user_name)); + $this->setContinueEnumParameter('from', $this->keyToTitle($row->user_name)); break; } diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index 8ccd93e224..11430ae79d 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -62,9 +62,9 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { // Image filters if (!is_null($params['from'])) - $this->addWhere('img_name>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); + $this->addWhere('img_name>=' . $db->addQuotes($this->titleToKey($params['from']))); if (isset ($params['prefix'])) - $this->addWhere("img_name LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); + $this->addWhere("img_name LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'"); if (isset ($params['minsize'])) { $this->addWhere('img_size>=' . intval($params['minsize'])); @@ -103,7 +103,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { if (++ $count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... // TODO: Security issue - if the user has no right to view next title, it will still be shown - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->img_name)); + $this->setContinueEnumParameter('from', $this->keyToTitle($row->img_name)); break; } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index b1e46bf3a9..c4ac486cf6 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -62,10 +62,10 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { $this->addWhereIf('page_is_redirect = 0', $params['filterredir'] === 'nonredirects'); $this->addWhereFld('page_namespace', $params['namespace']); $dir = ($params['dir'] == 'descending' ? 'older' : 'newer'); - $from = (is_null($params['from']) ? null : ApiQueryBase::titleToKey($params['from'])); + $from = (is_null($params['from']) ? null : $this->titleToKey($params['from'])); $this->addWhereRange('page_title', $dir, $from, null); if (isset ($params['prefix'])) - $this->addWhere("page_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); + $this->addWhere("page_title LIKE '" . $db->escapeLike($this->titleToKey($params['prefix'])) . "%'"); $forceNameTitleIndex = true; if (isset ($params['minsize'])) { @@ -130,7 +130,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { if (++ $count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... // TODO: Security issue - if the user has no right to view next title, it will still be shown - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->page_title)); + $this->setContinueEnumParameter('from', $this->keyToTitle($row->page_title)); break; } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index fe68e6fc01..90940703a1 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -323,7 +323,7 @@ abstract class ApiQueryBase extends ApiBase { * @param string $title Page title with spaces * @return string Page title with underscores */ - public static function titleToKey($title) { + public function titleToKey($title) { $t = Title::newFromText($title); if(!$t) $this->dieUsageMsg('invalidtitle', $title); @@ -335,7 +335,7 @@ abstract class ApiQueryBase extends ApiBase { * @param string $key Page title with underscores * @return string Page title with spaces */ - public static function keyToTitle($key) { + public function keyToTitle($key) { $t = Title::newFromDbKey($key); # This really shouldn't happen but we gotta check anyway if(!$t) -- 2.20.1