MediaWiki REL1_28
PHPVersionCheck.php
Go to the documentation of this file.
1<?php
32function wfEntryPointCheck( $entryPoint ) {
33 $mwVersion = '1.28';
34 $minimumVersionPHP = '5.5.9';
35 $phpVersion = PHP_VERSION;
36
37 if ( !function_exists( 'version_compare' )
38 || version_compare( $phpVersion, $minimumVersionPHP ) < 0
39 ) {
40 wfPHPVersionError( $entryPoint, $mwVersion, $minimumVersionPHP, $phpVersion );
41 }
42
43 // @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound
44 if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) {
45 // @codingStandardsIgnoreEnd
46 wfMissingVendorError( $entryPoint, $mwVersion );
47 }
48
49 // List of functions and their associated PHP extension to check for
50 // @codingStandardsIgnoreStart Generic.Arrays.DisallowLongArraySyntax
52 'mb_substr' => 'mbstring',
53 'utf8_encode' => 'xml',
54 'ctype_digit' => 'ctype',
55 'json_decode' => 'json',
56 'iconv' => 'iconv',
57 );
58 // List of extensions we're missing
59 $missingExtensions = array();
60 // @codingStandardsIgnoreEnd
61
62 foreach ( $extensions as $function => $extension ) {
63 if ( !function_exists( $function ) ) {
64 $missingExtensions[] = $extension;
65 }
66 }
67
68 if ( $missingExtensions ) {
69 wfMissingExtensions( $entryPoint, $mwVersion, $missingExtensions );
70 }
71}
72
93function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $longHtml ) {
94 $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
95
96 if ( $type == 'cli' ) {
97 $finalOutput = $longText;
98 } else {
99 header( "$protocol 500 MediaWiki configuration Error" );
100 // Don't cache error pages! They cause no end of trouble...
101 header( 'Cache-control: none' );
102 header( 'Pragma: no-cache' );
103
104 if ( $type == 'index.php' || $type == 'mw-config/index.php' ) {
105 $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
106 if ( $type == 'mw-config/index.php' ) {
107 $dirname = dirname( $pathinfo['dirname'] );
108 } else {
109 $dirname = $pathinfo['dirname'];
110 }
111 $encLogo = htmlspecialchars(
112 str_replace( '//', '/', $dirname . '/' ) .
113 'resources/assets/mediawiki.png'
114 );
115 $shortHtml = htmlspecialchars( $shortText );
116
117 header( 'Content-type: text/html; charset=UTF-8' );
118
119 $finalOutput = <<<HTML
120<!DOCTYPE html>
121<html lang="en" dir="ltr">
122 <head>
123 <meta charset="UTF-8" />
124 <title>MediaWiki {$mwVersion}</title>
125 <style media='screen'>
126 body {
127 color: #000;
128 background-color: #fff;
129 font-family: sans-serif;
130 padding: 2em;
131 text-align: center;
132 }
133 p, img, h1, h2, ul {
134 text-align: left;
135 margin: 0.5em 0 1em;
136 }
137 h1 {
138 font-size: 120%;
139 }
140 h2 {
141 font-size: 110%;
142 }
143 </style>
144 </head>
145 <body>
146 <img src="{$encLogo}" alt='The MediaWiki logo' />
147 <h1>MediaWiki {$mwVersion} internal error</h1>
148 <div class='error'>
149 <p>
150 {$shortHtml}
151 </p>
152 <h2>{$title}</h2>
153 <p>
154 {$longHtml}
155 </p>
156 </div>
157 </body>
158</html>
159HTML;
160 // Handle everything that's not index.php
161 } else {
162 // So nothing thinks this is JS or CSS
163 $finalOutput = ( $type == 'load.php' ) ? "/* $shortText */" : $shortText;
164 }
165 }
166 echo "$finalOutput\n";
167 die( 1 );
168}
169
178function wfPHPVersionError( $type, $mwVersion, $minimumVersionPHP, $phpVersion ) {
179 $shortText = "MediaWiki $mwVersion requires at least "
180 . "PHP version $minimumVersionPHP, you are using PHP $phpVersion.";
181
182 $longText = "Error: You might be using on older PHP version. \n"
183 . "MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher.\n\n"
184 . "Check if you have a newer php executable with a different name, such as php5.\n\n";
185
186 $longHtml = <<<HTML
187 Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
188 PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive
189 security or bugfix updates.
190 </p>
191 <p>
192 If for some reason you are unable to upgrade your PHP version, you will need to
193 <a href="https://www.mediawiki.org/wiki/Download">download</a> an older version
194 of MediaWiki from our website. See our
195 <a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
196 for details of which versions are compatible with prior versions of PHP.
197HTML;
198 wfGenericError( $type, $mwVersion, 'Supported PHP versions', $shortText, $longText, $longHtml );
199}
200
207function wfMissingVendorError( $type, $mwVersion ) {
208 $shortText = "Installing some external dependencies (e.g. via composer) is required.";
209
210 $longText = "Error: You are missing some external dependencies. \n"
211 . "MediaWiki now also has some external dependencies that need to be installed\n"
212 . "via composer or from a separate git repo. Please see\n"
213 . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
214 . "for help on installing the required components.";
215
216 // @codingStandardsIgnoreStart Generic.Files.LineLength
217 $longHtml = <<<HTML
218 MediaWiki now also has some external dependencies that need to be installed via
219 composer or from a separate git repo. Please see
220 <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
221 for help on installing the required components.
222HTML;
223 // @codingStandardsIgnoreEnd
224
225 wfGenericError( $type, $mwVersion, 'External dependencies', $shortText, $longText, $longHtml );
226}
227
235function wfMissingExtensions( $type, $mwVersion, $missingExts ) {
236 $shortText = "Installing some PHP extensions is required.";
237
238 $missingExtText = '';
239 $missingExtHtml = '';
240 $baseUrl = 'https://secure.php.net';
241 foreach ( $missingExts as $ext ) {
242 $missingExtText .= " * $ext <$baseUrl/$ext>\n";
243 $missingExtHtml .= "<li><b>$ext</b> "
244 . "(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
245 }
246
247 $cliText = "Error: Missing one or more required components of PHP.\n"
248 . "You are missing a required extension to PHP that MediaWiki needs.\n"
249 . "Please install:\n" . $missingExtText;
250
251 $longHtml = <<<HTML
252 You are missing a required extension to PHP that MediaWiki
253 requires to run. Please install:
254 <ul>
255 $missingExtHtml
256 </ul>
257HTML;
258
259 wfGenericError( $type, $mwVersion, 'Required components', $shortText,
260 $cliText, $longHtml );
261}
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed by
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
shown</td >< td > a href
in the sidebar</td >< td > font color
</td >< td > &</td >< td > t want your writing to be edited mercilessly and redistributed at will
wfPHPVersionError( $type, $mwVersion, $minimumVersionPHP, $phpVersion)
Display an error for the minimum PHP version requirement not being satisfied.
wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $longHtml)
Display something vaguely comprehensible in the event of a totally unrecoverable error.
wfMissingVendorError( $type, $mwVersion)
Display an error for the vendor/autoload.php file not being found.
wfMissingExtensions( $type, $mwVersion, $missingExts)
Display an error for a PHP extension not existing.
wfEntryPointCheck( $entryPoint)
Check php version and that external dependencies are installed, and display an informative error if e...
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by etc *css user provided css code *text plain text In PHP
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their please see
Definition database.txt:18
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these updates(as a Java servelet could)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition deferred.txt:13
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition design.txt:79
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition globals.txt:10
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor' $rcid is used in generating this variable which contains information about the new such as the revision s whether the revision was marked as a minor edit or not
Definition hooks.txt:1207
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
Definition hooks.txt:2543
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
Definition hooks.txt:88
$extensions
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition LICENSE.txt:11
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Prior to version
A helper class for throttling authentication attempts.
title
Bar style