r101037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101036‎ | r101037 | r101038 >
Date:20:23, 27 October 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Per Nikerabbit's comment on r100621:
* Removed OutputPage::setPageTitleMsg() and OutputPage::setHTMLTitleMsg() and make OutputPage::setPageTitle() and OutputPage::setHTMLTitle() accept a Message object
* Updated core calls (including some that I missed last time because of non-matching case)
* Added Message::setContext() and use it in RequestContext so that I don't need to duplicate the call in OutputPage
* Yes, I'm calling $this->msg() on places and then setting the context one more time in OutputPage::setPageTitle() or OutputPage::setHTMLTitle(), but at least I won't be confused about which objects $
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/Message.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/actions/MarkpatrolledAction.php (modified) (history)
  • /trunk/phase3/includes/actions/RollbackAction.php (modified) (history)
  • /trunk/phase3/includes/context/RequestContext.php (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAllpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlock.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialDeletedContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialEditWatchlist.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialEmailuser.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPrefixindex.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchangeslinked.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialTags.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnblock.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWhatlinkshere.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProtectionForm.php
@@ -224,7 +224,7 @@
225225 }
226226
227227 $titleLink = Linker::link( $this->mTitle );
228 - $wgOut->setPageTitleMsg( 'protect-title', $this->mTitle->getPrefixedText() );
 228+ $wgOut->setPageTitle( wfMessage( 'protect-title', $this->mTitle->getPrefixedText() ) );
229229 $wgOut->setSubtitle( wfMsg( 'protect-backlink', $titleLink ) );
230230
231231 # Show an appropriate message if the user isn't allowed or able to change
Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -188,7 +188,7 @@
189189 $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ),
190190 $this->deletedIdMarker( $this->mOldid ),
191191 $this->deletedIdMarker( $this->mNewid ) );
192 - $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
 192+ $wgOut->setPageTitle( wfMessage( 'errorpagetitle' ) );
193193 $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", "<span class='plainlinks'>$d</span>" );
194194 wfProfileOut( __METHOD__ );
195195 return;
Index: trunk/phase3/includes/Article.php
@@ -1334,7 +1334,7 @@
13351335 return;
13361336 }
13371337
1338 - $wgOut->setPagetitle( wfMsg( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
 1338+ $wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
13391339
13401340 # Better double-check that it hasn't been deleted yet!
13411341 $dbw = wfGetDB( DB_MASTER );
@@ -1529,7 +1529,7 @@
15301530 if ( $this->mPage->doDeleteArticle( $reason, $suppress, $id, $error ) ) {
15311531 $deleted = $this->getTitle()->getPrefixedText();
15321532
1533 - $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
 1533+ $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
15341534 $wgOut->setRobotPolicy( 'noindex,nofollow' );
15351535
15361536 $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
Index: trunk/phase3/includes/ImagePage.php
@@ -795,7 +795,7 @@
796796 */
797797 function showError( $description ) {
798798 global $wgOut;
799 - $wgOut->setPageTitle( wfMsg( 'internalerror' ) );
 799+ $wgOut->setPageTitle( wfMessage( 'internalerror' ) );
800800 $wgOut->setRobotPolicy( 'noindex,nofollow' );
801801 $wgOut->setArticleRelated( false );
802802 $wgOut->enableClientCache( false );
Index: trunk/phase3/includes/EditPage.php
@@ -1361,10 +1361,10 @@
13621362 global $wgOut;
13631363 $wgOut->setRobotPolicy( 'noindex,nofollow' );
13641364 if ( $this->isConflict ) {
1365 - $wgOut->setPageTitleMsg( 'editconflict', $this->getContextTitle()->getPrefixedText() );
 1365+ $wgOut->setPageTitle( wfMessage( 'editconflict', $this->getContextTitle()->getPrefixedText() ) );
13661366 } elseif ( $this->section != '' ) {
13671367 $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection';
1368 - $wgOut->setPageTitleMsg( $msg, $this->getContextTitle()->getPrefixedText() );
 1368+ $wgOut->setPageTitle( wfMessage( $msg, $this->getContextTitle()->getPrefixedText() ) );
13691369 } else {
13701370 # Use the title defined by DISPLAYTITLE magic word when present
13711371 if ( isset( $this->mParserOutput )
@@ -1373,7 +1373,7 @@
13741374 } else {
13751375 $title = $this->getContextTitle()->getPrefixedText();
13761376 }
1377 - $wgOut->setPageTitleMsg( 'editing', $title );
 1377+ $wgOut->setPageTitle( wfMessage( 'editing', $title ) );
13781378 }
13791379 }
13801380
@@ -2226,7 +2226,7 @@
22272227 array( 'returnto' => $this->getContextTitle()->getPrefixedText() )
22282228 );
22292229
2230 - $wgOut->setPageTitleMsg( 'whitelistedittitle' );
 2230+ $wgOut->setPageTitle( wfMessage( 'whitelistedittitle' ) );
22312231 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22322232 $wgOut->setArticleRelated( false );
22332233
@@ -2241,7 +2241,7 @@
22422242 function noSuchSectionPage() {
22432243 global $wgOut;
22442244
2245 - $wgOut->setPageTitleMsg( 'nosuchsectiontitle' );
 2245+ $wgOut->setPageTitle( wfMessage( 'nosuchsectiontitle' ) );
22462246 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22472247 $wgOut->setArticleRelated( false );
22482248
@@ -2261,7 +2261,7 @@
22622262 static function spamPage( $match = false ) {
22632263 global $wgOut, $wgTitle;
22642264
2265 - $wgOut->setPageTitleMsg( 'spamprotectiontitle' );
 2265+ $wgOut->setPageTitle( wfMessage( 'spamprotectiontitle' ) );
22662266 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22672267 $wgOut->setArticleRelated( false );
22682268
@@ -2284,7 +2284,7 @@
22852285 global $wgOut;
22862286 $this->textbox2 = $this->textbox1;
22872287
2288 - $wgOut->setPageTitleMsg( 'spamprotectiontitle' );
 2288+ $wgOut->setPageTitle( wfMessage( 'spamprotectiontitle' ) );
22892289 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22902290 $wgOut->setArticleRelated( false );
22912291
@@ -2845,7 +2845,7 @@
28462846
28472847 function noCreatePermission() {
28482848 global $wgOut;
2849 - $wgOut->setPageTitleMsg( 'nocreatetitle' );
 2849+ $wgOut->setPageTitle( wfMessage( 'nocreatetitle' ) );
28502850 $wgOut->addWikiMsg( 'nocreatetext' );
28512851 }
28522852
Index: trunk/phase3/includes/OutputPage.php
@@ -760,23 +760,14 @@
761761 * @param $name string
762762 */
763763 public function setHTMLTitle( $name ) {
764 - $this->mHTMLtitle = $name;
 764+ if ( $name instanceof Message ) {
 765+ $this->mHTMLtitle = $name->setContext( $this->getContext() )->text();
 766+ } else {
 767+ $this->mHTMLtitle = $name;
 768+ }
765769 }
766770
767771 /**
768 - * Same as setHTMLTitle(), but takes a message name and parameter instead
769 - * of directly the string to display.
770 - *
771 - * @since 1.19
772 - * @param $name String message name
773 - * @param $args Array|String message parameters, if there's only one
774 - * parameter it can be passed directly as a string.
775 - */
776 - public function setHTMLTitleMsg( $name, $args = array() ) {
777 - $this->setHTMLTitle( $this->msg( $name, $args )->text() );
778 - }
779 -
780 - /**
781772 * Return the "HTML title", i.e. the content of the <title> tag.
782773 *
783774 * @return String
@@ -791,32 +782,23 @@
792783 * This function automatically sets \<title\> to the same content as \<h1\> but with all tags removed.
793784 * Bad tags that were escaped in \<h1\> will still be escaped in \<title\>, and good tags like \<i\> will be dropped entirely.
794785 *
795 - * @param $name string
 786+ * @param $name string|Message
796787 */
797788 public function setPageTitle( $name ) {
 789+ if ( $name instanceof Message ) {
 790+ $name = $name->setContext( $this->getContext() )->text();
 791+ }
 792+
798793 # change "<script>foo&bar</script>" to "&lt;script&gt;foo&amp;bar&lt;/script&gt;"
799794 # but leave "<i>foobar</i>" alone
800795 $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) );
801796 $this->mPagetitle = $nameWithTags;
802797
803798 # change "<i>foo&amp;bar</i>" to "foo&bar"
804 - $this->setHTMLTitleMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) );
 799+ $this->setHTMLTitle( $this->msg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
805800 }
806801
807802 /**
808 - * Same as setPageTitle(), but takes a message name and parameter instead
809 - * of directly the string to display.
810 - *
811 - * @since 1.19
812 - * @param $name String message name
813 - * @param $args Array|String message parameters, if there's only one
814 - * parameter it can be passed directly as a string.
815 - */
816 - public function setPageTitleMsg( $name, $args = array() ) {
817 - $this->setPageTitle( $this->msg( $name, $args )->text() );
818 - }
819 -
820 - /**
821803 * Return the "page title", i.e. the content of the \<h1\> tag.
822804 *
823805 * @return String
@@ -1956,8 +1938,8 @@
19571939 if ( $this->getTitle() ) {
19581940 $this->mDebugtext .= 'Original title: ' . $this->getTitle()->getPrefixedText() . "\n";
19591941 }
1960 - $this->setPageTitleMsg( $title );
1961 - $this->setHTMLTitleMsg( 'errorpagetitle' );
 1942+ $this->setPageTitle( $this->msg( $title ) );
 1943+ $this->setHTMLTitle( $this->msg( 'errorpagetitle' ) );
19621944 $this->setRobotPolicy( 'noindex,nofollow' );
19631945 $this->setArticleRelated( false );
19641946 $this->enableClientCache( false );
@@ -1982,8 +1964,8 @@
19831965 public function showPermissionsErrorPage( $errors, $action = null ) {
19841966 $this->mDebugtext .= 'Original title: ' .
19851967 $this->getTitle()->getPrefixedText() . "\n";
1986 - $this->setPageTitleMsg( 'permissionserrors' );
1987 - $this->setHTMLTitleMsg( 'permissionserrors' );
 1968+ $this->setPageTitle( $this->msg( 'permissionserrors' ) );
 1969+ $this->setHTMLTitle( $this->msg('permissionserrors' ) );
19881970 $this->setRobotPolicy( 'noindex,nofollow' );
19891971 $this->setArticleRelated( false );
19901972 $this->enableClientCache( false );
@@ -1999,8 +1981,8 @@
20001982 * @param $version Mixed: the version of MediaWiki needed to use the page
20011983 */
20021984 public function versionRequired( $version ) {
2003 - $this->setPageTitleMsg( 'versionrequired' );
2004 - $this->setHTMLTitleMsg( 'versionrequired', $version );
 1985+ $this->setPageTitle( $this->msg( 'versionrequired' ) );
 1986+ $this->setHTMLTitle( $this->msg( 'versionrequired', $version ) );
20051987 $this->setRobotPolicy( 'noindex,nofollow' );
20061988 $this->setArticleRelated( false );
20071989 $this->mBodytext = '';
@@ -2026,8 +2008,8 @@
20272009 throw new PermissionsError( 'read' );
20282010 }
20292011
2030 - $this->setPageTitleMsg( 'loginreqtitle' );
2031 - $this->setHTMLTitleMsg( 'errorpagetitle' );
 2012+ $this->setPageTitle( $this->msg( 'loginreqtitle' ) );
 2013+ $this->setHTMLTitle( $this->msg( 'errorpagetitle' ) );
20322014 $this->setRobotPolicy( 'noindex,nofollow' );
20332015 $this->setArticleRelated( false );
20342016
@@ -2119,12 +2101,12 @@
21202102 if ( !empty( $reasons ) ) {
21212103 // Permissions error
21222104 if( $source ) {
2123 - $this->setPageTitleMsg( 'viewsource' );
 2105+ $this->setPageTitle( $this->msg( 'viewsource' ) );
21242106 $this->setSubtitle(
21252107 $this->msg( 'viewsourcefor', Linker::linkKnown( $this->getTitle() ) )->text()
21262108 );
21272109 } else {
2128 - $this->setPageTitleMsg( 'badaccess' );
 2110+ $this->setPageTitle( $this->msg( 'badaccess' ) );
21292111 }
21302112 $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
21312113 } else {
@@ -2194,7 +2176,7 @@
21952177 }
21962178
21972179 public function showFatalError( $message ) {
2198 - $this->setPageTitleMsg( 'internalerror' );
 2180+ $this->setPageTitle( $this->msg( 'internalerror' ) );
21992181 $this->setRobotPolicy( 'noindex,nofollow' );
22002182 $this->setArticleRelated( false );
22012183 $this->enableClientCache( false );
@@ -2286,7 +2268,7 @@
22872269 $ret = Html::htmlHeader( array( 'lang' => $this->getLang()->getCode(), 'dir' => $userdir, 'class' => 'client-nojs' ) );
22882270
22892271 if ( $this->getHTMLTitle() == '' ) {
2290 - $this->setHTMLTitleMsg( 'pagetitle', $this->getPageTitle() );
 2272+ $this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() ) );
22912273 }
22922274
22932275 $openHead = Html::openElement( 'head' );
Index: trunk/phase3/includes/context/RequestContext.php
@@ -252,7 +252,7 @@
253253 */
254254 public function msg() {
255255 $args = func_get_args();
256 - return call_user_func_array( 'wfMessage', $args )->inLanguage( $this->getLang() )->title( $this->getTitle() );
 256+ return call_user_func_array( 'wfMessage', $args )->setContext( $this );
257257 }
258258
259259 /** Static methods **/
Index: trunk/phase3/includes/actions/MarkpatrolledAction.php
@@ -67,7 +67,7 @@
6868 $return = SpecialPage::getTitleFor( $returnto );
6969
7070 if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) {
71 - $this->getOutput()->setPageTitleMsg( 'markedaspatrollederror' );
 71+ $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrollederror' ) );
7272 $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
7373 $this->getOutput()->returnToMain( null, $return );
7474 return;
@@ -79,7 +79,7 @@
8080 }
8181
8282 # Inform the user
83 - $this->getOutput()->setPageTitleMsg( 'markedaspatrolled' );
 83+ $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrolled' ) );
8484 $this->getOutput()->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
8585 $this->getOutput()->returnToMain( null, $return );
8686 }
Index: trunk/phase3/includes/actions/RollbackAction.php
@@ -54,7 +54,7 @@
5555 }
5656
5757 if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) {
58 - $this->getOutput()->setPageTitleMsg( 'rollbackfailed' );
 58+ $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) );
5959 $errArray = $result[0];
6060 $errMsg = array_shift( $errArray );
6161 $this->getOutput()->addWikiMsgArray( $errMsg, $errArray );
@@ -95,7 +95,7 @@
9696 $current = $details['current'];
9797 $target = $details['target'];
9898 $newId = $details['newid'];
99 - $this->getOutput()->setPageTitleMsg( 'actioncomplete' );
 99+ $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
100100 $this->getOutput()->setRobotPolicy( 'noindex,nofollow' );
101101
102102 if ( $current->getUserText() === '' ) {
Index: trunk/phase3/includes/Message.php
@@ -205,6 +205,19 @@
206206 }
207207
208208 /**
 209+ * Set the language and the title from a context object
 210+ *
 211+ * @param $context IContextSource
 212+ * @return Message: $this
 213+ */
 214+ public function setContext( IContextSource $context ) {
 215+ $this->inLanguage( $context->getLang() );
 216+ $this->title( $context->getTitle() );
 217+
 218+ return $this;
 219+ }
 220+
 221+ /**
209222 * Request the message in any language that is supported.
210223 * As a side effect interface message status is unconditionally
211224 * turned off.
Index: trunk/phase3/includes/FileDeleteForm.php
@@ -78,7 +78,7 @@
7979 $wgOut->addHTML( '</span>' );
8080 }
8181 if( $status->ok ) {
82 - $wgOut->setPageTitleMsg( 'actioncomplete' );
 82+ $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
8383 $wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
8484 // Return to the main page if we just deleted all versions of the
8585 // file, otherwise go back to the description page
@@ -271,7 +271,7 @@
272272 */
273273 private function setHeaders() {
274274 global $wgOut;
275 - $wgOut->setPageTitleMsg( 'filedelete', $this->title->getText() );
 275+ $wgOut->setPageTitle( wfMessage( 'filedelete', $this->title->getText() ) );
276276 $wgOut->setRobotPolicy( 'noindex,nofollow' );
277277 $wgOut->setSubtitle( wfMsg(
278278 'filedelete-backlink',
Index: trunk/phase3/includes/specials/SpecialAllpages.php
@@ -73,10 +73,10 @@
7474
7575 $namespaces = $wgContLang->getNamespaces();
7676
77 - $out->setPagetitle(
 77+ $out->setPageTitle(
7878 ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ?
79 - wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
80 - wfMsg( 'allarticles' )
 79+ $this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
 80+ $this->msg( 'allarticles' )
8181 );
8282 $out->addModuleStyles( 'mediawiki.special' );
8383
Index: trunk/phase3/includes/specials/SpecialUnblock.php
@@ -53,7 +53,7 @@
5454 $this->outputHeader();
5555
5656 $out = $this->getOutput();
57 - $out->setPageTitleMsg( 'unblockip' );
 57+ $out->setPageTitle( $this->msg( 'unblockip' ) );
5858 $out->addModules( 'mediawiki.special' );
5959
6060 $form = new HTMLForm( $this->getFields(), $this->getContext() );
Index: trunk/phase3/includes/specials/SpecialRecentchangeslinked.php
@@ -75,7 +75,7 @@
7676 return false;
7777 }
7878
79 - $this->getOutput()->setPageTitleMsg( 'recentchangeslinked-title', $title->getPrefixedText() );
 79+ $this->getOutput()->setPageTitle( $this->msg( 'recentchangeslinked-title', $title->getPrefixedText() ) );
8080
8181 /*
8282 * Ordinary links are in the pagelinks table, while transclusions are
Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -649,9 +649,9 @@
650650 $out = $this->getOutput();
651651
652652 if ( $this->mAllowed ) {
653 - $out->setPageTitleMsg( 'undeletepage' );
 653+ $out->setPageTitle( $this->msg( 'undeletepage' ) );
654654 } else {
655 - $out->setPageTitleMsg( 'viewdeletedpage' );
 655+ $out->setPageTitle( $this->msg( 'viewdeletedpage' ) );
656656 }
657657
658658 if( $par != '' ) {
@@ -802,7 +802,7 @@
803803 }
804804 }
805805
806 - $out->setPageTitleMsg( 'undeletepage' );
 806+ $out->setPageTitle( $this->msg( 'undeletepage' ) );
807807
808808 if( $this->mDiff ) {
809809 $previousRev = $archive->getPreviousRevision( $timestamp );
@@ -1016,9 +1016,9 @@
10171017 $out = $this->getOutput();
10181018 if( $this->mAllowed ) {
10191019 $out->addModules( 'mediawiki.special.undelete' );
1020 - $out->setPageTitleMsg( 'undeletepage' );
 1020+ $out->setPageTitle( $this->msg( 'undeletepage' ) );
10211021 } else {
1022 - $out->setPageTitleMsg( 'viewdeletedpage' );
 1022+ $out->setPageTitle( $this->msg( 'viewdeletedpage' ) );
10231023 }
10241024 $out->wrapWikiMsg(
10251025 "<div class='mw-undelete-pagetitle'>\n$1\n</div>\n",
Index: trunk/phase3/includes/specials/SpecialBlockList.php
@@ -43,7 +43,7 @@
4444 $this->setHeaders();
4545 $this->outputHeader();
4646 $out = $this->getOutput();
47 - $out->setPageTitleMsg( 'ipblocklist' );
 47+ $out->setPageTitle( $this->msg( 'ipblocklist' ) );
4848 $out->addModuleStyles( 'mediawiki.special' );
4949
5050 $request = $this->getRequest();
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -189,7 +189,7 @@
190190 $u->addNewUserLogEntry( true, $this->mReason );
191191
192192 $out = $this->getOutput();
193 - $out->setPageTitleMsg( 'accmailtitle' );
 193+ $out->setPageTitle( $this->msg( 'accmailtitle' ) );
194194
195195 if( !$result->isGood() ) {
196196 $this->mainLoginForm( $this->msg( 'mailerror', $result->getWikiText() )->text() );
@@ -251,7 +251,7 @@
252252 }
253253 } else {
254254 # Confirm that the account was created
255 - $out->setPageTitleMsg( 'accountcreated' );
 255+ $out->setPageTitle( $this->msg( 'accountcreated' ) );
256256 $out->addWikiMsg( 'accountcreatedtext', $u->getName() );
257257 $out->returnToMain( false, $this->getTitle() );
258258 wfRunHooks( 'AddNewAccount', array( $u, false ) );
@@ -883,7 +883,7 @@
884884 */
885885 private function displaySuccessfulLogin( $msgname, $injected_html ) {
886886 $out = $this->getOutput();
887 - $out->setPageTitleMsg( 'loginsuccesstitle' );
 887+ $out->setPageTitle( $this->msg( 'loginsuccesstitle' ) );
888888 if( $msgname ){
889889 $out->addWikiMsg( $msgname, wfEscapeWikiText( $this->getUser()->getName() ) );
890890 }
@@ -914,7 +914,7 @@
915915 # out.
916916
917917 $out = $this->getOutput();
918 - $out->setPageTitleMsg( 'cantcreateaccounttitle' );
 918+ $out->setPageTitle( $this->msg( 'cantcreateaccounttitle' ) );
919919
920920 $block_reason = $block->mReason;
921921 if ( strval( $block_reason ) === '' ) {
@@ -1077,9 +1077,9 @@
10781078 // Changes the title depending on permissions for creating account
10791079 $out = $this->getOutput();
10801080 if ( $user->isAllowed( 'createaccount' ) ) {
1081 - $out->setPageTitleMsg( 'userlogin' );
 1081+ $out->setPageTitle( $this->msg( 'userlogin' ) );
10821082 } else {
1083 - $out->setPageTitleMsg( 'userloginnocreate' );
 1083+ $out->setPageTitle( $this->msg( 'userloginnocreate' ) );
10841084 }
10851085
10861086 $out->disallowUserJs(); // just in case...
Index: trunk/phase3/includes/specials/SpecialWhatlinkshere.php
@@ -86,7 +86,7 @@
8787
8888 $this->selfTitle = $this->getTitle( $this->target->getPrefixedDBkey() );
8989
90 - $out->setPageTitleMsg( 'whatlinkshere-title', $this->target->getPrefixedText() );
 90+ $out->setPageTitle( $this->msg( 'whatlinkshere-title', $this->target->getPrefixedText() ) );
9191 $out->setSubtitle( wfMsg( 'whatlinkshere-backlink', Linker::link( $this->target, $this->target->getPrefixedText(), array(), array( 'redirect' => 'no' ) ) ) );
9292
9393 $this->showIndirectLinks( 0, $this->target, $opts->getValue( 'limit' ),
Index: trunk/phase3/includes/specials/SpecialEditWatchlist.php
@@ -34,7 +34,7 @@
3535
3636 # Anons don't get a watchlist
3737 if( $this->getUser()->isAnon() ) {
38 - $out->setPageTitleMsg( 'watchnologin' );
 38+ $out->setPageTitle( $this->msg( 'watchnologin' ) );
3939 $llink = Linker::linkKnown(
4040 SpecialPage::getTitleFor( 'Userlogin' ),
4141 wfMsgHtml( 'loginreqlink' ),
@@ -75,7 +75,7 @@
7676 // Pass on to the raw editor, from which it's very easy to clear.
7777
7878 case self::EDIT_RAW:
79 - $out->setPageTitleMsg( 'watchlistedit-raw-title' );
 79+ $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
8080 $form = $this->getRawForm();
8181 if( $form->show() ){
8282 $out->addHTML( $this->successMessage );
@@ -85,7 +85,7 @@
8686
8787 case self::EDIT_NORMAL:
8888 default:
89 - $out->setPageTitleMsg( 'watchlistedit-normal-title' );
 89+ $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
9090 $form = $this->getNormalForm();
9191 if( $form->show() ){
9292 $out->addHTML( $this->successMessage );
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -538,7 +538,7 @@
539539 * Report that the submit operation succeeded
540540 */
541541 protected function success() {
542 - $this->getOutput()->setPagetitle( wfMsg( 'actioncomplete' ) );
 542+ $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
543543 $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeInfo['success'] );
544544 $this->list->reloadFromMaster();
545545 $this->showForm();
@@ -548,7 +548,7 @@
549549 * Report that the submit operation failed
550550 */
551551 protected function failure( $status ) {
552 - $this->getOutput()->setPagetitle( wfMsg( 'actionfailed' ) );
 552+ $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) );
553553 $this->getOutput()->addWikiText( $status->getWikiText( $this->typeInfo['failure'] ) );
554554 $this->showForm();
555555 }
Index: trunk/phase3/includes/specials/SpecialPrefixindex.php
@@ -54,10 +54,10 @@
5555 $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
5656
5757 $namespaces = $wgContLang->getNamespaces();
58 - $out->setPagetitle(
 58+ $out->setPageTitle(
5959 ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
60 - ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
61 - : wfMsg( 'prefixindex' )
 60+ ? $this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
 61+ : $this->msg( 'prefixindex' )
6262 );
6363
6464 $showme = '';
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -84,14 +84,14 @@
8585 if( $this->opts['contribs'] != 'newbie' ) {
8686 $target = $nt->getText();
8787 $out->setSubtitle( $this->contributionsSub( $nt, $id ) );
88 - $out->setHTMLTitleMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) );
 88+ $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ), $target ) ) );
8989 $userObj = User::newFromName( $target, false );
9090 if ( is_object( $userObj ) ) {
9191 $this->getSkin()->setRelevantUser( $userObj );
9292 }
9393 } else {
9494 $out->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
95 - $out->setHTMLTitleMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) );
 95+ $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
9696 }
9797
9898 if( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php
@@ -269,7 +269,7 @@
270270
271271 $request = $this->getRequest();
272272 $out = $this->getOutput();
273 - $out->setPageTitleMsg( 'deletedcontributions-title' );
 273+ $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
274274
275275 $options = array();
276276
Index: trunk/phase3/includes/specials/SpecialBlock.php
@@ -91,7 +91,7 @@
9292 $this->outputHeader();
9393
9494 $out = $this->getOutput();
95 - $out->setPageTitleMsg( 'blockip-title' );
 95+ $out->setPageTitle( $this->msg( 'blockip-title' ) );
9696 $out->addModules( array( 'mediawiki.special', 'mediawiki.special.block' ) );
9797
9898 $fields = $this->getFormFields();
@@ -111,7 +111,7 @@
112112 $this->doPostText( $form );
113113
114114 if( $form->show() ){
115 - $out->setPageTitleMsg( 'blockipsuccesssub' );
 115+ $out->setPageTitle( $this->msg( 'blockipsuccesssub' ) );
116116 $out->addWikiMsg( 'blockipsuccesstext', $this->target );
117117 }
118118 }
Index: trunk/phase3/includes/specials/SpecialTags.php
@@ -40,7 +40,7 @@
4141 $this->outputHeader();
4242
4343 $out = $this->getOutput();
44 - $out->setPageTitleMsg( 'tags-title' );
 44+ $out->setPageTitle( $this->msg( 'tags-title' ) );
4545 $out->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1\n</div>", 'tags-intro' );
4646
4747 // Write the headers
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -55,7 +55,7 @@
5656
5757 # Anons don't get a watchlist
5858 if( $user->isAnon() ) {
59 - $output->setPageTitleMsg( 'watchnologin' );
 59+ $output->setPageTitle( $this->msg( 'watchnologin' ) );
6060 $llink = Linker::linkKnown(
6161 SpecialPage::getTitleFor( 'Userlogin' ),
6262 wfMsgHtml( 'loginreqlink' ),
Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -112,7 +112,7 @@
113113 $oldTitleLink = Linker::link( $this->oldTitle );
114114
115115 $out = $this->getOutput();
116 - $out->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) );
 116+ $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
117117 $out->addModules( 'mediawiki.special.movePage' );
118118
119119 $newTitle = $this->newTitle;
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -435,8 +435,8 @@
436436 $this->searchAdvanced = ($this->profile === 'advanced');
437437 $out = $this->getOutput();
438438 if( strval( $term ) !== '' ) {
439 - $out->setPageTitleMsg( 'searchresults' );
440 - $out->setHTMLTitleMsg( 'pagetitle', wfMsg( 'searchresults-title', $term ) );
 439+ $out->setPageTitle( $this->msg( 'searchresults' ) );
 440+ $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'searchresults-title', $term )->plain() ) );
441441 }
442442 // add javascript specific to special:search
443443 $out->addModules( 'mediawiki.special.search' );
Index: trunk/phase3/includes/specials/SpecialEmailuser.php
@@ -135,11 +135,11 @@
136136 return false;
137137 }
138138
139 - $out->setPageTitleMsg( 'emailpage' );
 139+ $out->setPageTitle( $this->msg( 'emailpage' ) );
140140 $result = $form->show();
141141
142142 if( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
143 - $out->setPageTitleMsg( 'emailsent' );
 143+ $out->setPageTitle( $this->msg( 'emailsent' ) );
144144 $out->addWikiMsg( 'emailsenttext' );
145145 $out->returnToMain( false, $this->mTargetObj->getUserPage() );
146146 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100621Added OutputPage::setPageTitleMsg() and OutputPage::setHTMLTitleMsg() as modi...ialex17:24, 24 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   06:44, 28 October 2011

Did your commit message truncate?

#Comment by IAlex (talk | contribs)   07:53, 28 October 2011

Yes, the end should have been "but at least I won't be confused about which objects have a context or not".

#Comment by Nikerabbit (talk | contribs)   06:47, 28 October 2011

Are those messages are still outputted unescaped? This could be nice spot to make them escaped without breaking extensions that rely on it.

#Comment by IAlex (talk | contribs)   07:58, 28 October 2011

The HTML title is escaped in OutputPage::headElement() and OutputPage::setPageTitle() does its own escaping as it allows only whitelisted tags (more or the same as in wikitext); so I'm considering these two methods safe.

#Comment by Nikerabbit (talk | contribs)   07:59, 28 October 2011

It must have been the member variable HTMLtitle that mislead me.

Status & tagging log