From 15833dafdfb44c186393ab3c51e43543b65617c6 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 22 Mar 2013 08:39:02 +0100 Subject: [PATCH] Fix case of some Title methods Change-Id: I1a37ffb0e8cde4deac027721b0e463585b58d634 --- docs/title.txt | 8 ++++---- includes/GlobalFunctions.php | 2 +- includes/ImagePage.php | 2 +- includes/Linker.php | 4 ++-- includes/Title.php | 4 ++-- includes/api/ApiQuery.php | 2 +- includes/api/ApiQueryBase.php | 2 +- includes/filerepo/file/ForeignAPIFile.php | 2 +- includes/parser/CoreParserFunctions.php | 4 ++-- includes/parser/Parser.php | 6 +++--- languages/classes/LanguageIu.php | 2 +- languages/classes/LanguageKk.php | 2 +- languages/classes/LanguageKu.php | 2 +- languages/classes/LanguageShi.php | 2 +- languages/classes/LanguageSr.php | 2 +- maintenance/dumpLinks.php | 4 ++-- tests/phpunit/includes/TitleTest.php | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/title.txt b/docs/title.txt index d2d91c9c28..454711dcb1 100644 --- a/docs/title.txt +++ b/docs/title.txt @@ -8,7 +8,7 @@ and can be queried for the others, and for other attributes of the title. This is intended to be an immutable "value" class, so there are no mutator functions. To get a new instance, call Title::newFromText(). Once instantiated, the -non-static accessor methods can be used, such as getText(), getDBKey(), +non-static accessor methods can be used, such as getText(), getDBkey(), getNamespace(), etc. Note that Title::newFromText() may return false if the text is illegal according to the rules below. @@ -36,11 +36,11 @@ An initial colon in a title listed in wiki text may however suppress special handling for interlanguage links, image links, and category links. It is also used to indicate the main namespace in template inclusions. -Once prefixes have been stripped, the rest of the title processed this way: +Once prefixes have been stripped, the rest of the title processed this way: * Spaces and underscores are treated as equivalent and each is converted to the other in the appropriate context (underscore in URL and database keys, spaces - in plain text). + in plain text). * Multiple consecutive spaces are converted to a single space. * Leading or trailing space is removed. * If $wgCapitalLinks is enabled (the default), the first letter is capitalised, @@ -58,7 +58,7 @@ UTF-8, because that is the size of the database field. Special page titles may be up to 512 bytes. Note that Unicode Normal Form C (NFC) is enforced by MediaWiki's user interface -input functions, and so titles will typically be in this form. +input functions, and so titles will typically be in this form. getArticleID() needs some explanation: for "internal" articles, it should return the "page_id" field if the article exists, else it returns 0. For all external diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0b291ecbb5..90429268e9 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3940,7 +3940,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { # Handle redirects $redirectTitle = RepoGroup::singleton()->checkRedirect( Title::makeTitle( NS_FILE, $name ) ); if( $redirectTitle ) { - $name = $redirectTitle->getDbKey(); + $name = $redirectTitle->getDBkey(); } # Run the extension hook diff --git a/includes/ImagePage.php b/includes/ImagePage.php index aba9ab5613..b5b69df20d 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -719,7 +719,7 @@ EOT $limit = 100; $out = $this->getContext()->getOutput(); - $res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1 ); + $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 ); $rows = array(); $redirects = array(); foreach ( $res as $row ) { diff --git a/includes/Linker.php b/includes/Linker.php index 972adfceab..4f1d10e58b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -961,7 +961,7 @@ class Linker { */ protected static function getUploadUrl( $destFile, $query = '' ) { global $wgUploadMissingFileUrl, $wgUploadNavigationUrl; - $q = 'wpDestFile=' . $destFile->getPartialUrl(); + $q = 'wpDestFile=' . $destFile->getPartialURL(); if ( $query != '' ) $q .= '&' . $query; @@ -1527,7 +1527,7 @@ class Linker { $nodotdot = substr( $nodotdot, 3 ); } if ( $dotdotcount > 0 ) { - $exploded = explode( '/', $contextTitle->GetPrefixedText() ); + $exploded = explode( '/', $contextTitle->getPrefixedText() ); if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page $ret = implode( '/', array_slice( $exploded, 0, -$dotdotcount ) ); # / at the end means don't show full path diff --git a/includes/Title.php b/includes/Title.php index 80be529611..5ce742c6b6 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4070,8 +4070,8 @@ class Title { if ( $res->numRows() > 0 ) { foreach ( $res as $row ) { - // $data[] = Title::newFromText($wgContLang->getNSText ( NS_CATEGORY ).':'.$row->cl_to); - $data[$wgContLang->getNSText( NS_CATEGORY ) . ':' . $row->cl_to] = $this->getFullText(); + // $data[] = Title::newFromText($wgContLang->getNsText ( NS_CATEGORY ).':'.$row->cl_to); + $data[$wgContLang->getNsText( NS_CATEGORY ) . ':' . $row->cl_to] = $this->getFullText(); } } return $data; diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index f69ad2341b..7c64996ea9 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -513,7 +513,7 @@ class ApiQuery extends ApiBase { ApiQueryBase::addTitleInfo( $vals, $title ); $vals['special'] = ''; if ( $title->isSpecialPage() && - !SpecialPageFactory::exists( $title->getDbKey() ) ) { + !SpecialPageFactory::exists( $title->getDBkey() ) ) { $vals['missing'] = ''; } elseif ( $title->getNamespace() == NS_MEDIA && !wfFindFile( $title ) ) { diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 7819ead4b7..44fbf58c4d 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -432,7 +432,7 @@ abstract class ApiQueryBase extends ApiBase { if ( trim( $key ) == '' ) { return ''; } - $t = Title::newFromDbKey( $key ); + $t = Title::newFromDBkey( $key ); // This really shouldn't happen but we gotta check anyway if ( !$t ) { $this->dieUsageMsg( array( 'invalidtitle', $key ) ); diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index 4cc63080d7..edf623e281 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -54,7 +54,7 @@ class ForeignAPIFile extends File { */ static function newFromTitle( Title $title, $repo ) { $data = $repo->fetchImageQuery( array( - 'titles' => 'File:' . $title->getDBKey(), + 'titles' => 'File:' . $title->getDBkey(), 'iiprop' => self::getProps(), 'prop' => 'imageinfo', 'iimetadataversion' => MediaHandler::getMetadataVersion() diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 542ac0ff6d..6aef08ea23 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -555,7 +555,7 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canTalk() ) return ''; - return wfEscapeWikiText( $t->getTalkPage()->getPrefixedUrl() ); + return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() ); } static function subjectpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); @@ -567,7 +567,7 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedUrl() ); + return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() ); } /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 59f32d0a75..62e76c5ebe 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2756,7 +2756,7 @@ class Parser { case 'talkpagenamee': if ( $this->mTitle->canTalk() ) { $talkPage = $this->mTitle->getTalkPage(); - $value = wfEscapeWikiText( $talkPage->getPrefixedUrl() ); + $value = wfEscapeWikiText( $talkPage->getPrefixedURL() ); } else { $value = ''; } @@ -2767,7 +2767,7 @@ class Parser { break; case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); - $value = wfEscapeWikiText( $subjPage->getPrefixedUrl() ); + $value = wfEscapeWikiText( $subjPage->getPrefixedURL() ); break; case 'pageid': // requested in bug 23427 $pageid = $this->getTitle()->getArticleId(); @@ -3289,7 +3289,7 @@ class Parser { if ( !$found && $title ) { if ( !Profiler::instance()->isPersistent() ) { # Too many unique items can kill profiling DBs/collectors - $titleProfileIn = __METHOD__ . "-title-" . $title->getDBKey(); + $titleProfileIn = __METHOD__ . "-title-" . $title->getDBkey(); wfProfileIn( $titleProfileIn ); // template in } wfProfileIn( __METHOD__ . '-loadtpl' ); diff --git a/languages/classes/LanguageIu.php b/languages/classes/LanguageIu.php index fe5cdf8d41..14a564114e 100644 --- a/languages/classes/LanguageIu.php +++ b/languages/classes/LanguageIu.php @@ -168,7 +168,7 @@ class IuConverter extends LanguageConverter { */ function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { + if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); if ( preg_match( "/^$imagename:/", $text ) ) return $text; } diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php index f6bbae7d8c..d8a7e2c336 100644 --- a/languages/classes/LanguageKk.php +++ b/languages/classes/LanguageKk.php @@ -280,7 +280,7 @@ class KkConverter extends LanguageConverter { */ function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { + if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); if ( preg_match( "/^$imagename:/", $text ) ) return $text; } diff --git a/languages/classes/LanguageKu.php b/languages/classes/LanguageKu.php index 56a52ccba3..ef1b065108 100644 --- a/languages/classes/LanguageKu.php +++ b/languages/classes/LanguageKu.php @@ -188,7 +188,7 @@ class KuConverter extends LanguageConverter { */ function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { + if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); if ( preg_match( "/^$imagename:/", $text ) ) return $text; } diff --git a/languages/classes/LanguageShi.php b/languages/classes/LanguageShi.php index 5ddcfdeffd..001ad082e2 100644 --- a/languages/classes/LanguageShi.php +++ b/languages/classes/LanguageShi.php @@ -147,7 +147,7 @@ class ShiConverter extends LanguageConverter { */ function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { + if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); if ( preg_match( "/^$imagename:/", $text ) ) return $text; } diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php index 55aec32ea2..b29cfb8e92 100644 --- a/languages/classes/LanguageSr.php +++ b/languages/classes/LanguageSr.php @@ -139,7 +139,7 @@ class SrConverter extends LanguageConverter { */ function autoConvert( $text, $toVariant = false ) { global $wgTitle; - if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) { + if ( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE ) { $imagename = $wgTitle->getNsText(); if ( preg_match( "/^$imagename:/", $text ) ) return $text; } diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index 08aae2952f..7dfbec1e63 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -63,11 +63,11 @@ class DumpLinks extends Maintenance { $this->output( "\n" ); } $page = Title::makeTitle( $row->page_namespace, $row->page_title ); - $this->output( $page->getPrefixedUrl() ); + $this->output( $page->getPrefixedURL() ); $lastPage = $row->page_id; } $link = Title::makeTitle( $row->pl_namespace, $row->pl_title ); - $this->output( " " . $link->getPrefixedUrl() ); + $this->output( " " . $link->getPrefixedURL() ); } if ( isset( $lastPage ) ) $this->output( "\n" ); diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index cff8a2fe6e..970862b1e7 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -38,7 +38,7 @@ class TitleTest extends MediaWikiTestCase { function testBug31100FixSpecialName( $text, $expectedParam ) { $title = Title::newFromText( $text ); $fixed = $title->fixSpecialName(); - $stuff = explode( '/', $fixed->getDbKey(), 2 ); + $stuff = explode( '/', $fixed->getDBkey(), 2 ); if ( count( $stuff ) == 2 ) { $par = $stuff[1]; } else { -- 2.20.1