r87589 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87588‎ | r87589 | r87590 >
Date:22:09, 6 May 2011
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
Kill off the long deprecated $wgInputEncoding and $wgOutputEncoding globals
Modified paths:
  • /trunk/extensions/DumpHTML/dumpHTML.inc (modified) (history)
  • /trunk/extensions/Math/Math.body.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NMSendMailAsync.php (modified) (history)
  • /trunk/extensions/gis/maparea.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Exception.php (modified) (history)
  • /trunk/phase3/includes/ExternalEdit.php (modified) (history)
  • /trunk/phase3/includes/Html.php (modified) (history)
  • /trunk/phase3/includes/Metadata.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/RawPage.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/UserMailer.php (modified) (history)
  • /trunk/phase3/includes/cache/HTMLFileCache.php (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/tools/code-utils/check-vars.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RawPage.php
@@ -24,7 +24,7 @@
2525 var $mContentType, $mExpandTemplates;
2626
2727 function __construct( Article $article, $request = false ) {
28 - global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
 28+ global $wgRequest, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
2929
3030 $allowedCTypes = array( 'text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit' );
3131 $this->mArticle = $article;
@@ -89,7 +89,7 @@
9090 } else {
9191 $this->mGen = false;
9292 }
93 - $this->mCharset = $wgInputEncoding;
 93+ $this->mCharset = 'UTF-8';
9494
9595 # Force caching for CSS and JS raw content, default: 5 minutes
9696 if( is_null( $smaxage ) && ( $ctype == 'text/css' || $ctype == $wgJsMimeType ) ) {
Index: trunk/phase3/includes/Exception.php
@@ -221,11 +221,11 @@
222222 * $wgOut to output the exception.
223223 */
224224 function htmlHeader() {
225 - global $wgLogo, $wgOutputEncoding, $wgLang;
 225+ global $wgLogo, $wgLang;
226226
227227 if ( !headers_sent() ) {
228228 header( 'HTTP/1.0 500 Internal Server Error' );
229 - header( 'Content-type: text/html; charset=' . $wgOutputEncoding );
 229+ header( 'Content-type: text/html; charset=UTF-8' );
230230 /* Don't cache error pages! They cause no end of trouble... */
231231 header( 'Cache-control: none' );
232232 header( 'Pragma: nocache' );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1870,11 +1870,6 @@
18711871 'simple',
18721872 );
18731873
1874 -/** @deprecated Since MediaWiki 1.5, this must always be set to UTF-8. */
1875 -$wgInputEncoding = 'UTF-8';
1876 -/** @deprecated Since MediaWiki 1.5, this must always be set to UTF-8. */
1877 -$wgOutputEncoding = 'UTF-8';
1878 -
18791874 /**
18801875 * Character set for use in the article edit box. Language-specific encodings
18811876 * may be defined.
Index: trunk/phase3/includes/Revision.php
@@ -760,8 +760,8 @@
761761 # Upconvert on demand.
762762 # ("utf8" checked for compatibility with some broken
763763 # conversion scripts 2008-12-30)
764 - global $wgInputEncoding, $wgContLang;
765 - $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding, $text );
 764+ global $wgContLang;
 765+ $text = $wgContLang->iconv( $wgLegacyEncoding, 'UTF-8', $text );
766766 }
767767 }
768768 wfProfileOut( __METHOD__ );
Index: trunk/phase3/includes/Metadata.php
@@ -212,11 +212,9 @@
213213 * begin of the page
214214 */
215215 protected function prologue() {
216 - global $wgOutputEncoding;
217 -
218216 $url = htmlspecialchars( $this->reallyFullUrl() );
219217 print <<<PROLOGUE
220 -<?xml version="1.0" encoding="{$wgOutputEncoding}" ?>
 218+<?xml version="1.0" encoding="UTF-8" ?>
221219 <!DOCTYPE rdf:RDF PUBLIC "-//DUBLIN CORE//DCMES DTD 2002/07/31//EN" "http://dublincore.org/documents/2002/07/31/dcmes-xml/dcmes-xml-dtd.dtd">
222220 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
223221 xmlns:dc="http://purl.org/dc/elements/1.1/">
@@ -269,9 +267,8 @@
270268 }
271269
272270 protected function prologue() {
273 - global $wgOutputEncoding;
274271 echo <<<PROLOGUE
275 -<?xml version='1.0' encoding="{$wgOutputEncoding}" ?>
 272+<?xml version='1.0' encoding="UTF-8" ?>
276273 <rdf:RDF xmlns:cc="http://web.resource.org/cc/"
277274 xmlns:dc="http://purl.org/dc/elements/1.1/"
278275 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
Index: trunk/phase3/includes/ExternalEdit.php
@@ -21,10 +21,9 @@
2222 class ExternalEdit {
2323
2424 function __construct( $article, $mode ) {
25 - global $wgInputEncoding;
2625 $this->mArticle =& $article;
2726 $this->mTitle =& $article->mTitle;
28 - $this->mCharset = $wgInputEncoding;
 27+ $this->mCharset = 'UTF-8';
2928 $this->mMode = $mode;
3029 }
3130
Index: trunk/phase3/includes/Html.php
@@ -609,9 +609,9 @@
610610 public static function htmlHeader( $attribs = array() ) {
611611 $ret = '';
612612
613 - global $wgMimeType, $wgOutputEncoding;
 613+ global $wgMimeType;
614614 if ( self::isXmlMimeType( $wgMimeType ) ) {
615 - $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
 615+ $ret .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n";
616616 }
617617
618618 global $wgHtml5, $wgHtml5Version, $wgDocType, $wgDTD;
Index: trunk/phase3/includes/cache/HTMLFileCache.php
@@ -155,14 +155,14 @@
156156
157157 /* Working directory to/from output */
158158 public function loadFromFileCache() {
159 - global $wgOut, $wgMimeType, $wgOutputEncoding, $wgLanguageCode;
 159+ global $wgOut, $wgMimeType, $wgLanguageCode;
160160 wfDebug( __METHOD__ . "()\n");
161161 $filename = $this->fileCacheName();
162162 // Raw pages should handle cache control on their own,
163163 // even when using file cache. This reduces hits from clients.
164164 if( $this->mType !== 'raw' ) {
165165 $wgOut->sendCacheControl();
166 - header( "Content-Type: $wgMimeType; charset={$wgOutputEncoding}" );
 166+ header( "Content-Type: $wgMimeType; charset=UTF-8" );
167167 header( "Content-Language: $wgLanguageCode" );
168168 }
169169
Index: trunk/phase3/includes/UserMailer.php
@@ -110,7 +110,7 @@
111111 * @return Status object
112112 */
113113 public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = null ) {
114 - global $wgSMTP, $wgOutputEncoding, $wgEnotifImpersonal;
 114+ global $wgSMTP, $wgEnotifImpersonal;
115115 global $wgEnotifMaxRecips, $wgAdditionalMailParams;
116116
117117 if ( is_array( $to ) ) {
@@ -164,7 +164,7 @@
165165 $headers['Date'] = date( 'r' );
166166 $headers['MIME-Version'] = '1.0';
167167 $headers['Content-type'] = ( is_null( $contentType ) ?
168 - 'text/plain; charset=' . $wgOutputEncoding : $contentType );
 168+ 'text/plain; charset=UTF-8' : $contentType );
169169 $headers['Content-transfer-encoding'] = '8bit';
170170 $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME
171171 $headers['X-Mailer'] = 'MediaWiki mailer';
@@ -203,7 +203,7 @@
204204 $endl = "\n";
205205 }
206206 $ctype = ( is_null( $contentType ) ?
207 - 'text/plain; charset=' . $wgOutputEncoding : $contentType );
 207+ 'text/plain; charset=UTF-8' : $contentType );
208208 $headers =
209209 "MIME-Version: 1.0$endl" .
210210 "Content-type: $ctype$endl" .
@@ -277,8 +277,7 @@
278278 public static function quotedPrintable( $string, $charset = '' ) {
279279 # Probably incomplete; see RFC 2045
280280 if( empty( $charset ) ) {
281 - global $wgInputEncoding;
282 - $charset = $wgInputEncoding;
 281+ $charset = 'UTF-8';
283282 }
284283 $charset = strtoupper( $charset );
285284 $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ?
Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -130,9 +130,9 @@
131131 # we'll use the application/x-external-editor interface to call
132132 # an external diff tool like kompare, kdiff3, etc.
133133 if ( $wgUseExternalEditor && $wgUser->getOption( 'externaldiff' ) ) {
134 - global $wgInputEncoding, $wgServer, $wgScript, $wgLang;
 134+ global $wgServer, $wgScript, $wgLang;
135135 $wgOut->disable();
136 - header ( "Content-type: application/x-external-editor; charset=" . $wgInputEncoding );
 136+ header ( "Content-type: application/x-external-editor; charset=UTF-8" );
137137 $url1 = $this->mTitle->getFullURL( array(
138138 'action' => 'raw',
139139 'oldid' => $this->mOldid
Index: trunk/phase3/includes/OutputPage.php
@@ -1838,7 +1838,6 @@
18391839 * the object, let's actually output it:
18401840 */
18411841 public function output() {
1842 - global $wgOutputEncoding;
18431842 global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
18441843
18451844 if( $this->mDoNothing ) {
@@ -1882,7 +1881,7 @@
18831882 # Buffer output; final headers may depend on later processing
18841883 ob_start();
18851884
1886 - $response->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
 1885+ $response->header( "Content-type: $wgMimeType; charset=UTF-8" );
18871886 $response->header( 'Content-language: ' . $wgLanguageCode );
18881887
18891888 // Prevent framing, if requested
@@ -1919,11 +1918,11 @@
19201919 * @param $ins String: the string to output
19211920 */
19221921 public function out( $ins ) {
1923 - global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
1924 - if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
 1922+ global $wgContLang;
 1923+ if ( 0 == strcmp( 'UTF-8', 'UTF-8' ) ) {
19251924 $outs = $ins;
19261925 } else {
1927 - $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
 1926+ $outs = $wgContLang->iconv( 'UTF-8', 'UTF-8', $ins );
19281927 if ( false === $outs ) {
19291928 $outs = $ins;
19301929 }
@@ -2684,7 +2683,7 @@
26852684 */
26862685 public function getHeadLinks( Skin $sk, $addContentType = false ) {
26872686 global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
2688 - $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgOutputEncoding,
 2687+ $wgSitename, $wgVersion, $wgHtml5, $wgMimeType,
26892688 $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
26902689 $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf,
26912690 $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang,
@@ -2696,11 +2695,11 @@
26972696 if ( $wgHtml5 ) {
26982697 # More succinct than <meta http-equiv=Content-Type>, has the
26992698 # same effect
2700 - $tags[] = Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) );
 2699+ $tags[] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) );
27012700 } else {
27022701 $tags[] = Html::element( 'meta', array(
27032702 'http-equiv' => 'Content-Type',
2704 - 'content' => "$wgMimeType; charset=$wgOutputEncoding"
 2703+ 'content' => "$wgMimeType; charset=UTF-8"
27052704 ) );
27062705 $tags[] = Html::element( 'meta', array( // bug 15835
27072706 'http-equiv' => 'Content-Style-Type',
Index: trunk/phase3/includes/SkinTemplate.php
@@ -134,7 +134,7 @@
135135 function outputPage( OutputPage $out ) {
136136 global $wgUser, $wgLang, $wgContLang;
137137 global $wgScript, $wgStylePath, $wgLanguageCode;
138 - global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
 138+ global $wgMimeType, $wgJsMimeType, $wgRequest;
139139 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
140140 global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
141141 global $wgMaxCredits, $wgShowCreditsIfMax;
@@ -274,7 +274,7 @@
275275
276276 $tpl->setRef( 'mimetype', $wgMimeType );
277277 $tpl->setRef( 'jsmimetype', $wgJsMimeType );
278 - $tpl->setRef( 'charset', $wgOutputEncoding );
 278+ $tpl->setRef( 'charset', 'UTF-8' );
279279 $tpl->setRef( 'wgScript', $wgScript );
280280 $tpl->setRef( 'skinname', $this->skinname );
281281 $tpl->set( 'skinclass', get_class( $this ) );
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -193,14 +193,13 @@
194194 wfProfileOut( __METHOD__ );
195195 return;
196196 }
197 - global $wgInputEncoding;
198197 $wgOut->addHTML(
199198 Xml::openElement( 'fieldset' ) .
200199 Xml::element( 'legend', null, wfMsg( 'search-external' ) ) .
201200 Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), wfMsg( 'searchdisabled' ) ) .
202201 wfMsg( 'googlesearch',
203202 htmlspecialchars( $term ),
204 - htmlspecialchars( $wgInputEncoding ),
 203+ htmlspecialchars( 'UTF-8' ),
205204 htmlspecialchars( wfMsg( 'searchbutton' ) )
206205 ) .
207206 Xml::closeElement( 'fieldset' )
Index: trunk/phase3/languages/Language.php
@@ -19,14 +19,6 @@
2020 global $wgLanguageNames;
2121 require_once( dirname( __FILE__ ) . '/Names.php' );
2222
23 -global $wgInputEncoding, $wgOutputEncoding;
24 -
25 -/**
26 - * These are always UTF-8, they exist only for backwards compatibility
27 - */
28 -$wgInputEncoding = 'UTF-8';
29 -$wgOutputEncoding = 'UTF-8';
30 -
3123 if ( function_exists( 'mb_strtoupper' ) ) {
3224 mb_internal_encoding( 'UTF-8' );
3325 }
Index: trunk/extensions/DumpHTML/dumpHTML.inc
@@ -844,8 +844,8 @@
845845
846846 /** Returns image paths used in an XHTML document */
847847 function findImages( $text ) {
848 - global $wgOutputEncoding, $wgDumpImages;
849 - $parser = xml_parser_create( $wgOutputEncoding );
 848+ global $wgDumpImages;
 849+ $parser = xml_parser_create( 'UTF-8' );
850850 xml_set_element_handler( $parser, 'wfDumpStartTagHandler', 'wfDumpEndTagHandler' );
851851
852852 $wgDumpImages = array();
Index: trunk/extensions/Math/Math.body.php
@@ -37,7 +37,7 @@
3838 }
3939
4040 function render() {
41 - global $wgTmpDirectory, $wgInputEncoding;
 41+ global $wgTmpDirectory;
4242 global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor;
4343
4444 if( $this->mode == MW_MATH_SOURCE ) {
@@ -68,7 +68,7 @@
6969 escapeshellarg( $wgTmpDirectory ).' '.
7070 escapeshellarg( $wgTmpDirectory ).' '.
7171 escapeshellarg( $this->tex ).' '.
72 - escapeshellarg( $wgInputEncoding ).' '.
 72+ escapeshellarg( 'UTF-8' ).' '.
7373 escapeshellarg( $wgTexvcBackgroundColor );
7474
7575 if ( wfIsWindows() ) {
Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NMSendMailAsync.php
@@ -55,14 +55,13 @@
5656 if ( ( $user_info->user_email != '' ) && getUserNMOption( $user_info->user_options ) ) {
5757 $name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );
5858
59 - global $wgOutputEncoding;
6059 UserMailer::send(
6160 new MailAddress( $user_info->user_email, $name ),
6261 new MailAddress( $wgEmergencyContact, 'Admin' ),
6362 wfMsg( 'smw_nm_hint_mail_title', $msg['title'], $wgSitename ),
6463 wfMsg( 'smw_nm_hint_mail_body_html', $name, $msg['notify'] ),
6564 new MailAddress( $wgEmergencyContact, 'Admin' ),
66 - 'text/html; charset=' . $wgOutputEncoding
 65+ 'text/html; charset=UTF-8'
6766 );
6867 }
6968 }
Index: trunk/extensions/gis/maparea.php
@@ -56,9 +56,8 @@
5757
5858 $wgOut->addWikiText( $this->make_output() );
5959 } else {
60 - global $wgInputEncoding;
6160 $ContentType = 'text/x-wiki';
62 - header( "Content-type: ".$ContentType.'; charset='.$wgInputEncoding);
 61+ header( "Content-type: ".$ContentType.'; charset=UTF-8');
6362
6463 echo( $this->make_output() );
6564
Index: trunk/tools/code-utils/check-vars.php
@@ -241,7 +241,7 @@
242242 // Predefine constant that might not be defined by this file source code
243243 $this->mConstants = array( 'PARSEKIT_SIMPLE', 'UNORM_NFC', # Extensions
244244 /* Defined in Title.php and GlobalFunctions.php */
245 - 'GAID_FOR_UPDATE', 'TC_MYSQL', 'TS_UNIX', 'TS_MW', 'TS_DB', 'TS_RFC2822',
 245+ 'TC_MYSQL', 'TS_UNIX', 'TS_MW', 'TS_DB', 'TS_RFC2822',
246246 'TS_ISO_8601', 'TS_EXIF', 'TS_ORACLE', 'TS_POSTGRES', 'TS_DB2',
247247 'TS_ISO_8601_BASIC',
248248 /* PHP extensions */

Follow-up revisions

RevisionCommit summaryAuthorDate
r87591Fix fail attempt at passing string by reference in r87589reedy22:17, 6 May 2011
r87604List all removed globals in my recent commits in RELEASE-NOTESreedy23:39, 6 May 2011
r88110Follow-up r87589: let's simplify this a bit :Pialex17:02, 14 May 2011
r88158In tests, remove references to wgInputEncoding and wgOutputEncoding...hashar12:09, 15 May 2011

Comments

#Comment by Raymond (talk | contribs)   22:15, 6 May 2011

PHP Fatal error: Cannot pass parameter 2 by reference in /www/w/includes/SkinTemplate.php on line 277

#Comment by Aaron Schulz (talk | contribs)   00:46, 7 May 2011

Good riddance.

Status & tagging log