Index: trunk/phase3/languages/Language.php |
— | — | @@ -174,20 +174,22 @@ |
175 | 175 | $class = 'Language'; |
176 | 176 | } else { |
177 | 177 | $class = 'Language' . str_replace( '-', '_', ucfirst( $code ) ); |
178 | | - // Preload base classes to work around APC/PHP5 bug |
179 | | - if ( file_exists( "$IP/languages/classes/$class.deps.php" ) ) { |
180 | | - include_once( "$IP/languages/classes/$class.deps.php" ); |
| 178 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 179 | + // Preload base classes to work around APC/PHP5 bug |
| 180 | + if ( file_exists( "$IP/languages/classes/$class.deps.php" ) ) { |
| 181 | + include_once( "$IP/languages/classes/$class.deps.php" ); |
| 182 | + } |
| 183 | + if ( file_exists( "$IP/languages/classes/$class.php" ) ) { |
| 184 | + include_once( "$IP/languages/classes/$class.php" ); |
| 185 | + } |
181 | 186 | } |
182 | | - if ( file_exists( "$IP/languages/classes/$class.php" ) ) { |
183 | | - include_once( "$IP/languages/classes/$class.php" ); |
184 | | - } |
185 | 187 | } |
186 | 188 | |
187 | 189 | if ( $recursionLevel > 5 ) { |
188 | 190 | throw new MWException( "Language fallback loop detected when creating class $class\n" ); |
189 | 191 | } |
190 | 192 | |
191 | | - if ( !class_exists( $class ) ) { |
| 193 | + if ( !MWInit::classExists( $class ) ) { |
192 | 194 | $fallback = Language::getFallbackFor( $code ); |
193 | 195 | ++$recursionLevel; |
194 | 196 | $lang = Language::newFromCode( $fallback ); |
— | — | @@ -540,8 +542,14 @@ |
541 | 543 | * If $customisedOnly is true, only returns codes with a messages file |
542 | 544 | */ |
543 | 545 | public static function getLanguageNames( $customisedOnly = false ) { |
544 | | - global $wgLanguageNames, $wgExtraLanguageNames; |
545 | | - $allNames = $wgExtraLanguageNames + $wgLanguageNames; |
| 546 | + global $wgExtraLanguageNames; |
| 547 | + static $coreLanguageNames; |
| 548 | + |
| 549 | + if ( $coreLanguageNames === null ) { |
| 550 | + include( MWInit::compiledPath( 'languages/Names.php' ) ); |
| 551 | + } |
| 552 | + |
| 553 | + $allNames = $wgExtraLanguageNames + $coreLanguageNames; |
546 | 554 | if ( !$customisedOnly ) { |
547 | 555 | return $allNames; |
548 | 556 | } |
Index: trunk/phase3/languages/Names.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @ingroup Language |
8 | 8 | */ |
9 | | -/* private */ $wgLanguageNames = array( |
| 9 | +/* private */ $coreLanguageNames = array( |
10 | 10 | 'aa' => 'Qafár af', # Afar |
11 | 11 | 'ab' => 'Аҧсуа', # Abkhaz, should possibly add ' бысжѡа' |
12 | 12 | 'ace' => 'Acèh', # Aceh |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -67,12 +67,12 @@ |
68 | 68 | public function __construct( $langobj, $maincode, $variants = array(), |
69 | 69 | $variantfallbacks = array(), $flags = array(), |
70 | 70 | $manualLevel = array() ) { |
71 | | - global $wgDisabledVariants, $wgLanguageNames; |
| 71 | + global $wgDisabledVariants; |
72 | 72 | $this->mLangObj = $langobj; |
73 | 73 | $this->mMainLanguageCode = $maincode; |
74 | 74 | $this->mVariants = array_diff( $variants, $wgDisabledVariants ); |
75 | 75 | $this->mVariantFallbacks = $variantfallbacks; |
76 | | - $this->mVariantNames = $wgLanguageNames; |
| 76 | + $this->mVariantNames = Language::getLanguageNames(); |
77 | 77 | $this->mCacheKey = wfMemcKey( 'conversiontables', $maincode ); |
78 | 78 | $defaultflags = array( |
79 | 79 | // 'S' show converted text |
Index: trunk/phase3/maintenance/doMaintenance.php |
— | — | @@ -53,17 +53,35 @@ |
54 | 54 | // to $maintenance->mSelf. Keep that here for b/c |
55 | 55 | $self = $maintenance->getName(); |
56 | 56 | |
| 57 | +// Detect compiled mode |
| 58 | +try { |
| 59 | + $r = new ReflectionFunction( 'wfHipHopCompilerVersion' ); |
| 60 | +} catch ( ReflectionException $e ) { |
| 61 | + $r = false; |
| 62 | +} |
| 63 | + |
| 64 | +if ( $r ) { |
| 65 | + define( 'MW_COMPILED', 1 ); |
| 66 | +} |
| 67 | + |
| 68 | +# Get the MWInit class |
| 69 | +if ( !defined( 'MW_COMPILED' ) ) { |
| 70 | + require_once( "$IP/includes/Init.php" ); |
| 71 | +} |
| 72 | + |
57 | 73 | # Setup the profiler |
58 | 74 | global $IP; |
59 | | -if ( file_exists( "$IP/StartProfiler.php" ) ) { |
| 75 | +if ( !defined( 'MW_COMPILED' ) && file_exists( "$IP/StartProfiler.php" ) ) { |
60 | 76 | require_once( "$IP/StartProfiler.php" ); |
61 | 77 | } else { |
62 | | - require_once( "$IP/includes/ProfilerStub.php" ); |
| 78 | + require_once( MWInit::compiledPath( 'includes/ProfilerStub.php' ) ); |
63 | 79 | } |
64 | 80 | |
65 | 81 | // Some other requires |
66 | | -require_once( "$IP/includes/AutoLoader.php" ); |
67 | | -require_once( "$IP/includes/Defines.php" ); |
| 82 | +if ( !defined( 'MW_COMPILED' ) ) { |
| 83 | + require_once( "$IP/includes/AutoLoader.php" ); |
| 84 | + require_once( "$IP/includes/Defines.php" ); |
| 85 | +} |
68 | 86 | require_once( "$IP/includes/DefaultSettings.php" ); |
69 | 87 | |
70 | 88 | if ( defined( 'MW_CONFIG_CALLBACK' ) ) { |
— | — | @@ -77,10 +95,10 @@ |
78 | 96 | global $cluster; |
79 | 97 | $wgWikiFarm = true; |
80 | 98 | $cluster = 'pmtpa'; |
81 | | - require_once( "$IP/includes/SiteConfiguration.php" ); |
82 | | - require( "$IP/wmf-config/wgConf.php" ); |
| 99 | + require_once( MWInit::compiledPath( 'includes/SiteConfiguration.php' ) ); |
| 100 | + require( MWInit::interpretedPath( 'wmf-config/wgConf.php' ) ); |
83 | 101 | $maintenance->loadWikimediaSettings(); |
84 | | - require( $IP . '/wmf-config/CommonSettings.php' ); |
| 102 | + require( MWInit::interpretedPath( '/wmf-config/CommonSettings.php' ) ); |
85 | 103 | } else { |
86 | 104 | require_once( $maintenance->loadSettings() ); |
87 | 105 | } |
— | — | @@ -88,12 +106,12 @@ |
89 | 107 | if ( $maintenance->getDbType() === Maintenance::DB_ADMIN && |
90 | 108 | is_readable( "$IP/AdminSettings.php" ) ) |
91 | 109 | { |
92 | | - require( "$IP/AdminSettings.php" ); |
| 110 | + require( MWInit::interpretedPath( 'AdminSettings.php' ) ); |
93 | 111 | } |
94 | 112 | $maintenance->finalSetup(); |
95 | 113 | // Some last includes |
96 | | -require_once( "$IP/includes/Setup.php" ); |
97 | | -require_once( "$IP/maintenance/install-utils.inc" ); |
| 114 | +require_once( MWInit::compiledPath( 'includes/Setup.php' ) ); |
| 115 | +require_once( MWInit::compiledPath( 'maintenance/install-utils.inc' ) ); |
98 | 116 | |
99 | 117 | // Much much faster startup than creating a title object |
100 | 118 | $wgTitle = null; |
Index: trunk/phase3/maintenance/addwiki.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $languageNames = Language::getLanguageNames(); |
59 | 59 | |
60 | 60 | if ( !isset( $languageNames[$lang] ) ) { |
61 | | - $this->error( "Language $lang not found in \$wgLanguageNames", true ); |
| 61 | + $this->error( "Language $lang not found in Names.php", true ); |
62 | 62 | } |
63 | 63 | $name = $languageNames[$lang]; |
64 | 64 | |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | if( count( $bt ) !== 2 ) { |
141 | 141 | return false; |
142 | 142 | } |
143 | | - return ( $bt[1]['function'] == 'require_once' || $bt[1]['function'] == 'require' ) && |
| 143 | + return in_array( $bt[1]['function'], array( 'require_once', 'require', 'include' ) ) && |
144 | 144 | $bt[0]['class'] == 'Maintenance' && |
145 | 145 | $bt[0]['function'] == 'shouldExecute'; |
146 | 146 | } |
— | — | @@ -430,11 +430,11 @@ |
431 | 431 | */ |
432 | 432 | public function runChild( $maintClass, $classFile = null ) { |
433 | 433 | // Make sure the class is loaded first |
434 | | - if ( !class_exists( $maintClass ) ) { |
| 434 | + if ( !MWInit::classExists( $maintClass ) ) { |
435 | 435 | if ( $classFile ) { |
436 | 436 | require_once( $classFile ); |
437 | 437 | } |
438 | | - if ( !class_exists( $maintClass ) ) { |
| 438 | + if ( !MWInit::classExists( $maintClass ) ) { |
439 | 439 | $this->error( "Cannot spawn child: $maintClass" ); |
440 | 440 | } |
441 | 441 | } |
— | — | @@ -456,7 +456,7 @@ |
457 | 457 | } |
458 | 458 | |
459 | 459 | # Make sure we can handle script parameters |
460 | | - if ( !ini_get( 'register_argc_argv' ) ) { |
| 460 | + if ( !function_exists( 'hphp_thread_set_warmup_enabled' ) && !ini_get( 'register_argc_argv' ) ) { |
461 | 461 | $this->error( 'Cannot get command line arguments, register_argc_argv is set to false', true ); |
462 | 462 | } |
463 | 463 | |
Index: trunk/phase3/maintenance/eval.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | readline_write_history( $historyFile ); |
76 | 76 | } |
77 | 77 | $val = eval( $line . ";" ); |
78 | | - if ( is_null( $val ) ) { |
| 78 | + if ( wfIsHipHop() || is_null( $val ) ) { |
79 | 79 | echo "\n"; |
80 | 80 | } elseif ( is_string( $val ) || is_numeric( $val ) ) { |
81 | 81 | echo "$val\n"; |
Index: trunk/phase3/maintenance/hiphop/file-list.small |
— | — | @@ -158,6 +158,7 @@ |
159 | 159 | includes/filerepo/OldLocalFile.php |
160 | 160 | includes/filerepo/RepoGroup.php |
161 | 161 | includes/filerepo/UnregisteredLocalFile.php |
| 162 | +includes/installer/Installer.php |
162 | 163 | includes/job/DoubleRedirectJob.php |
163 | 164 | includes/job/EmaillingJob.php |
164 | 165 | includes/job/EnotifNotifyJob.php |
— | — | @@ -280,6 +281,8 @@ |
281 | 282 | redirect.php |
282 | 283 | resources/Resources.php |
283 | 284 | serialized/serialize.php |
| 285 | +skins/MonoBook.deps.php |
| 286 | +skins/MonoBook.php |
284 | 287 | skins/Vector.deps.php |
285 | 288 | skins/Vector.php |
286 | 289 | thumb.php |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -457,6 +457,22 @@ |
458 | 458 | 'LBFactory_InstallerFake' => 'includes/installer/Installer.php', |
459 | 459 | 'LocalSettingsGenerator' => 'includes/installer/LocalSettingsGenerator.php', |
460 | 460 | 'WebInstaller' => 'includes/installer/WebInstaller.php', |
| 461 | + 'WebInstaller_Complete' => 'includes/installer/WebInstallerPage.php', |
| 462 | + 'WebInstaller_Copying' => 'includes/installer/WebInstallerPage.php', |
| 463 | + 'WebInstaller_DBConnect' => 'includes/installer/WebInstallerPage.php', |
| 464 | + 'WebInstaller_DBSettings' => 'includes/installer/WebInstallerPage.php', |
| 465 | + 'WebInstaller_Document' => 'includes/installer/WebInstallerPage.php', |
| 466 | + 'WebInstaller_ExistingWiki' => 'includes/installer/WebInstallerPage.php', |
| 467 | + 'WebInstaller_Install' => 'includes/installer/WebInstallerPage.php', |
| 468 | + 'WebInstaller_Language' => 'includes/installer/WebInstallerPage.php', |
| 469 | + 'WebInstaller_Name' => 'includes/installer/WebInstallerPage.php', |
| 470 | + 'WebInstaller_Options' => 'includes/installer/WebInstallerPage.php', |
| 471 | + 'WebInstaller_Readme' => 'includes/installer/WebInstallerPage.php', |
| 472 | + 'WebInstaller_ReleaseNotes' => 'includes/installer/WebInstallerPage.php', |
| 473 | + 'WebInstaller_Restart' => 'includes/installer/WebInstallerPage.php', |
| 474 | + 'WebInstaller_Upgrade' => 'includes/installer/WebInstallerPage.php', |
| 475 | + 'WebInstaller_UpgradeDoc' => 'includes/installer/WebInstallerPage.php', |
| 476 | + 'WebInstaller_Welcome' => 'includes/installer/WebInstallerPage.php', |
461 | 477 | 'WebInstallerPage' => 'includes/installer/WebInstallerPage.php', |
462 | 478 | 'WebInstallerOutput' => 'includes/installer/WebInstallerOutput.php', |
463 | 479 | 'MysqlInstaller' => 'includes/installer/MysqlInstaller.php', |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -218,6 +218,35 @@ |
219 | 219 | $wgMetaNamespace = str_replace( ' ', '_', $wgSitename ); |
220 | 220 | } |
221 | 221 | |
| 222 | +/** |
| 223 | + * Definitions of the NS_ constants are in Defines.php |
| 224 | + * @private |
| 225 | + */ |
| 226 | +$wgCanonicalNamespaceNames = array( |
| 227 | + NS_MEDIA => 'Media', |
| 228 | + NS_SPECIAL => 'Special', |
| 229 | + NS_TALK => 'Talk', |
| 230 | + NS_USER => 'User', |
| 231 | + NS_USER_TALK => 'User_talk', |
| 232 | + NS_PROJECT => 'Project', |
| 233 | + NS_PROJECT_TALK => 'Project_talk', |
| 234 | + NS_FILE => 'File', |
| 235 | + NS_FILE_TALK => 'File_talk', |
| 236 | + NS_MEDIAWIKI => 'MediaWiki', |
| 237 | + NS_MEDIAWIKI_TALK => 'MediaWiki_talk', |
| 238 | + NS_TEMPLATE => 'Template', |
| 239 | + NS_TEMPLATE_TALK => 'Template_talk', |
| 240 | + NS_HELP => 'Help', |
| 241 | + NS_HELP_TALK => 'Help_talk', |
| 242 | + NS_CATEGORY => 'Category', |
| 243 | + NS_CATEGORY_TALK => 'Category_talk', |
| 244 | +); |
| 245 | + |
| 246 | +/// @todo UGLY UGLY |
| 247 | +if( is_array( $wgExtraNamespaces ) ) { |
| 248 | + $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces; |
| 249 | +} |
| 250 | + |
222 | 251 | # These are now the same, always |
223 | 252 | # To determine the user language, use $wgLang->getCode() |
224 | 253 | $wgContLanguageCode = $wgLanguageCode; |
— | — | @@ -274,22 +303,24 @@ |
275 | 304 | $wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry'; |
276 | 305 | } |
277 | 306 | |
278 | | -if ( !class_exists( 'AutoLoader' ) ) { |
279 | | - require_once( "$IP/includes/AutoLoader.php" ); |
280 | | -} |
| 307 | +if ( !defined( 'MW_COMPILED' ) ) { |
| 308 | + if ( !MWInit::classExists( 'AutoLoader' ) ) { |
| 309 | + require_once( "$IP/includes/AutoLoader.php" ); |
| 310 | + } |
281 | 311 | |
282 | | -wfProfileIn( $fname . '-exception' ); |
283 | | -require_once( "$IP/includes/Exception.php" ); |
284 | | -wfInstallExceptionHandler(); |
285 | | -wfProfileOut( $fname . '-exception' ); |
| 312 | + wfProfileIn( $fname . '-exception' ); |
| 313 | + require_once( "$IP/includes/Exception.php" ); |
| 314 | + wfInstallExceptionHandler(); |
| 315 | + wfProfileOut( $fname . '-exception' ); |
286 | 316 | |
287 | | -wfProfileIn( $fname . '-includes' ); |
288 | | -require_once( "$IP/includes/GlobalFunctions.php" ); |
289 | | -require_once( "$IP/includes/Hooks.php" ); |
290 | | -require_once( "$IP/includes/Namespace.php" ); |
291 | | -require_once( "$IP/includes/ProxyTools.php" ); |
292 | | -require_once( "$IP/includes/ImageFunctions.php" ); |
293 | | -wfProfileOut( $fname . '-includes' ); |
| 317 | + wfProfileIn( $fname . '-includes' ); |
| 318 | + require_once( "$IP/includes/GlobalFunctions.php" ); |
| 319 | + require_once( "$IP/includes/Hooks.php" ); |
| 320 | + require_once( "$IP/includes/Namespace.php" ); |
| 321 | + require_once( "$IP/includes/ProxyTools.php" ); |
| 322 | + require_once( "$IP/includes/ImageFunctions.php" ); |
| 323 | + wfProfileOut( $fname . '-includes' ); |
| 324 | +} |
294 | 325 | wfProfileIn( $fname . '-misc1' ); |
295 | 326 | |
296 | 327 | # Raise the memory limit if it's too low |
Index: trunk/phase3/includes/User.php |
— | — | @@ -1333,7 +1333,7 @@ |
1334 | 1334 | if( $count > $max ) { |
1335 | 1335 | wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" ); |
1336 | 1336 | if( $wgRateLimitLog ) { |
1337 | | - @error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog ); |
| 1337 | + @file_put_contents( $wgRateLimitLog, wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", FILE_APPEND ); |
1338 | 1338 | } |
1339 | 1339 | $triggered = true; |
1340 | 1340 | } else { |
Index: trunk/phase3/includes/MemcachedSessions.php |
— | — | @@ -96,10 +96,3 @@ |
97 | 97 | session_write_close(); |
98 | 98 | } |
99 | 99 | |
100 | | -session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' ); |
101 | | - |
102 | | -// It's necessary to register a shutdown function to call session_write_close(), |
103 | | -// because by the time the request shutdown function for the session module is |
104 | | -// called, $wgMemc has already been destroyed. Shutdown functions registered |
105 | | -// this way are called before object destruction. |
106 | | -register_shutdown_function( 'memsess_write_close' ); |
Index: trunk/phase3/includes/installer/WebInstaller.php |
— | — | @@ -408,9 +408,6 @@ |
409 | 409 | * @return WebInstallerPage |
410 | 410 | */ |
411 | 411 | public function getPageByName( $pageName ) { |
412 | | - // Totally lame way to force autoload of WebInstallerPage.php |
413 | | - class_exists( 'WebInstallerPage' ); |
414 | | - |
415 | 412 | $pageClass = 'WebInstaller_' . $pageName; |
416 | 413 | |
417 | 414 | return new $pageClass( $this ); |
Index: trunk/phase3/includes/Sanitizer.php |
— | — | @@ -25,322 +25,323 @@ |
26 | 26 | */ |
27 | 27 | |
28 | 28 | /** |
29 | | - * Regular expression to match various types of character references in |
30 | | - * Sanitizer::normalizeCharReferences and Sanitizer::decodeCharReferences |
| 29 | + * XHTML sanitizer for MediaWiki |
| 30 | + * @ingroup Parser |
31 | 31 | */ |
32 | | -define( 'MW_CHAR_REFS_REGEX', |
33 | | - '/&([A-Za-z0-9\x80-\xff]+); |
34 | | - |&\#([0-9]+); |
35 | | - |&\#[xX]([0-9A-Fa-f]+); |
36 | | - |(&)/x' ); |
| 32 | +class Sanitizer { |
| 33 | + /** |
| 34 | + * Regular expression to match various types of character references in |
| 35 | + * Sanitizer::normalizeCharReferences and Sanitizer::decodeCharReferences |
| 36 | + */ |
| 37 | + const CHAR_REFS_REGEX = |
| 38 | + '/&([A-Za-z0-9\x80-\xff]+); |
| 39 | + |&\#([0-9]+); |
| 40 | + |&\#[xX]([0-9A-Fa-f]+); |
| 41 | + |(&)/x'; |
37 | 42 | |
38 | | -/** |
39 | | - * Regular expression to match HTML/XML attribute pairs within a tag. |
40 | | - * Allows some... latitude. |
41 | | - * Used in Sanitizer::fixTagAttributes and Sanitizer::decodeTagAttributes |
42 | | - */ |
43 | | -$attribFirst = '[:A-Z_a-z0-9]'; |
44 | | -$attrib = '[:A-Z_a-z-.0-9]'; |
45 | | -$space = '[\x09\x0a\x0d\x20]'; |
46 | | -define( 'MW_ATTRIBS_REGEX', |
47 | | - "/(?:^|$space)({$attribFirst}{$attrib}*) |
48 | | - ($space*=$space* |
49 | | - (?: |
50 | | - # The attribute value: quoted or alone |
51 | | - \"([^<\"]*)\" |
52 | | - | '([^<']*)' |
53 | | - | ([a-zA-Z0-9!#$%&()*,\\-.\\/:;<>?@[\\]^_`{|}~]+) |
54 | | - | (\#[0-9a-fA-F]+) # Technically wrong, but lots of |
55 | | - # colors are specified like this. |
56 | | - # We'll be normalizing it. |
57 | | - ) |
58 | | - )?(?=$space|\$)/sx" ); |
| 43 | + const EVIL_URI_PATTERN = '!(^|\s|\*/\s*)(javascript|vbscript)([^\w]|$)!i'; |
| 44 | + const XMLNS_ATTRIBUTE_PATTERN = "/^xmlns:[:A-Z_a-z-.0-9]+$/"; |
59 | 45 | |
60 | | -/** |
61 | | - * Regular expression to match URIs that could trigger script execution |
62 | | - */ |
63 | | -define( 'MW_EVIL_URI_PATTERN', '!(^|\s|\*/\s*)(javascript|vbscript)([^\w]|$)!i' ); |
| 46 | + /** |
| 47 | + * List of all named character entities defined in HTML 4.01 |
| 48 | + * http://www.w3.org/TR/html4/sgml/entities.html |
| 49 | + * @private |
| 50 | + */ |
| 51 | + static $htmlEntities = array( |
| 52 | + 'Aacute' => 193, |
| 53 | + 'aacute' => 225, |
| 54 | + 'Acirc' => 194, |
| 55 | + 'acirc' => 226, |
| 56 | + 'acute' => 180, |
| 57 | + 'AElig' => 198, |
| 58 | + 'aelig' => 230, |
| 59 | + 'Agrave' => 192, |
| 60 | + 'agrave' => 224, |
| 61 | + 'alefsym' => 8501, |
| 62 | + 'Alpha' => 913, |
| 63 | + 'alpha' => 945, |
| 64 | + 'amp' => 38, |
| 65 | + 'and' => 8743, |
| 66 | + 'ang' => 8736, |
| 67 | + 'Aring' => 197, |
| 68 | + 'aring' => 229, |
| 69 | + 'asymp' => 8776, |
| 70 | + 'Atilde' => 195, |
| 71 | + 'atilde' => 227, |
| 72 | + 'Auml' => 196, |
| 73 | + 'auml' => 228, |
| 74 | + 'bdquo' => 8222, |
| 75 | + 'Beta' => 914, |
| 76 | + 'beta' => 946, |
| 77 | + 'brvbar' => 166, |
| 78 | + 'bull' => 8226, |
| 79 | + 'cap' => 8745, |
| 80 | + 'Ccedil' => 199, |
| 81 | + 'ccedil' => 231, |
| 82 | + 'cedil' => 184, |
| 83 | + 'cent' => 162, |
| 84 | + 'Chi' => 935, |
| 85 | + 'chi' => 967, |
| 86 | + 'circ' => 710, |
| 87 | + 'clubs' => 9827, |
| 88 | + 'cong' => 8773, |
| 89 | + 'copy' => 169, |
| 90 | + 'crarr' => 8629, |
| 91 | + 'cup' => 8746, |
| 92 | + 'curren' => 164, |
| 93 | + 'dagger' => 8224, |
| 94 | + 'Dagger' => 8225, |
| 95 | + 'darr' => 8595, |
| 96 | + 'dArr' => 8659, |
| 97 | + 'deg' => 176, |
| 98 | + 'Delta' => 916, |
| 99 | + 'delta' => 948, |
| 100 | + 'diams' => 9830, |
| 101 | + 'divide' => 247, |
| 102 | + 'Eacute' => 201, |
| 103 | + 'eacute' => 233, |
| 104 | + 'Ecirc' => 202, |
| 105 | + 'ecirc' => 234, |
| 106 | + 'Egrave' => 200, |
| 107 | + 'egrave' => 232, |
| 108 | + 'empty' => 8709, |
| 109 | + 'emsp' => 8195, |
| 110 | + 'ensp' => 8194, |
| 111 | + 'Epsilon' => 917, |
| 112 | + 'epsilon' => 949, |
| 113 | + 'equiv' => 8801, |
| 114 | + 'Eta' => 919, |
| 115 | + 'eta' => 951, |
| 116 | + 'ETH' => 208, |
| 117 | + 'eth' => 240, |
| 118 | + 'Euml' => 203, |
| 119 | + 'euml' => 235, |
| 120 | + 'euro' => 8364, |
| 121 | + 'exist' => 8707, |
| 122 | + 'fnof' => 402, |
| 123 | + 'forall' => 8704, |
| 124 | + 'frac12' => 189, |
| 125 | + 'frac14' => 188, |
| 126 | + 'frac34' => 190, |
| 127 | + 'frasl' => 8260, |
| 128 | + 'Gamma' => 915, |
| 129 | + 'gamma' => 947, |
| 130 | + 'ge' => 8805, |
| 131 | + 'gt' => 62, |
| 132 | + 'harr' => 8596, |
| 133 | + 'hArr' => 8660, |
| 134 | + 'hearts' => 9829, |
| 135 | + 'hellip' => 8230, |
| 136 | + 'Iacute' => 205, |
| 137 | + 'iacute' => 237, |
| 138 | + 'Icirc' => 206, |
| 139 | + 'icirc' => 238, |
| 140 | + 'iexcl' => 161, |
| 141 | + 'Igrave' => 204, |
| 142 | + 'igrave' => 236, |
| 143 | + 'image' => 8465, |
| 144 | + 'infin' => 8734, |
| 145 | + 'int' => 8747, |
| 146 | + 'Iota' => 921, |
| 147 | + 'iota' => 953, |
| 148 | + 'iquest' => 191, |
| 149 | + 'isin' => 8712, |
| 150 | + 'Iuml' => 207, |
| 151 | + 'iuml' => 239, |
| 152 | + 'Kappa' => 922, |
| 153 | + 'kappa' => 954, |
| 154 | + 'Lambda' => 923, |
| 155 | + 'lambda' => 955, |
| 156 | + 'lang' => 9001, |
| 157 | + 'laquo' => 171, |
| 158 | + 'larr' => 8592, |
| 159 | + 'lArr' => 8656, |
| 160 | + 'lceil' => 8968, |
| 161 | + 'ldquo' => 8220, |
| 162 | + 'le' => 8804, |
| 163 | + 'lfloor' => 8970, |
| 164 | + 'lowast' => 8727, |
| 165 | + 'loz' => 9674, |
| 166 | + 'lrm' => 8206, |
| 167 | + 'lsaquo' => 8249, |
| 168 | + 'lsquo' => 8216, |
| 169 | + 'lt' => 60, |
| 170 | + 'macr' => 175, |
| 171 | + 'mdash' => 8212, |
| 172 | + 'micro' => 181, |
| 173 | + 'middot' => 183, |
| 174 | + 'minus' => 8722, |
| 175 | + 'Mu' => 924, |
| 176 | + 'mu' => 956, |
| 177 | + 'nabla' => 8711, |
| 178 | + 'nbsp' => 160, |
| 179 | + 'ndash' => 8211, |
| 180 | + 'ne' => 8800, |
| 181 | + 'ni' => 8715, |
| 182 | + 'not' => 172, |
| 183 | + 'notin' => 8713, |
| 184 | + 'nsub' => 8836, |
| 185 | + 'Ntilde' => 209, |
| 186 | + 'ntilde' => 241, |
| 187 | + 'Nu' => 925, |
| 188 | + 'nu' => 957, |
| 189 | + 'Oacute' => 211, |
| 190 | + 'oacute' => 243, |
| 191 | + 'Ocirc' => 212, |
| 192 | + 'ocirc' => 244, |
| 193 | + 'OElig' => 338, |
| 194 | + 'oelig' => 339, |
| 195 | + 'Ograve' => 210, |
| 196 | + 'ograve' => 242, |
| 197 | + 'oline' => 8254, |
| 198 | + 'Omega' => 937, |
| 199 | + 'omega' => 969, |
| 200 | + 'Omicron' => 927, |
| 201 | + 'omicron' => 959, |
| 202 | + 'oplus' => 8853, |
| 203 | + 'or' => 8744, |
| 204 | + 'ordf' => 170, |
| 205 | + 'ordm' => 186, |
| 206 | + 'Oslash' => 216, |
| 207 | + 'oslash' => 248, |
| 208 | + 'Otilde' => 213, |
| 209 | + 'otilde' => 245, |
| 210 | + 'otimes' => 8855, |
| 211 | + 'Ouml' => 214, |
| 212 | + 'ouml' => 246, |
| 213 | + 'para' => 182, |
| 214 | + 'part' => 8706, |
| 215 | + 'permil' => 8240, |
| 216 | + 'perp' => 8869, |
| 217 | + 'Phi' => 934, |
| 218 | + 'phi' => 966, |
| 219 | + 'Pi' => 928, |
| 220 | + 'pi' => 960, |
| 221 | + 'piv' => 982, |
| 222 | + 'plusmn' => 177, |
| 223 | + 'pound' => 163, |
| 224 | + 'prime' => 8242, |
| 225 | + 'Prime' => 8243, |
| 226 | + 'prod' => 8719, |
| 227 | + 'prop' => 8733, |
| 228 | + 'Psi' => 936, |
| 229 | + 'psi' => 968, |
| 230 | + 'quot' => 34, |
| 231 | + 'radic' => 8730, |
| 232 | + 'rang' => 9002, |
| 233 | + 'raquo' => 187, |
| 234 | + 'rarr' => 8594, |
| 235 | + 'rArr' => 8658, |
| 236 | + 'rceil' => 8969, |
| 237 | + 'rdquo' => 8221, |
| 238 | + 'real' => 8476, |
| 239 | + 'reg' => 174, |
| 240 | + 'rfloor' => 8971, |
| 241 | + 'Rho' => 929, |
| 242 | + 'rho' => 961, |
| 243 | + 'rlm' => 8207, |
| 244 | + 'rsaquo' => 8250, |
| 245 | + 'rsquo' => 8217, |
| 246 | + 'sbquo' => 8218, |
| 247 | + 'Scaron' => 352, |
| 248 | + 'scaron' => 353, |
| 249 | + 'sdot' => 8901, |
| 250 | + 'sect' => 167, |
| 251 | + 'shy' => 173, |
| 252 | + 'Sigma' => 931, |
| 253 | + 'sigma' => 963, |
| 254 | + 'sigmaf' => 962, |
| 255 | + 'sim' => 8764, |
| 256 | + 'spades' => 9824, |
| 257 | + 'sub' => 8834, |
| 258 | + 'sube' => 8838, |
| 259 | + 'sum' => 8721, |
| 260 | + 'sup' => 8835, |
| 261 | + 'sup1' => 185, |
| 262 | + 'sup2' => 178, |
| 263 | + 'sup3' => 179, |
| 264 | + 'supe' => 8839, |
| 265 | + 'szlig' => 223, |
| 266 | + 'Tau' => 932, |
| 267 | + 'tau' => 964, |
| 268 | + 'there4' => 8756, |
| 269 | + 'Theta' => 920, |
| 270 | + 'theta' => 952, |
| 271 | + 'thetasym' => 977, |
| 272 | + 'thinsp' => 8201, |
| 273 | + 'THORN' => 222, |
| 274 | + 'thorn' => 254, |
| 275 | + 'tilde' => 732, |
| 276 | + 'times' => 215, |
| 277 | + 'trade' => 8482, |
| 278 | + 'Uacute' => 218, |
| 279 | + 'uacute' => 250, |
| 280 | + 'uarr' => 8593, |
| 281 | + 'uArr' => 8657, |
| 282 | + 'Ucirc' => 219, |
| 283 | + 'ucirc' => 251, |
| 284 | + 'Ugrave' => 217, |
| 285 | + 'ugrave' => 249, |
| 286 | + 'uml' => 168, |
| 287 | + 'upsih' => 978, |
| 288 | + 'Upsilon' => 933, |
| 289 | + 'upsilon' => 965, |
| 290 | + 'Uuml' => 220, |
| 291 | + 'uuml' => 252, |
| 292 | + 'weierp' => 8472, |
| 293 | + 'Xi' => 926, |
| 294 | + 'xi' => 958, |
| 295 | + 'Yacute' => 221, |
| 296 | + 'yacute' => 253, |
| 297 | + 'yen' => 165, |
| 298 | + 'Yuml' => 376, |
| 299 | + 'yuml' => 255, |
| 300 | + 'Zeta' => 918, |
| 301 | + 'zeta' => 950, |
| 302 | + 'zwj' => 8205, |
| 303 | + 'zwnj' => 8204 |
| 304 | + ); |
64 | 305 | |
65 | | -/** |
66 | | - * Regular expression to match namespace attributes |
67 | | - */ |
68 | | -define( 'MW_XMLNS_ATTRIBUTE_PATTRN', "/^xmlns:$attrib+$/" ); |
| 306 | + /** |
| 307 | + * Character entity aliases accepted by MediaWiki |
| 308 | + */ |
| 309 | + static $htmlEntityAliases = array( |
| 310 | + 'רלמ' => 'rlm', |
| 311 | + 'رلم' => 'rlm', |
| 312 | + ); |
69 | 313 | |
70 | | -/** |
71 | | - * List of all named character entities defined in HTML 4.01 |
72 | | - * http://www.w3.org/TR/html4/sgml/entities.html |
73 | | - * @private |
74 | | - */ |
75 | | -global $wgHtmlEntities; |
76 | | -$wgHtmlEntities = array( |
77 | | - 'Aacute' => 193, |
78 | | - 'aacute' => 225, |
79 | | - 'Acirc' => 194, |
80 | | - 'acirc' => 226, |
81 | | - 'acute' => 180, |
82 | | - 'AElig' => 198, |
83 | | - 'aelig' => 230, |
84 | | - 'Agrave' => 192, |
85 | | - 'agrave' => 224, |
86 | | - 'alefsym' => 8501, |
87 | | - 'Alpha' => 913, |
88 | | - 'alpha' => 945, |
89 | | - 'amp' => 38, |
90 | | - 'and' => 8743, |
91 | | - 'ang' => 8736, |
92 | | - 'Aring' => 197, |
93 | | - 'aring' => 229, |
94 | | - 'asymp' => 8776, |
95 | | - 'Atilde' => 195, |
96 | | - 'atilde' => 227, |
97 | | - 'Auml' => 196, |
98 | | - 'auml' => 228, |
99 | | - 'bdquo' => 8222, |
100 | | - 'Beta' => 914, |
101 | | - 'beta' => 946, |
102 | | - 'brvbar' => 166, |
103 | | - 'bull' => 8226, |
104 | | - 'cap' => 8745, |
105 | | - 'Ccedil' => 199, |
106 | | - 'ccedil' => 231, |
107 | | - 'cedil' => 184, |
108 | | - 'cent' => 162, |
109 | | - 'Chi' => 935, |
110 | | - 'chi' => 967, |
111 | | - 'circ' => 710, |
112 | | - 'clubs' => 9827, |
113 | | - 'cong' => 8773, |
114 | | - 'copy' => 169, |
115 | | - 'crarr' => 8629, |
116 | | - 'cup' => 8746, |
117 | | - 'curren' => 164, |
118 | | - 'dagger' => 8224, |
119 | | - 'Dagger' => 8225, |
120 | | - 'darr' => 8595, |
121 | | - 'dArr' => 8659, |
122 | | - 'deg' => 176, |
123 | | - 'Delta' => 916, |
124 | | - 'delta' => 948, |
125 | | - 'diams' => 9830, |
126 | | - 'divide' => 247, |
127 | | - 'Eacute' => 201, |
128 | | - 'eacute' => 233, |
129 | | - 'Ecirc' => 202, |
130 | | - 'ecirc' => 234, |
131 | | - 'Egrave' => 200, |
132 | | - 'egrave' => 232, |
133 | | - 'empty' => 8709, |
134 | | - 'emsp' => 8195, |
135 | | - 'ensp' => 8194, |
136 | | - 'Epsilon' => 917, |
137 | | - 'epsilon' => 949, |
138 | | - 'equiv' => 8801, |
139 | | - 'Eta' => 919, |
140 | | - 'eta' => 951, |
141 | | - 'ETH' => 208, |
142 | | - 'eth' => 240, |
143 | | - 'Euml' => 203, |
144 | | - 'euml' => 235, |
145 | | - 'euro' => 8364, |
146 | | - 'exist' => 8707, |
147 | | - 'fnof' => 402, |
148 | | - 'forall' => 8704, |
149 | | - 'frac12' => 189, |
150 | | - 'frac14' => 188, |
151 | | - 'frac34' => 190, |
152 | | - 'frasl' => 8260, |
153 | | - 'Gamma' => 915, |
154 | | - 'gamma' => 947, |
155 | | - 'ge' => 8805, |
156 | | - 'gt' => 62, |
157 | | - 'harr' => 8596, |
158 | | - 'hArr' => 8660, |
159 | | - 'hearts' => 9829, |
160 | | - 'hellip' => 8230, |
161 | | - 'Iacute' => 205, |
162 | | - 'iacute' => 237, |
163 | | - 'Icirc' => 206, |
164 | | - 'icirc' => 238, |
165 | | - 'iexcl' => 161, |
166 | | - 'Igrave' => 204, |
167 | | - 'igrave' => 236, |
168 | | - 'image' => 8465, |
169 | | - 'infin' => 8734, |
170 | | - 'int' => 8747, |
171 | | - 'Iota' => 921, |
172 | | - 'iota' => 953, |
173 | | - 'iquest' => 191, |
174 | | - 'isin' => 8712, |
175 | | - 'Iuml' => 207, |
176 | | - 'iuml' => 239, |
177 | | - 'Kappa' => 922, |
178 | | - 'kappa' => 954, |
179 | | - 'Lambda' => 923, |
180 | | - 'lambda' => 955, |
181 | | - 'lang' => 9001, |
182 | | - 'laquo' => 171, |
183 | | - 'larr' => 8592, |
184 | | - 'lArr' => 8656, |
185 | | - 'lceil' => 8968, |
186 | | - 'ldquo' => 8220, |
187 | | - 'le' => 8804, |
188 | | - 'lfloor' => 8970, |
189 | | - 'lowast' => 8727, |
190 | | - 'loz' => 9674, |
191 | | - 'lrm' => 8206, |
192 | | - 'lsaquo' => 8249, |
193 | | - 'lsquo' => 8216, |
194 | | - 'lt' => 60, |
195 | | - 'macr' => 175, |
196 | | - 'mdash' => 8212, |
197 | | - 'micro' => 181, |
198 | | - 'middot' => 183, |
199 | | - 'minus' => 8722, |
200 | | - 'Mu' => 924, |
201 | | - 'mu' => 956, |
202 | | - 'nabla' => 8711, |
203 | | - 'nbsp' => 160, |
204 | | - 'ndash' => 8211, |
205 | | - 'ne' => 8800, |
206 | | - 'ni' => 8715, |
207 | | - 'not' => 172, |
208 | | - 'notin' => 8713, |
209 | | - 'nsub' => 8836, |
210 | | - 'Ntilde' => 209, |
211 | | - 'ntilde' => 241, |
212 | | - 'Nu' => 925, |
213 | | - 'nu' => 957, |
214 | | - 'Oacute' => 211, |
215 | | - 'oacute' => 243, |
216 | | - 'Ocirc' => 212, |
217 | | - 'ocirc' => 244, |
218 | | - 'OElig' => 338, |
219 | | - 'oelig' => 339, |
220 | | - 'Ograve' => 210, |
221 | | - 'ograve' => 242, |
222 | | - 'oline' => 8254, |
223 | | - 'Omega' => 937, |
224 | | - 'omega' => 969, |
225 | | - 'Omicron' => 927, |
226 | | - 'omicron' => 959, |
227 | | - 'oplus' => 8853, |
228 | | - 'or' => 8744, |
229 | | - 'ordf' => 170, |
230 | | - 'ordm' => 186, |
231 | | - 'Oslash' => 216, |
232 | | - 'oslash' => 248, |
233 | | - 'Otilde' => 213, |
234 | | - 'otilde' => 245, |
235 | | - 'otimes' => 8855, |
236 | | - 'Ouml' => 214, |
237 | | - 'ouml' => 246, |
238 | | - 'para' => 182, |
239 | | - 'part' => 8706, |
240 | | - 'permil' => 8240, |
241 | | - 'perp' => 8869, |
242 | | - 'Phi' => 934, |
243 | | - 'phi' => 966, |
244 | | - 'Pi' => 928, |
245 | | - 'pi' => 960, |
246 | | - 'piv' => 982, |
247 | | - 'plusmn' => 177, |
248 | | - 'pound' => 163, |
249 | | - 'prime' => 8242, |
250 | | - 'Prime' => 8243, |
251 | | - 'prod' => 8719, |
252 | | - 'prop' => 8733, |
253 | | - 'Psi' => 936, |
254 | | - 'psi' => 968, |
255 | | - 'quot' => 34, |
256 | | - 'radic' => 8730, |
257 | | - 'rang' => 9002, |
258 | | - 'raquo' => 187, |
259 | | - 'rarr' => 8594, |
260 | | - 'rArr' => 8658, |
261 | | - 'rceil' => 8969, |
262 | | - 'rdquo' => 8221, |
263 | | - 'real' => 8476, |
264 | | - 'reg' => 174, |
265 | | - 'rfloor' => 8971, |
266 | | - 'Rho' => 929, |
267 | | - 'rho' => 961, |
268 | | - 'rlm' => 8207, |
269 | | - 'rsaquo' => 8250, |
270 | | - 'rsquo' => 8217, |
271 | | - 'sbquo' => 8218, |
272 | | - 'Scaron' => 352, |
273 | | - 'scaron' => 353, |
274 | | - 'sdot' => 8901, |
275 | | - 'sect' => 167, |
276 | | - 'shy' => 173, |
277 | | - 'Sigma' => 931, |
278 | | - 'sigma' => 963, |
279 | | - 'sigmaf' => 962, |
280 | | - 'sim' => 8764, |
281 | | - 'spades' => 9824, |
282 | | - 'sub' => 8834, |
283 | | - 'sube' => 8838, |
284 | | - 'sum' => 8721, |
285 | | - 'sup' => 8835, |
286 | | - 'sup1' => 185, |
287 | | - 'sup2' => 178, |
288 | | - 'sup3' => 179, |
289 | | - 'supe' => 8839, |
290 | | - 'szlig' => 223, |
291 | | - 'Tau' => 932, |
292 | | - 'tau' => 964, |
293 | | - 'there4' => 8756, |
294 | | - 'Theta' => 920, |
295 | | - 'theta' => 952, |
296 | | - 'thetasym' => 977, |
297 | | - 'thinsp' => 8201, |
298 | | - 'THORN' => 222, |
299 | | - 'thorn' => 254, |
300 | | - 'tilde' => 732, |
301 | | - 'times' => 215, |
302 | | - 'trade' => 8482, |
303 | | - 'Uacute' => 218, |
304 | | - 'uacute' => 250, |
305 | | - 'uarr' => 8593, |
306 | | - 'uArr' => 8657, |
307 | | - 'Ucirc' => 219, |
308 | | - 'ucirc' => 251, |
309 | | - 'Ugrave' => 217, |
310 | | - 'ugrave' => 249, |
311 | | - 'uml' => 168, |
312 | | - 'upsih' => 978, |
313 | | - 'Upsilon' => 933, |
314 | | - 'upsilon' => 965, |
315 | | - 'Uuml' => 220, |
316 | | - 'uuml' => 252, |
317 | | - 'weierp' => 8472, |
318 | | - 'Xi' => 926, |
319 | | - 'xi' => 958, |
320 | | - 'Yacute' => 221, |
321 | | - 'yacute' => 253, |
322 | | - 'yen' => 165, |
323 | | - 'Yuml' => 376, |
324 | | - 'yuml' => 255, |
325 | | - 'Zeta' => 918, |
326 | | - 'zeta' => 950, |
327 | | - 'zwj' => 8205, |
328 | | - 'zwnj' => 8204 ); |
| 314 | + /** |
| 315 | + * Lazy-initialised attributes regex, see getAttribsRegex() |
| 316 | + */ |
| 317 | + static $attribsRegex; |
329 | 318 | |
330 | | -/** |
331 | | - * Character entity aliases accepted by MediaWiki |
332 | | - */ |
333 | | -global $wgHtmlEntityAliases; |
334 | | -$wgHtmlEntityAliases = array( |
335 | | - 'רלמ' => 'rlm', |
336 | | - 'رلم' => 'rlm', |
337 | | -); |
| 319 | + /** |
| 320 | + * Regular expression to match HTML/XML attribute pairs within a tag. |
| 321 | + * Allows some... latitude. |
| 322 | + * Used in Sanitizer::fixTagAttributes and Sanitizer::decodeTagAttributes |
| 323 | + */ |
| 324 | + static function getAttribsRegex() { |
| 325 | + if ( self::$attribsRegex === null ) { |
| 326 | + $attribFirst = '[:A-Z_a-z0-9]'; |
| 327 | + $attrib = '[:A-Z_a-z-.0-9]'; |
| 328 | + $space = '[\x09\x0a\x0d\x20]'; |
| 329 | + self::$attribsRegex = |
| 330 | + "/(?:^|$space)({$attribFirst}{$attrib}*) |
| 331 | + ($space*=$space* |
| 332 | + (?: |
| 333 | + # The attribute value: quoted or alone |
| 334 | + \"([^<\"]*)\" |
| 335 | + | '([^<']*)' |
| 336 | + | ([a-zA-Z0-9!#$%&()*,\\-.\\/:;<>?@[\\]^_`{|}~]+) |
| 337 | + | (\#[0-9a-fA-F]+) # Technically wrong, but lots of |
| 338 | + # colors are specified like this. |
| 339 | + # We'll be normalizing it. |
| 340 | + ) |
| 341 | + )?(?=$space|\$)/sx"; |
| 342 | + } |
| 343 | + return self::$attribsRegex; |
| 344 | + } |
338 | 345 | |
339 | | - |
340 | | -/** |
341 | | - * XHTML sanitizer for MediaWiki |
342 | | - * @ingroup Parser |
343 | | - */ |
344 | | -class Sanitizer { |
345 | 346 | /** |
346 | 347 | * Cleans up HTML, removes dangerous tags and attributes, and |
347 | 348 | * removes HTML comments |
— | — | @@ -635,8 +636,8 @@ |
636 | 637 | $out = array(); |
637 | 638 | foreach( $attribs as $attribute => $value ) { |
638 | 639 | #allow XML namespace declaration if RDFa is enabled |
639 | | - if ( $wgAllowRdfaAttributes && preg_match( MW_XMLNS_ATTRIBUTE_PATTRN, $attribute ) ) { |
640 | | - if ( !preg_match( MW_EVIL_URI_PATTERN, $value ) ) { |
| 640 | + if ( $wgAllowRdfaAttributes && preg_match( self::XMLNS_ATTRIBUTE_PATTERN, $attribute ) ) { |
| 641 | + if ( !preg_match( self::EVIL_URI_PATTERN, $value ) ) { |
641 | 642 | $out[$attribute] = $value; |
642 | 643 | } |
643 | 644 | |
— | — | @@ -666,7 +667,7 @@ |
667 | 668 | $attribute === 'itemscope' || $attribute === 'itemtype' ) { #HTML5 microdata |
668 | 669 | |
669 | 670 | //Paranoia. Allow "simple" values but suppress javascript |
670 | | - if ( preg_match( MW_EVIL_URI_PATTERN, $value ) ) { |
| 671 | + if ( preg_match( self::EVIL_URI_PATTERN, $value ) ) { |
671 | 672 | continue; |
672 | 673 | } |
673 | 674 | } |
— | — | @@ -1002,7 +1003,7 @@ |
1003 | 1004 | $attribs = array(); |
1004 | 1005 | $pairs = array(); |
1005 | 1006 | if( !preg_match_all( |
1006 | | - MW_ATTRIBS_REGEX, |
| 1007 | + self::getAttribsRegex(), |
1007 | 1008 | $text, |
1008 | 1009 | $pairs, |
1009 | 1010 | PREG_SET_ORDER ) ) { |
— | — | @@ -1025,7 +1026,7 @@ |
1026 | 1027 | |
1027 | 1028 | /** |
1028 | 1029 | * Pick the appropriate attribute value from a match set from the |
1029 | | - * MW_ATTRIBS_REGEX matches. |
| 1030 | + * attribs regex matches. |
1030 | 1031 | * |
1031 | 1032 | * @param $set Array |
1032 | 1033 | * @return String |
— | — | @@ -1105,7 +1106,7 @@ |
1106 | 1107 | */ |
1107 | 1108 | static function normalizeCharReferences( $text ) { |
1108 | 1109 | return preg_replace_callback( |
1109 | | - MW_CHAR_REFS_REGEX, |
| 1110 | + self::CHAR_REFS_REGEX, |
1110 | 1111 | array( 'Sanitizer', 'normalizeCharReferencesCallback' ), |
1111 | 1112 | $text ); |
1112 | 1113 | } |
— | — | @@ -1140,14 +1141,13 @@ |
1141 | 1142 | * @return String |
1142 | 1143 | */ |
1143 | 1144 | static function normalizeEntity( $name ) { |
1144 | | - global $wgHtmlEntities, $wgHtmlEntityAliases; |
1145 | | - if ( isset( $wgHtmlEntityAliases[$name] ) ) { |
1146 | | - return "&{$wgHtmlEntityAliases[$name]};"; |
| 1145 | + if ( isset( self::$htmlEntityAliases[$name] ) ) { |
| 1146 | + return '&' . self::$htmlEntityAliases[$name] . ';'; |
1147 | 1147 | } elseif ( in_array( $name, |
1148 | 1148 | array( 'lt', 'gt', 'amp', 'quot' ) ) ) { |
1149 | 1149 | return "&$name;"; |
1150 | | - } elseif ( isset( $wgHtmlEntities[$name] ) ) { |
1151 | | - return "&#{$wgHtmlEntities[$name]};"; |
| 1150 | + } elseif ( isset( self::$htmlEntities[$name] ) ) { |
| 1151 | + return '&#' . self::$htmlEntities[$name] . ';'; |
1152 | 1152 | } else { |
1153 | 1153 | return "&$name;"; |
1154 | 1154 | } |
— | — | @@ -1194,7 +1194,7 @@ |
1195 | 1195 | */ |
1196 | 1196 | public static function decodeCharReferences( $text ) { |
1197 | 1197 | return preg_replace_callback( |
1198 | | - MW_CHAR_REFS_REGEX, |
| 1198 | + self::CHAR_REFS_REGEX, |
1199 | 1199 | array( 'Sanitizer', 'decodeCharReferencesCallback' ), |
1200 | 1200 | $text ); |
1201 | 1201 | } |
— | — | @@ -1212,7 +1212,7 @@ |
1213 | 1213 | public static function decodeCharReferencesAndNormalize( $text ) { |
1214 | 1214 | global $wgContLang; |
1215 | 1215 | $text = preg_replace_callback( |
1216 | | - MW_CHAR_REFS_REGEX, |
| 1216 | + self::CHAR_REFS_REGEX, |
1217 | 1217 | array( 'Sanitizer', 'decodeCharReferencesCallback' ), |
1218 | 1218 | $text, /* limit */ -1, $count ); |
1219 | 1219 | |
— | — | @@ -1263,12 +1263,11 @@ |
1264 | 1264 | * @return String |
1265 | 1265 | */ |
1266 | 1266 | static function decodeEntity( $name ) { |
1267 | | - global $wgHtmlEntities, $wgHtmlEntityAliases; |
1268 | | - if ( isset( $wgHtmlEntityAliases[$name] ) ) { |
1269 | | - $name = $wgHtmlEntityAliases[$name]; |
| 1267 | + if ( isset( self::$htmlEntityAliases[$name] ) ) { |
| 1268 | + $name = self::$htmlEntityAliases[$name]; |
1270 | 1269 | } |
1271 | | - if( isset( $wgHtmlEntities[$name] ) ) { |
1272 | | - return codepointToUtf8( $wgHtmlEntities[$name] ); |
| 1270 | + if( isset( self::$htmlEntities[$name] ) ) { |
| 1271 | + return codepointToUtf8( self::$htmlEntities[$name] ); |
1273 | 1272 | } else { |
1274 | 1273 | return "&$name;"; |
1275 | 1274 | } |
— | — | @@ -1493,9 +1492,8 @@ |
1494 | 1493 | * @return String |
1495 | 1494 | */ |
1496 | 1495 | static function hackDocType() { |
1497 | | - global $wgHtmlEntities; |
1498 | 1496 | $out = "<!DOCTYPE html [\n"; |
1499 | | - foreach( $wgHtmlEntities as $entity => $codepoint ) { |
| 1497 | + foreach( self::$htmlEntities as $entity => $codepoint ) { |
1500 | 1498 | $out .= "<!ENTITY $entity \"&#$codepoint;\">"; |
1501 | 1499 | } |
1502 | 1500 | $out .= "]>\n"; |
Index: trunk/phase3/includes/Defines.php |
— | — | @@ -1,6 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * A few constants that might be needed during LocalSettings.php |
| 4 | + * A few constants that might be needed during LocalSettings.php. |
| 5 | + * |
| 6 | + * Note: these constants must all be resolvable at compile time by HipHop, |
| 7 | + * since this file will not be executed during request startup for a compiled |
| 8 | + * MediaWiki. |
| 9 | + * |
5 | 10 | * @file |
6 | 11 | */ |
7 | 12 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -5,15 +5,6 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | /** |
9 | | - * @todo: determine if it is really necessary to load this. Appears to be left over from pre-autoloader versions, and |
10 | | - * is only really needed to provide access to constant UTF8_REPLACEMENT, which actually resides in UtfNormalDefines.php |
11 | | - * and is loaded by UtfNormalUtil.php, which is loaded by UtfNormal.php. |
12 | | - */ |
13 | | -if ( !class_exists( 'UtfNormal' ) ) { |
14 | | - require_once( dirname( __FILE__ ) . '/normal/UtfNormal.php' ); |
15 | | -} |
16 | | - |
17 | | -/** |
18 | 9 | * @deprecated This used to be a define, but was moved to |
19 | 10 | * Title::GAID_FOR_UPDATE in 1.17. This will probably be removed in 1.18 |
20 | 11 | */ |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -8,7 +8,9 @@ |
9 | 9 | die( "This file is part of MediaWiki, it is not a valid entry point" ); |
10 | 10 | } |
11 | 11 | |
12 | | -require_once dirname( __FILE__ ) . '/normal/UtfNormalUtil.php'; |
| 12 | +if ( !defined( 'MW_COMPILED' ) ) { |
| 13 | + require_once( dirname( __FILE__ ) . '/normal/UtfNormalUtil.php' ); |
| 14 | +} |
13 | 15 | |
14 | 16 | // Hide compatibility functions from Doxygen |
15 | 17 | /// @cond |
— | — | @@ -329,7 +331,7 @@ |
330 | 332 | $exists = file_exists( $file ); |
331 | 333 | $size = $exists ? filesize( $file ) : false; |
332 | 334 | if ( !$exists || ( $size !== false && $size + strlen( $text ) < 0x7fffffff ) ) { |
333 | | - error_log( $text, 3, $file ); |
| 335 | + file_put_contents( $file, $text, FILE_APPEND ); |
334 | 336 | } |
335 | 337 | wfRestoreWarnings(); |
336 | 338 | } |
— | — | @@ -495,7 +497,7 @@ |
496 | 498 | */ |
497 | 499 | function wfMessageFallback( /*...*/ ) { |
498 | 500 | $args = func_get_args(); |
499 | | - return call_user_func_array( array( 'Message', 'newFallbackSequence' ), $args ); |
| 501 | + return MWFunction::callArray( 'Message::newFallbackSequence', $args ); |
500 | 502 | } |
501 | 503 | |
502 | 504 | /** |
— | — | @@ -1994,6 +1996,13 @@ |
1995 | 1997 | } |
1996 | 1998 | |
1997 | 1999 | /** |
| 2000 | + * Check if we are running under HipHop |
| 2001 | + */ |
| 2002 | +function wfIsHipHop() { |
| 2003 | + return function_exists( 'hphp_thread_set_warmup_enabled' ); |
| 2004 | +} |
| 2005 | + |
| 2006 | +/** |
1998 | 2007 | * Swap two variables |
1999 | 2008 | */ |
2000 | 2009 | function swap( &$x, &$y ) { |
— | — | @@ -2781,7 +2790,17 @@ |
2782 | 2791 | global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain, |
2783 | 2792 | $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler; |
2784 | 2793 | if( $wgSessionsInMemcached ) { |
2785 | | - require_once( 'MemcachedSessions.php' ); |
| 2794 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 2795 | + require_once( 'MemcachedSessions.php' ); |
| 2796 | + } |
| 2797 | + session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', |
| 2798 | + 'memsess_write', 'memsess_destroy', 'memsess_gc' ); |
| 2799 | + |
| 2800 | + // It's necessary to register a shutdown function to call session_write_close(), |
| 2801 | + // because by the time the request shutdown function for the session module is |
| 2802 | + // called, $wgMemc has already been destroyed. Shutdown functions registered |
| 2803 | + // this way are called before object destruction. |
| 2804 | + register_shutdown_function( 'memsess_write_close' ); |
2786 | 2805 | } elseif( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) { |
2787 | 2806 | # Only set this if $wgSessionHandler isn't null and session.save_handler |
2788 | 2807 | # hasn't already been set to the desired value (that causes errors) |
Index: trunk/phase3/includes/Namespace.php |
— | — | @@ -5,35 +5,6 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | /** |
9 | | - * Definitions of the NS_ constants are in Defines.php |
10 | | - * @private |
11 | | - */ |
12 | | -$wgCanonicalNamespaceNames = array( |
13 | | - NS_MEDIA => 'Media', |
14 | | - NS_SPECIAL => 'Special', |
15 | | - NS_TALK => 'Talk', |
16 | | - NS_USER => 'User', |
17 | | - NS_USER_TALK => 'User_talk', |
18 | | - NS_PROJECT => 'Project', |
19 | | - NS_PROJECT_TALK => 'Project_talk', |
20 | | - NS_FILE => 'File', |
21 | | - NS_FILE_TALK => 'File_talk', |
22 | | - NS_MEDIAWIKI => 'MediaWiki', |
23 | | - NS_MEDIAWIKI_TALK => 'MediaWiki_talk', |
24 | | - NS_TEMPLATE => 'Template', |
25 | | - NS_TEMPLATE_TALK => 'Template_talk', |
26 | | - NS_HELP => 'Help', |
27 | | - NS_HELP_TALK => 'Help_talk', |
28 | | - NS_CATEGORY => 'Category', |
29 | | - NS_CATEGORY_TALK => 'Category_talk', |
30 | | -); |
31 | | - |
32 | | -/// @todo UGLY UGLY |
33 | | -if( is_array( $wgExtraNamespaces ) ) { |
34 | | - $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces; |
35 | | -} |
36 | | - |
37 | | -/** |
38 | 9 | * This is a utility class with only static functions |
39 | 10 | * for dealing with namespaces that encodes all the |
40 | 11 | * "magic" behaviors of them based on index. The textual |
Index: trunk/phase3/includes/ExternalStore.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | |
69 | 69 | $class = 'ExternalStore' . ucfirst( $proto ); |
70 | 70 | /* Any custom modules should be added to $wgAutoLoadClasses for on-demand loading */ |
71 | | - if( !class_exists( $class ) ) { |
| 71 | + if( !MWInit::classExists( $class ) ) { |
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
Index: trunk/phase3/includes/normal/UtfNormalUtil.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | * @ingroup UtfNormal |
27 | 27 | */ |
28 | 28 | |
29 | | -require_once dirname(__FILE__).'/UtfNormalDefines.php'; |
| 29 | +require_once( MWInit::compiledPath( 'includes/normal/UtfNormalDefines.php' ) ); |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Return UTF-8 sequence for a given Unicode code point. |
Index: trunk/phase3/includes/normal/UtfNormalDefines.php |
— | — | @@ -1,7 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Some constant definitions for the unicode normalization module |
| 4 | + * Some constant definitions for the unicode normalization module. |
5 | 5 | * |
| 6 | + * Note: these constants must all be resolvable at compile time by HipHop, |
| 7 | + * since this file will not be executed during request startup for a compiled |
| 8 | + * MediaWiki. |
| 9 | + * |
6 | 10 | * @file |
7 | 11 | * @ingroup UtfNormal |
8 | 12 | */ |
Index: trunk/phase3/includes/WebStart.php |
— | — | @@ -8,6 +8,20 @@ |
9 | 9 | * @file |
10 | 10 | */ |
11 | 11 | |
| 12 | +/** |
| 13 | + * Detect compiled mode by looking for a function that only exists if compiled |
| 14 | + * in. Note that we can't use function_exists(), because it is terribly broken |
| 15 | + * under HipHop due to the "volatile" feature. |
| 16 | + */ |
| 17 | +function wfDetectCompiledMode() { |
| 18 | + try { |
| 19 | + $r = new ReflectionFunction( 'wfHipHopCompilerVersion' ); |
| 20 | + } catch ( ReflectionException $e ) { |
| 21 | + $r = false; |
| 22 | + } |
| 23 | + return $r !== false; |
| 24 | +} |
| 25 | + |
12 | 26 | # Protect against register_globals |
13 | 27 | # This must be done before any globals are set by the code |
14 | 28 | if ( ini_get( 'register_globals' ) ) { |
— | — | @@ -67,40 +81,51 @@ |
68 | 82 | $IP = realpath( '.' ); |
69 | 83 | } |
70 | 84 | |
71 | | - |
72 | | -# Start profiler |
73 | | -if( file_exists("$IP/StartProfiler.php") ) { |
74 | | - require_once( "$IP/StartProfiler.php" ); |
75 | | -} else { |
76 | | - require_once( "$IP/includes/ProfilerStub.php" ); |
| 85 | +if ( wfDetectCompiledMode() ) { |
| 86 | + define( 'MW_COMPILED', 1 ); |
77 | 87 | } |
78 | | -wfProfileIn( 'WebStart.php-conf' ); |
79 | 88 | |
80 | | -# Load up some global defines. |
81 | | -require_once( "$IP/includes/Defines.php" ); |
| 89 | +if ( !defined( 'MW_COMPILED' ) ) { |
| 90 | + # Get MWInit class |
| 91 | + require_once( "$IP/includes/Init.php" ); |
82 | 92 | |
83 | | -# Check for PHP 5 |
84 | | -if ( !function_exists( 'version_compare' ) |
85 | | - || version_compare( phpversion(), '5.0.0' ) < 0 |
86 | | -) { |
87 | | - define( 'MW_PHP4', '1' ); |
88 | | - require( "$IP/includes/DefaultSettings.php" ); |
89 | | - require( "$IP/includes/templates/PHP4.php" ); |
90 | | - exit; |
| 93 | + # Start profiler |
| 94 | + # FIXME: rewrite wfProfileIn/wfProfileOut so that they can work in compiled mode |
| 95 | + if ( file_exists( "$IP/StartProfiler.php" ) ) { |
| 96 | + require_once( "$IP/StartProfiler.php" ); |
| 97 | + } else { |
| 98 | + require_once( "$IP/includes/ProfilerStub.php" ); |
| 99 | + } |
| 100 | + |
| 101 | + # Load up some global defines. |
| 102 | + require_once( "$IP/includes/Defines.php" ); |
| 103 | + |
| 104 | + # Check for PHP 5 |
| 105 | + if ( !function_exists( 'version_compare' ) |
| 106 | + || version_compare( phpversion(), '5.0.0' ) < 0 |
| 107 | + ) { |
| 108 | + define( 'MW_PHP4', '1' ); |
| 109 | + require( "$IP/includes/DefaultSettings.php" ); |
| 110 | + require( "$IP/includes/templates/PHP4.php" ); |
| 111 | + exit; |
| 112 | + } |
| 113 | + |
| 114 | + # Start the autoloader, so that extensions can derive classes from core files |
| 115 | + require_once( "$IP/includes/AutoLoader.php" ); |
91 | 116 | } |
92 | 117 | |
93 | | -# Start the autoloader, so that extensions can derive classes from core files |
94 | | -require_once( "$IP/includes/AutoLoader.php" ); |
| 118 | +wfProfileIn( 'WebStart.php-conf' ); |
| 119 | + |
95 | 120 | # Load default settings |
96 | | -require_once( "$IP/includes/DefaultSettings.php" ); |
| 121 | +require_once( MWInit::compiledPath( "includes/DefaultSettings.php" ) ); |
97 | 122 | |
98 | 123 | if ( defined( 'MW_CONFIG_CALLBACK' ) ) { |
99 | 124 | # Use a callback function to configure MediaWiki |
100 | 125 | MWFunction::call( MW_CONFIG_CALLBACK ); |
101 | | - |
102 | 126 | } else { |
103 | | - if ( !defined('MW_CONFIG_FILE') ) |
104 | | - define('MW_CONFIG_FILE', "$IP/LocalSettings.php"); |
| 127 | + if ( !defined( 'MW_CONFIG_FILE' ) ) { |
| 128 | + define('MW_CONFIG_FILE', MWInit::interpretedPath( 'LocalSettings.php' ) ); |
| 129 | + } |
105 | 130 | |
106 | 131 | # LocalSettings.php is the per site customization file. If it does not exist |
107 | 132 | # the wiki installer needs to be launched or the generated file uploaded to |
— | — | @@ -115,7 +140,7 @@ |
116 | 141 | } |
117 | 142 | |
118 | 143 | if ( $wgEnableSelenium ) { |
119 | | - require_once( "$IP/includes/SeleniumWebSettings.php" ); |
| 144 | + require_once( MWInit::compiledPath( "includes/SeleniumWebSettings.php" ) ); |
120 | 145 | } |
121 | 146 | |
122 | 147 | wfProfileOut( 'WebStart.php-conf' ); |
— | — | @@ -126,12 +151,14 @@ |
127 | 152 | # that would cause us to potentially mix gzip and non-gzip output, creating a |
128 | 153 | # big mess. |
129 | 154 | if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ob_get_level() == 0 ) { |
130 | | - require_once( "$IP/includes/OutputHandler.php" ); |
| 155 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 156 | + require_once( "$IP/includes/OutputHandler.php" ); |
| 157 | + } |
131 | 158 | ob_start( 'wfOutputHandler' ); |
132 | 159 | } |
133 | 160 | wfProfileOut( 'WebStart.php-ob_start' ); |
134 | 161 | |
135 | 162 | if ( !defined( 'MW_NO_SETUP' ) ) { |
136 | | - require_once( "$IP/includes/Setup.php" ); |
| 163 | + require_once( MWInit::compiledPath( "includes/Setup.php" ) ); |
137 | 164 | } |
138 | 165 | |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -138,24 +138,28 @@ |
139 | 139 | $className = "Skin{$skinName}"; |
140 | 140 | |
141 | 141 | # Grab the skin class and initialise it. |
142 | | - if ( !class_exists( $className ) ) { |
143 | | - // Preload base classes to work around APC/PHP5 bug |
144 | | - $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; |
| 142 | + if ( !MWInit::classExists( $className ) ) { |
145 | 143 | |
146 | | - if ( file_exists( $deps ) ) { |
147 | | - include_once( $deps ); |
| 144 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 145 | + // Preload base classes to work around APC/PHP5 bug |
| 146 | + $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; |
| 147 | + if ( file_exists( $deps ) ) { |
| 148 | + include_once( $deps ); |
| 149 | + } |
| 150 | + require_once( "{$wgStyleDirectory}/{$skinName}.php" ); |
148 | 151 | } |
149 | | - require_once( "{$wgStyleDirectory}/{$skinName}.php" ); |
150 | 152 | |
151 | 153 | # Check if we got if not failback to default skin |
152 | | - if ( !class_exists( $className ) ) { |
| 154 | + if ( !MWInit::classExists( $className ) ) { |
153 | 155 | # DO NOT die if the class isn't found. This breaks maintenance |
154 | 156 | # scripts and can cause a user account to be unrecoverable |
155 | 157 | # except by SQL manipulation if a previously valid skin name |
156 | 158 | # is no longer valid. |
157 | 159 | wfDebug( "Skin class does not exist: $className\n" ); |
158 | 160 | $className = 'SkinVector'; |
159 | | - require_once( "{$wgStyleDirectory}/Vector.php" ); |
| 161 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 162 | + require_once( "{$wgStyleDirectory}/Vector.php" ); |
| 163 | + } |
160 | 164 | } |
161 | 165 | } |
162 | 166 | $skin = new $className; |
Index: trunk/phase3/includes/MimeMagic.php |
— | — | @@ -117,14 +117,6 @@ |
118 | 118 | END_STRING |
119 | 119 | ); |
120 | 120 | |
121 | | -// Note: because this file is possibly included by a function, |
122 | | -// we need to access the global scope explicitely! |
123 | | -global $wgLoadFileinfoExtension; |
124 | | - |
125 | | -if ( $wgLoadFileinfoExtension ) { |
126 | | - wfDl( 'fileinfo' ); |
127 | | -} |
128 | | - |
129 | 121 | /** |
130 | 122 | * Implements functions related to mime types such as detection and mapping to |
131 | 123 | * file extension. |
— | — | @@ -160,6 +152,10 @@ |
161 | 153 | */ |
162 | 154 | private static $instance; |
163 | 155 | |
| 156 | + /** True if the fileinfo extension has been loaded |
| 157 | + */ |
| 158 | + private static $extensionLoaded = false; |
| 159 | + |
164 | 160 | /** Initializes the MimeMagic object. This is called by MimeMagic::singleton(). |
165 | 161 | * |
166 | 162 | * This constructor parses the mime.types and mime.info files and build internal mappings. |
— | — | @@ -169,7 +165,7 @@ |
170 | 166 | * --- load mime.types --- |
171 | 167 | */ |
172 | 168 | |
173 | | - global $wgMimeTypeFile, $IP; |
| 169 | + global $wgMimeTypeFile, $IP, $wgLoadFileinfoExtension; |
174 | 170 | |
175 | 171 | $types = MM_WELL_KNOWN_MIME_TYPES; |
176 | 172 | |
— | — | @@ -177,6 +173,11 @@ |
178 | 174 | $wgMimeTypeFile = "$IP/$wgMimeTypeFile"; |
179 | 175 | } |
180 | 176 | |
| 177 | + if ( $wgLoadFileinfoExtension && !self::$extensionLoaded ) { |
| 178 | + self::$extensionLoaded = true; |
| 179 | + wfDl( 'fileinfo' ); |
| 180 | + } |
| 181 | + |
181 | 182 | if ( $wgMimeTypeFile ) { |
182 | 183 | if ( is_file( $wgMimeTypeFile ) and is_readable( $wgMimeTypeFile ) ) { |
183 | 184 | wfDebug( __METHOD__.": loading mime types from $wgMimeTypeFile\n" ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -28,7 +28,9 @@ |
29 | 29 | |
30 | 30 | # Create a site configuration object. Not used for much in a default install |
31 | 31 | if ( !defined( 'MW_PHP4' ) ) { |
32 | | - require_once( "$IP/includes/SiteConfiguration.php" ); |
| 32 | + if ( !defined( 'MW_COMPILED' ) ) { |
| 33 | + require_once( "$IP/includes/SiteConfiguration.php" ); |
| 34 | + } |
33 | 35 | $wgConf = new SiteConfiguration; |
34 | 36 | } |
35 | 37 | /** @endcond */ |