From 15df9a9d5cd3c217ed90c99e4c094e3c985468f0 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 6 May 2011 22:09:47 +0000 Subject: [PATCH] Kill off the long deprecated $wgInputEncoding and $wgOutputEncoding globals --- includes/DefaultSettings.php | 5 ----- includes/Exception.php | 4 ++-- includes/ExternalEdit.php | 3 +-- includes/Html.php | 4 ++-- includes/Metadata.php | 7 ++----- includes/OutputPage.php | 15 +++++++-------- includes/RawPage.php | 4 ++-- includes/Revision.php | 4 ++-- includes/SkinTemplate.php | 4 ++-- includes/UserMailer.php | 9 ++++----- includes/cache/HTMLFileCache.php | 4 ++-- includes/diff/DifferenceEngine.php | 4 ++-- includes/specials/SpecialSearch.php | 3 +-- languages/Language.php | 8 -------- 14 files changed, 29 insertions(+), 49 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index b3c2049806..c06586d8de 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1870,11 +1870,6 @@ $wgDummyLanguageCodes = array( 'simple', ); -/** @deprecated Since MediaWiki 1.5, this must always be set to UTF-8. */ -$wgInputEncoding = 'UTF-8'; -/** @deprecated Since MediaWiki 1.5, this must always be set to UTF-8. */ -$wgOutputEncoding = 'UTF-8'; - /** * Character set for use in the article edit box. Language-specific encodings * may be defined. diff --git a/includes/Exception.php b/includes/Exception.php index 67ad329088..1db0b029b4 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -221,11 +221,11 @@ class MWException extends Exception { * $wgOut to output the exception. */ function htmlHeader() { - global $wgLogo, $wgOutputEncoding, $wgLang; + global $wgLogo, $wgLang; if ( !headers_sent() ) { header( 'HTTP/1.0 500 Internal Server Error' ); - header( 'Content-type: text/html; charset=' . $wgOutputEncoding ); + header( 'Content-type: text/html; charset=UTF-8' ); /* Don't cache error pages! They cause no end of trouble... */ header( 'Cache-control: none' ); header( 'Pragma: nocache' ); diff --git a/includes/ExternalEdit.php b/includes/ExternalEdit.php index 7109c1ac93..094ae8fdfc 100644 --- a/includes/ExternalEdit.php +++ b/includes/ExternalEdit.php @@ -21,10 +21,9 @@ class ExternalEdit { function __construct( $article, $mode ) { - global $wgInputEncoding; $this->mArticle =& $article; $this->mTitle =& $article->mTitle; - $this->mCharset = $wgInputEncoding; + $this->mCharset = 'UTF-8'; $this->mMode = $mode; } diff --git a/includes/Html.php b/includes/Html.php index ea335334c3..43419e7714 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -609,9 +609,9 @@ class Html { public static function htmlHeader( $attribs = array() ) { $ret = ''; - global $wgMimeType, $wgOutputEncoding; + global $wgMimeType; if ( self::isXmlMimeType( $wgMimeType ) ) { - $ret .= "\n"; + $ret .= "\n"; } global $wgHtml5, $wgHtml5Version, $wgDocType, $wgDTD; diff --git a/includes/Metadata.php b/includes/Metadata.php index 93ce4b27c0..5f9a13bb5a 100644 --- a/includes/Metadata.php +++ b/includes/Metadata.php @@ -212,11 +212,9 @@ class DublinCoreRdf extends RdfMetaData { * begin of the page */ protected function prologue() { - global $wgOutputEncoding; - $url = htmlspecialchars( $this->reallyFullUrl() ); print << + @@ -269,9 +267,8 @@ class CreativeCommonsRdf extends RdfMetaData { } protected function prologue() { - global $wgOutputEncoding; echo << + diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2f8d85bcd1..640b4a3f1a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1838,7 +1838,6 @@ class OutputPage { * the object, let's actually output it: */ public function output() { - global $wgOutputEncoding; global $wgLanguageCode, $wgDebugRedirects, $wgMimeType; if( $this->mDoNothing ) { @@ -1882,7 +1881,7 @@ class OutputPage { # Buffer output; final headers may depend on later processing ob_start(); - $response->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" ); + $response->header( "Content-type: $wgMimeType; charset=UTF-8" ); $response->header( 'Content-language: ' . $wgLanguageCode ); // Prevent framing, if requested @@ -1919,11 +1918,11 @@ class OutputPage { * @param $ins String: the string to output */ public function out( $ins ) { - global $wgInputEncoding, $wgOutputEncoding, $wgContLang; - if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) { + global $wgContLang; + if ( 0 == strcmp( 'UTF-8', 'UTF-8' ) ) { $outs = $ins; } else { - $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins ); + $outs = $wgContLang->iconv( 'UTF-8', 'UTF-8', $ins ); if ( false === $outs ) { $outs = $ins; } @@ -2684,7 +2683,7 @@ class OutputPage { */ public function getHeadLinks( Skin $sk, $addContentType = false ) { global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, - $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgOutputEncoding, + $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang, @@ -2696,11 +2695,11 @@ class OutputPage { if ( $wgHtml5 ) { # More succinct than , has the # same effect - $tags[] = Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ); + $tags[] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) ); } else { $tags[] = Html::element( 'meta', array( 'http-equiv' => 'Content-Type', - 'content' => "$wgMimeType; charset=$wgOutputEncoding" + 'content' => "$wgMimeType; charset=UTF-8" ) ); $tags[] = Html::element( 'meta', array( // bug 15835 'http-equiv' => 'Content-Style-Type', diff --git a/includes/RawPage.php b/includes/RawPage.php index 0608c222cf..c994cb74e9 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -24,7 +24,7 @@ class RawPage { var $mContentType, $mExpandTemplates; function __construct( Article $article, $request = false ) { - global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions; + global $wgRequest, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions; $allowedCTypes = array( 'text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit' ); $this->mArticle = $article; @@ -89,7 +89,7 @@ class RawPage { } else { $this->mGen = false; } - $this->mCharset = $wgInputEncoding; + $this->mCharset = 'UTF-8'; # Force caching for CSS and JS raw content, default: 5 minutes if( is_null( $smaxage ) && ( $ctype == 'text/css' || $ctype == $wgJsMimeType ) ) { diff --git a/includes/Revision.php b/includes/Revision.php index 5fff018e69..fde05431ca 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -760,8 +760,8 @@ class Revision { # Upconvert on demand. # ("utf8" checked for compatibility with some broken # conversion scripts 2008-12-30) - global $wgInputEncoding, $wgContLang; - $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding, $text ); + global $wgContLang; + $text = $wgContLang->iconv( $wgLegacyEncoding, 'UTF-8', $text ); } } wfProfileOut( __METHOD__ ); diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 9404c6b5c2..4b60b2bc72 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -134,7 +134,7 @@ class SkinTemplate extends Skin { function outputPage( OutputPage $out ) { global $wgUser, $wgLang, $wgContLang; global $wgScript, $wgStylePath, $wgLanguageCode; - global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; + global $wgMimeType, $wgJsMimeType, $wgRequest; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; @@ -274,7 +274,7 @@ class SkinTemplate extends Skin { $tpl->setRef( 'mimetype', $wgMimeType ); $tpl->setRef( 'jsmimetype', $wgJsMimeType ); - $tpl->setRef( 'charset', $wgOutputEncoding ); + $tpl->setRef( 'charset', 'UTF-8' ); $tpl->setRef( 'wgScript', $wgScript ); $tpl->setRef( 'skinname', $this->skinname ); $tpl->set( 'skinclass', get_class( $this ) ); diff --git a/includes/UserMailer.php b/includes/UserMailer.php index cca9c59858..a2e11d7504 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -110,7 +110,7 @@ class UserMailer { * @return Status object */ public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = null ) { - global $wgSMTP, $wgOutputEncoding, $wgEnotifImpersonal; + global $wgSMTP, $wgEnotifImpersonal; global $wgEnotifMaxRecips, $wgAdditionalMailParams; if ( is_array( $to ) ) { @@ -164,7 +164,7 @@ class UserMailer { $headers['Date'] = date( 'r' ); $headers['MIME-Version'] = '1.0'; $headers['Content-type'] = ( is_null( $contentType ) ? - 'text/plain; charset=' . $wgOutputEncoding : $contentType ); + 'text/plain; charset=UTF-8' : $contentType ); $headers['Content-transfer-encoding'] = '8bit'; $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME $headers['X-Mailer'] = 'MediaWiki mailer'; @@ -203,7 +203,7 @@ class UserMailer { $endl = "\n"; } $ctype = ( is_null( $contentType ) ? - 'text/plain; charset=' . $wgOutputEncoding : $contentType ); + 'text/plain; charset=UTF-8' : $contentType ); $headers = "MIME-Version: 1.0$endl" . "Content-type: $ctype$endl" . @@ -277,8 +277,7 @@ class UserMailer { public static function quotedPrintable( $string, $charset = '' ) { # Probably incomplete; see RFC 2045 if( empty( $charset ) ) { - global $wgInputEncoding; - $charset = $wgInputEncoding; + $charset = 'UTF-8'; } $charset = strtoupper( $charset ); $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ? diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php index 949ed36f5c..4b3ef2766c 100644 --- a/includes/cache/HTMLFileCache.php +++ b/includes/cache/HTMLFileCache.php @@ -155,14 +155,14 @@ class HTMLFileCache { /* Working directory to/from output */ public function loadFromFileCache() { - global $wgOut, $wgMimeType, $wgOutputEncoding, $wgLanguageCode; + global $wgOut, $wgMimeType, $wgLanguageCode; wfDebug( __METHOD__ . "()\n"); $filename = $this->fileCacheName(); // Raw pages should handle cache control on their own, // even when using file cache. This reduces hits from clients. if( $this->mType !== 'raw' ) { $wgOut->sendCacheControl(); - header( "Content-Type: $wgMimeType; charset={$wgOutputEncoding}" ); + header( "Content-Type: $wgMimeType; charset=UTF-8" ); header( "Content-Language: $wgLanguageCode" ); } diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index d2a08546c7..5ada4e7dbd 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -130,9 +130,9 @@ class DifferenceEngine { # we'll use the application/x-external-editor interface to call # an external diff tool like kompare, kdiff3, etc. if ( $wgUseExternalEditor && $wgUser->getOption( 'externaldiff' ) ) { - global $wgInputEncoding, $wgServer, $wgScript, $wgLang; + global $wgServer, $wgScript, $wgLang; $wgOut->disable(); - header ( "Content-type: application/x-external-editor; charset=" . $wgInputEncoding ); + header ( "Content-type: application/x-external-editor; charset=UTF-8" ); $url1 = $this->mTitle->getFullURL( array( 'action' => 'raw', 'oldid' => $this->mOldid diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 2deb67c2dd..917854288d 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -193,14 +193,13 @@ class SpecialSearch extends SpecialPage { wfProfileOut( __METHOD__ ); return; } - global $wgInputEncoding; $wgOut->addHTML( Xml::openElement( 'fieldset' ) . Xml::element( 'legend', null, wfMsg( 'search-external' ) ) . Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), wfMsg( 'searchdisabled' ) ) . wfMsg( 'googlesearch', htmlspecialchars( $term ), - htmlspecialchars( $wgInputEncoding ), + htmlspecialchars( 'UTF-8' ), htmlspecialchars( wfMsg( 'searchbutton' ) ) ) . Xml::closeElement( 'fieldset' ) diff --git a/languages/Language.php b/languages/Language.php index 4420b27a4a..8991ae2644 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -19,14 +19,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { global $wgLanguageNames; require_once( dirname( __FILE__ ) . '/Names.php' ); -global $wgInputEncoding, $wgOutputEncoding; - -/** - * These are always UTF-8, they exist only for backwards compatibility - */ -$wgInputEncoding = 'UTF-8'; -$wgOutputEncoding = 'UTF-8'; - if ( function_exists( 'mb_strtoupper' ) ) { mb_internal_encoding( 'UTF-8' ); } -- 2.20.1