62 'table' =>
'revision_comment_temp',
63 'pk' =>
'revcomment_rev',
64 'field' =>
'revcomment_comment_id',
67 'img_description' => [
68 'table' =>
'image_comment_temp',
69 'pk' =>
'imgcomment_name',
70 'field' =>
'imgcomment_description_id',
71 'joinPK' =>
'img_name',
133 $fields[
"{$this->key}_data"] =
'NULL';
134 $fields[
"{$this->key}_cid"] =
'NULL';
139 if ( isset( self::$tempTables[$this->
key] ) ) {
140 $fields[
"{$this->key}_pk"] = self::$tempTables[
$this->key][
'joinPK'];
142 $fields[
"{$this->key}_id"] =
"{$this->key}_id";
161 if ( $this->joinCache ===
null ) {
168 $fields[
"{$this->key}_data"] =
'NULL';
169 $fields[
"{$this->key}_cid"] =
'NULL';
171 $join = $this->stage ===
MIGRATION_NEW ?
'JOIN' :
'LEFT JOIN';
173 if ( isset( self::$tempTables[$this->
key] ) ) {
175 $alias =
"temp_$this->key";
177 $joins[$alias] = [ $join,
"{$alias}.{$t['pk']} = {$t['joinPK']}" ];
178 $joinField =
"{$alias}.{$t['field']}";
180 $joinField =
"{$this->key}_id";
183 $alias =
"comment_$this->key";
185 $joins[$alias] = [ $join,
"{$alias}.comment_id = {$joinField}" ];
188 $fields[
"{$this->key}_text"] =
"{$alias}.comment_text";
190 $fields[
"{$this->key}_text"] =
"COALESCE( {$alias}.comment_text, $this->key )";
192 $fields[
"{$this->key}_data"] =
"{$alias}.comment_data";
193 $fields[
"{$this->key}_cid"] =
"{$alias}.comment_id";
219 if ( array_key_exists(
"{$key}_text", $row ) && array_key_exists(
"{$key}_data", $row ) ) {
220 $cid = isset( $row[
"{$key}_cid"] ) ? $row[
"{$key}_cid"] :
null;
221 $text = $row[
"{$key}_text"];
222 $data = $row[
"{$key}_data"];
226 wfLogWarning(
"Using deprecated fallback handling for comment $key" );
229 wfLogWarning(
"Missing {$key}_text and {$key}_data fields in row with MIGRATION_OLD" );
234 if ( isset( self::$tempTables[
$key] ) ) {
235 if ( array_key_exists(
"{$key}_pk", $row ) ) {
237 throw new InvalidArgumentException(
238 "\$row does not contain fields needed for comment $key and getComment(), but "
239 .
"does have fields for getCommentLegacy()"
242 $t = self::$tempTables[
$key];
243 $id = $row[
"{$key}_pk"];
244 $row2 = $db->selectRow(
245 [
$t[
'table'],
'comment' ],
246 [
'comment_id',
'comment_text',
'comment_data' ],
250 [
'comment' => [
'JOIN', [
"comment_id = {$t['field']}" ] ] ]
253 wfLogWarning(
"Using deprecated fallback handling for comment $key" );
254 $row2 = (
object)[
'comment_text' => $row[
$key],
'comment_data' =>
null ];
256 throw new InvalidArgumentException(
"\$row does not contain fields needed for comment $key" );
259 if ( array_key_exists(
"{$key}_id", $row ) ) {
261 throw new InvalidArgumentException(
262 "\$row does not contain fields needed for comment $key and getComment(), but "
263 .
"does have fields for getCommentLegacy()"
266 $id = $row[
"{$key}_id"];
267 $row2 = $db->selectRow(
269 [
'comment_id',
'comment_text',
'comment_data' ],
270 [
'comment_id' => $id ],
274 wfLogWarning(
"Using deprecated fallback handling for comment $key" );
275 $row2 = (
object)[
'comment_text' => $row[
$key],
'comment_data' =>
null ];
277 throw new InvalidArgumentException(
"\$row does not contain fields needed for comment $key" );
282 $cid = $row2->comment_id;
283 $text = $row2->comment_text;
284 $data = $row2->comment_data;
285 } elseif ( $this->stage <
MIGRATION_NEW && array_key_exists(
"{$key}_old", $row ) ) {
287 $text = $row[
"{$key}_old"];
300 if ( $data !==
null ) {
301 $data = FormatJson::decode( $data );
302 if ( !is_object( $data ) ) {
304 wfLogWarning(
"Invalid JSON object in comment: $data" );
308 $data = (
array)$data;
309 if ( isset( $data[
'_message'] ) ) {
311 ->setInterfaceMessageFlag(
true );
313 if ( !empty( $data[
'_null'] ) ) {
316 foreach ( $data
as $k => $v ) {
317 if ( substr( $k, 0, 1 ) ===
'_' ) {
386 # Truncate comment in a Unicode-sensitive manner
387 $comment->text = $this->lang->truncate( $comment->text, self::MAX_COMMENT_LENGTH );
388 if ( mb_strlen( $comment->text,
'UTF-8' ) > self::COMMENT_CHARACTER_LIMIT ) {
389 $ellipsis =
wfMessage(
'ellipsis' )->inLanguage( $this->lang )->escaped();
390 if ( mb_strlen( $ellipsis ) >= self::COMMENT_CHARACTER_LIMIT ) {
394 $maxLength = self::COMMENT_CHARACTER_LIMIT - mb_strlen( $ellipsis,
'UTF-8' );
395 $comment->text = mb_substr( $comment->text, 0, $maxLength,
'UTF-8' ) . $ellipsis;
399 $dbData = $comment->data;
400 if ( !$comment->message instanceof
RawMessage ) {
401 if ( $dbData ===
null ) {
402 $dbData = [
'_null' =>
true ];
406 if ( $dbData !==
null ) {
407 $dbData = FormatJson::encode( (
object)$dbData,
false, FormatJson::ALL_OK );
408 $len = strlen( $dbData );
409 if ( $len > self::MAX_DATA_LENGTH ) {
411 throw new OverflowException(
"Comment data is too long ($len bytes, maximum is $max)" );
415 $hash =
self::hash( $comment->text, $dbData );
420 'comment_hash' => $hash,
421 'comment_text' => $comment->text,
422 'comment_data' => $dbData,
426 if ( !$comment->id ) {
430 'comment_hash' => $hash,
431 'comment_text' => $comment->text,
432 'comment_data' => $dbData,
457 $fields[
$this->key] = $this->lang->truncate( $comment->text, 255 );
461 if ( isset( self::$tempTables[$this->
key] ) ) {
464 $commentId = $comment->id;
465 $callback =
function ( $id )
use ( $dbw, $commentId,
$t, $func ) {
470 $t[
'field'] => $commentId,
476 $fields[
"{$this->key}_id"] = $comment->id;
480 return [ $fields, $callback ];
494 if ( isset( self::$tempTables[$this->
key] ) ) {
495 throw new InvalidArgumentException(
"Must use insertWithTempTable() for $this->key" );
519 if ( isset( self::$formerTempTables[$this->
key] ) ) {
520 wfDeprecated( __METHOD__ .
" for $this->key", self::$formerTempTables[$this->key] );
521 } elseif ( !isset( self::$tempTables[$this->key] ) ) {
522 throw new InvalidArgumentException(
"Must use insert() for $this->key" );
527 $callback =
function () {
531 return [ $fields, $callback ];
543 if ( $param instanceof
Message ) {
559 $key = array_shift( $data );
560 foreach ( $data
as &$param ) {
561 if ( is_object( $param ) ) {
562 $param = (
array)$param;
564 if ( is_array( $param ) && count( $param ) === 1 && isset( $param[
'message'] ) ) {
577 public static function hash( $text, $data ) {
578 $hash = crc32( $text ) ^ crc32( (
string)$data );
582 if ( $hash >= 0x80000000 ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
int $wgCommentTableSchemaMigrationStage
Comment table schema migration stage.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
The Message class provides methods which fulfil two basic services:
getParams()
Returns the message parameters.
getKey()
Returns the message key.
Variant of the Message class.
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 list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
when a variable name is used in a it is silently declared as a new local masking the global
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 in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
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 will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
const MIGRATION_WRITE_BOTH
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
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