66 public function open( $server,
$user, $password, $dbName ) {
67 # Test for driver support, to avoid suppressed fatal error
68 if ( !function_exists(
'sqlsrv_connect' ) ) {
71 "Microsoft SQL Server Native (sqlsrv) functions missing.
72 You can download the driver from: http://go.microsoft.com/fwlink/?LinkId=123470\n"
78 # e.g. the class is being loaded
79 if ( !strlen(
$user ) ) {
84 $this->mServer = $server;
87 $this->mPassword = $password;
88 $this->mDBname = $dbName;
93 $connectionInfo[
'Database'] = $dbName;
98 if ( !$wgDBWindowsAuthentication ) {
99 $connectionInfo[
'UID'] =
$user;
100 $connectionInfo[
'PWD'] = $password;
103 MediaWiki\suppressWarnings();
104 $this->mConn = sqlsrv_connect( $server, $connectionInfo );
105 MediaWiki\restoreWarnings();
107 if ( $this->mConn ===
false ) {
111 $this->mOpened =
true;
122 return sqlsrv_close( $this->mConn );
134 } elseif (
$result ===
true ) {
138 return new MssqlResultWrapper( $this,
$result );
158 if ( preg_match(
'/\bLIMIT\s*/i', $sql ) ) {
164 if ( preg_match(
'#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql,
$matches ) ) {
166 $sql = str_replace(
$matches[0],
"DATEDIFF(s,CONVERT(datetime,'1/1/1970'),", $sql );
175 if ( $this->mScrollableCursor ) {
176 $scrollArr = [
'Scrollable' => SQLSRV_CURSOR_STATIC ];
181 if ( $this->mPrepareStatements ) {
183 $stmt = sqlsrv_prepare( $this->mConn, $sql, [], $scrollArr );
186 $stmt = sqlsrv_query( $this->mConn, $sql, [], $scrollArr );
193 if ( $this->mIgnoreDupKeyErrors ) {
196 $ignoreErrors[] =
'2601';
197 $ignoreErrors[] =
'2627';
198 $ignoreErrors[] =
'3621';
202 $errors = sqlsrv_errors();
205 foreach ( $errors
as $err ) {
206 if ( !in_array( $err[
'code'], $ignoreErrors ) ) {
217 $this->mAffectedRows = sqlsrv_rows_affected( $stmt );
227 sqlsrv_free_stmt(
$res );
236 return $res->fetchObject();
244 return $res->fetchRow();
258 if (
$ret ===
false ) {
261 $ret = (int)sqlsrv_has_rows(
$res );
276 return sqlsrv_num_fields(
$res );
289 return sqlsrv_field_metadata(
$res )[$n][
'Name'];
306 return $res->seek( $row );
314 $retErrors = sqlsrv_errors( SQLSRV_ERR_ALL );
315 if ( $retErrors != null ) {
316 foreach ( $retErrors
as $arrError ) {
320 $strRet =
"No errors found";
331 return '[SQLSTATE ' . $err[
'SQLSTATE'] .
'][Error Code ' . $err[
'code'] .
']' . $err[
'message'];
338 $err = sqlsrv_errors( SQLSRV_ERR_ALL );
339 if ( $err !== null && isset( $err[0] ) ) {
340 return $err[0][
'code'];
375 if ( isset(
$options[
'EXPLAIN'] ) ) {
377 $this->mScrollableCursor =
false;
378 $this->mPrepareStatements =
false;
379 $this->
query(
"SET SHOWPLAN_ALL ON" );
381 $this->
query(
"SET SHOWPLAN_ALL OFF" );
383 if ( isset(
$options[
'FOR COUNT'] ) ) {
385 $this->
query(
"SET SHOWPLAN_ALL OFF" );
389 'COUNT(*) AS EstimateRows',
398 $this->mScrollableCursor =
true;
399 $this->mPrepareStatements =
true;
403 $this->mScrollableCursor =
true;
404 $this->mPrepareStatements =
true;
426 if ( isset(
$options[
'EXPLAIN'] ) ) {
433 if ( strpos( $sql,
'MAX(' ) !==
false || strpos( $sql,
'MIN(' ) !==
false ) {
435 if ( is_array( $table ) ) {
436 foreach ( $table
as $t ) {
443 foreach ( $bitColumns
as $col => $info ) {
445 "MAX({$col})" =>
"MAX(CAST({$col} AS tinyint))",
446 "MIN({$col})" =>
"MIN(CAST({$col} AS tinyint))",
448 $sql = str_replace( array_keys( $replace ), array_values( $replace ), $sql );
455 public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
458 $this->mScrollableCursor =
false;
460 parent::deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname );
462 $this->mScrollableCursor =
true;
465 $this->mScrollableCursor =
true;
468 public function delete( $table, $conds,
$fname = __METHOD__ ) {
469 $this->mScrollableCursor =
false;
471 parent::delete( $table, $conds, $fname );
473 $this->mScrollableCursor =
true;
476 $this->mScrollableCursor =
true;
504 if ( isset( $row[
'EstimateRows'] ) ) {
505 $rows = (int)$row[
'EstimateRows'];
520 public function indexInfo( $table, $index, $fname = __METHOD__ ) {
521 # This does not return the same info as MYSQL would, but that's OK
522 # because MediaWiki never uses the returned value except to check for
523 # the existance of indexes.
524 $sql =
"sp_helpindex '" . $this->
tableName( $table ) .
"'";
532 foreach (
$res as $row ) {
533 if ( $row->index_name == $index ) {
534 $row->Non_unique = !stristr( $row->index_description,
"unique" );
535 $cols = explode(
", ", $row->index_keys );
536 foreach ( $cols
as $col ) {
537 $row->Column_name = trim( $col );
540 } elseif ( $index ==
'PRIMARY' && stristr( $row->index_description,
'PRIMARY' ) ) {
541 $row->Non_unique = 0;
542 $cols = explode(
", ", $row->index_keys );
543 foreach ( $cols
as $col ) {
544 $row->Column_name = trim( $col );
568 public function insert( $table, $arrToInsert, $fname = __METHOD__,
$options = [] ) {
569 # No rows to insert, easy just return now
570 if ( !count( $arrToInsert ) ) {
580 if ( !( isset( $arrToInsert[0] ) && is_array( $arrToInsert[0] ) ) ) {
581 $arrToInsert = [ 0 => $arrToInsert ];
587 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
588 $tableRaw = array_pop( $tableRawArr );
590 "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS " .
591 "WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'"
593 if (
$res && sqlsrv_has_rows(
$res ) ) {
595 $identityArr = sqlsrv_fetch_array(
$res, SQLSRV_FETCH_ASSOC );
596 $identity = array_pop( $identityArr );
598 sqlsrv_free_stmt(
$res );
605 if ( in_array(
'IGNORE',
$options ) ) {
607 $this->mIgnoreDupKeyErrors =
true;
610 foreach ( $arrToInsert
as $a ) {
615 $identityClause =
'';
620 foreach ( $a
as $k => $v ) {
621 if ( $k == $identity ) {
622 if ( !is_null( $v ) ) {
625 $sqlPre =
"SET IDENTITY_INSERT $table ON;";
626 $sqlPost =
";SET IDENTITY_INSERT $table OFF;";
636 $identityClause =
"OUTPUT INSERTED.$identity ";
639 $keys = array_keys( $a );
642 $sql = $sqlPre .
'INSERT ' . implode(
' ',
$options ) .
643 " INTO $table (" . implode(
',',
$keys ) .
") $identityClause VALUES (";
647 if ( isset( $binaryColumns[$key] ) ) {
655 if ( is_null(
$value ) ) {
657 } elseif ( is_array(
$value ) || is_object(
$value ) ) {
667 $sql .=
')' . $sqlPost;
670 $this->mScrollableCursor =
false;
674 $this->mScrollableCursor =
true;
675 $this->mIgnoreDupKeyErrors =
false;
678 $this->mScrollableCursor =
true;
680 if ( !is_null( $identity ) ) {
682 $row =
$ret->fetchObject();
683 if ( is_object( $row ) ) {
684 $this->mInsertId = $row->$identity;
688 if ( $this->mAffectedRows == -1 ) {
689 $this->mAffectedRows = 1;
694 $this->mIgnoreDupKeyErrors =
false;
714 $insertOptions = [], $selectOptions = []
716 $this->mScrollableCursor =
false;
718 $ret = parent::nativeInsertSelect(
728 $this->mScrollableCursor =
true;
731 $this->mScrollableCursor =
true;
765 $opts = $this->makeUpdateOptions(
$options );
766 $sql =
"UPDATE $opts $table SET " . $this->
makeList( $values,
LIST_SET, $binaryColumns );
768 if ( $conds !== [] && $conds !==
'*' ) {
772 $this->mScrollableCursor =
false;
774 $this->
query( $sql );
776 $this->mScrollableCursor =
true;
779 $this->mScrollableCursor =
true;
800 if ( !is_array( $a ) ) {
801 throw new DBUnexpectedError( $this, __METHOD__ .
' called with incorrect parameters' );
808 foreach ( array_keys( $a )
as $field ) {
809 if ( !isset( $binaryColumns[$field] ) ) {
813 if ( is_array( $a[$field] ) ) {
814 foreach ( $a[$field]
as &$v ) {
819 $a[$field] =
new MssqlBlob( $a[$field] );
824 return parent::makeList( $a, $mode );
834 $sql =
"SELECT CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.Columns
835 WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$field'";
839 if ( strtolower( $row[
'DATA_TYPE'] ) !=
'text' ) {
840 $size = $row[
'CHARACTER_MAXIMUM_LENGTH'];
857 if ( $offset ===
false || $offset == 0 ) {
858 if ( strpos( $sql,
"SELECT" ) ===
false ) {
859 return "TOP {$limit} " . $sql;
861 return preg_replace(
'/\bSELECT(\s+DISTINCT)?\b/Dsi',
862 'SELECT$1 TOP ' .
$limit, $sql, 1 );
866 $select = $orderby = [];
867 $s1 = preg_match(
'#SELECT\s+(.+?)\s+FROM#Dis', $sql, $select );
868 $s2 = preg_match(
'#(ORDER BY\s+.+?)(\s*FOR XML .*)?$#Dis', $sql, $orderby );
869 $overOrder = $postOrder =
'';
870 $first = $offset + 1;
873 $sub2 =
'sub_' . ( $this->mSubqueryId + 1 );
874 $this->mSubqueryId += 2;
877 throw new DBUnexpectedError( $this,
"Attempting to LIMIT a non-SELECT query\n" );
881 $overOrder =
'ORDER BY (SELECT 1)';
883 if ( !isset( $orderby[2] ) || !$orderby[2] ) {
885 $sql = str_replace( $orderby[1],
'', $sql );
887 $overOrder = $orderby[1];
888 $postOrder =
' ' . $overOrder;
890 $sql =
"SELECT {$select[1]}
892 SELECT ROW_NUMBER() OVER({$overOrder}) AS rowNumber, *
893 FROM ({$sql}) {$sub1}
895 WHERE rowNumber BETWEEN {$first} AND {$last}{$postOrder}";
913 $pattern =
'/\bLIMIT\s+((([0-9]+)\s*,\s*)?([0-9]+)(\s+OFFSET\s+([0-9]+))?)/i';
914 if ( preg_match( $pattern, $sql,
$matches ) ) {
919 $sql = str_replace(
$matches[0],
'', $sql );
921 return $this->
limitResult( $sql, $row_count, $offset );
931 return "[{{int:version-db-mssql-url}} MS SQL Server]";
938 $server_info = sqlsrv_server_info( $this->mConn );
940 if ( isset( $server_info[
'SQLServerVersion'] ) ) {
941 $version = $server_info[
'SQLServerVersion'];
953 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
955 if ( $db !==
false ) {
957 wfDebug(
"Attempting to call tableExists on a remote table" );
961 if ( $schema ===
false ) {
966 $res = $this->
query(
"SELECT 1 FROM INFORMATION_SCHEMA.TABLES
967 WHERE TABLE_TYPE = 'BASE TABLE'
968 AND TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table'" );
970 if (
$res->numRows() ) {
984 public function fieldExists( $table, $field, $fname = __METHOD__ ) {
985 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
987 if ( $db !==
false ) {
989 wfDebug(
"Attempting to call fieldExists on a remote table" );
993 $res = $this->
query(
"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
994 WHERE TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" );
996 if (
$res->numRows() ) {
1004 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
1006 if ( $db !==
false ) {
1008 wfDebug(
"Attempting to call fieldInfo on a remote table" );
1012 $res = $this->
query(
"SELECT * FROM INFORMATION_SCHEMA.COLUMNS
1013 WHERE TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" );
1015 $meta =
$res->fetchRow();
1027 protected function doBegin( $fname = __METHOD__ ) {
1028 sqlsrv_begin_transaction( $this->mConn );
1029 $this->mTrxLevel = 1;
1037 sqlsrv_commit( $this->mConn );
1038 $this->mTrxLevel = 0;
1047 sqlsrv_rollback( $this->mConn );
1048 $this->mTrxLevel = 0;
1060 if ( strlen( $identifier ) == 0 ) {
1063 if ( strlen( $identifier ) > 128 ) {
1066 if ( ( strpos( $identifier,
'[' ) !==
false )
1067 || ( strpos( $identifier,
']' ) !==
false )
1074 return "[$identifier]";
1084 return str_replace(
"'",
"''",
$s );
1094 } elseif (
$s instanceof
Blob ) {
1097 $blob =
new MssqlBlob(
$s->fetch() );
1098 return $blob->fetch();
1100 if ( is_bool(
$s ) ) {
1103 return parent::addQuotes(
$s );
1113 return '[' .
$s .
']';
1121 return strlen(
$name ) &&
$name[0] ==
'[' && substr(
$name, -1, 1 ) ==
']';
1131 return addcslashes(
$s,
'\%_[]^' );
1150 return parent::buildLike(
$params ) .
" ESCAPE '\' ";
1159 $this->mDBname = $db;
1160 $this->
query(
"USE $db" );
1178 if ( is_numeric( $key ) ) {
1179 $noKeyOptions[$option] =
true;
1183 $tailOpts .= $this->makeGroupByWithHaving(
$options );
1185 $tailOpts .= $this->makeOrderBy(
$options );
1187 if ( isset( $noKeyOptions[
'DISTINCT'] ) || isset( $noKeyOptions[
'DISTINCTROW'] ) ) {
1188 $startOpts .=
'DISTINCT';
1191 if ( isset( $noKeyOptions[
'FOR XML'] ) ) {
1193 $tailOpts .=
" FOR XML PATH('')";
1197 return [ $startOpts,
'', $tailOpts,
'',
'' ];
1213 return implode(
' + ', $stringList );
1237 $this->mSubqueryId++;
1239 $delimLen = strlen( $delim );
1240 $fld =
"{$field} + {$this->addQuotes( $delim )}";
1241 $sql =
"(SELECT LEFT({$field}, LEN({$field}) - {$delimLen}) FROM ("
1242 . $this->
selectSQLText( $table, $fld, $conds, null, [
'FOR XML' ], $join_conds )
1243 .
") {$gcsq} ({$field}))";
1255 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
1256 $tableRaw = array_pop( $tableRawArr );
1258 if ( $this->mBinaryColumnCache === null ) {
1262 return isset( $this->mBinaryColumnCache[$tableRaw] )
1263 ? $this->mBinaryColumnCache[$tableRaw]
1272 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
1273 $tableRaw = array_pop( $tableRawArr );
1275 if ( $this->mBitColumnCache === null ) {
1279 return isset( $this->mBitColumnCache[$tableRaw] )
1280 ? $this->mBitColumnCache[$tableRaw]
1285 $res = $this->
select(
'INFORMATION_SCHEMA.COLUMNS',
'*',
1287 'TABLE_CATALOG' => $this->mDBname,
1288 'TABLE_SCHEMA' => $this->mSchema,
1289 'DATA_TYPE' => [
'varbinary',
'binary',
'image',
'bit' ]
1292 $this->mBinaryColumnCache = [];
1293 $this->mBitColumnCache = [];
1294 foreach (
$res as $row ) {
1295 if ( $row->DATA_TYPE ==
'bit' ) {
1296 $this->mBitColumnCache[$row->TABLE_NAME][$row->COLUMN_NAME] = $row;
1298 $this->mBinaryColumnCache[$row->TABLE_NAME][$row->COLUMN_NAME] = $row;
1309 # Replace reserved words with better ones
1326 if ( $format ==
'split' ) {
1329 $table = explode(
'.', $table );
1330 while ( count( $table ) < 3 ) {
1331 array_unshift( $table,
false );
1344 public function dropTable( $tableName, $fName = __METHOD__ ) {
1345 if ( !$this->
tableExists( $tableName, $fName ) ) {
1350 $sql =
"DROP TABLE " . $this->
tableName( $tableName );
1352 return $this->
query( $sql, $fName );
fieldExists($table, $field, $fname=__METHOD__)
Query whether a given column exists in the mediawiki schema.
getBinaryColumns($table)
Returns an associative array for fields that are of type varbinary, binary, or image $table can be ei...
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
doCommit($fname=__METHOD__)
End a transaction.
Utility classThis allows us to distinguish a blob from a normal string and an array of strings...
realTableName($name, $format= 'quoted')
call this instead of tableName() in the updater when renaming tables
buildGroupConcatField($delim, $table, $field, $conds= '', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
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 & $ret
doBegin($fname=__METHOD__)
Begin a transaction, committing any previously open transaction.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
doRollback($fname=__METHOD__)
Rollback a transaction.
unionSupportsOrderAndLimit()
$wgDBmwschema
Mediawiki schema.
isQuotedIdentifier($name)
when a variable name is used in a it is silently declared as a new local masking the global
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for tableName() and addQuotes().You will need both of them.------------------------------------------------------------------------Basic query optimisation------------------------------------------------------------------------MediaWiki developers who need to write DB queries should have some understanding of databases and the performance issues associated with them.Patches containing unacceptably slow features will not be accepted.Unindexed queries are generally not welcome in MediaWiki
$wgDBWindowsAuthentication
Use Windows Authentication instead of $wgDBuser / $wgDBpassword for MS SQL Server.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED!Use HtmlPageLinkRendererBegin instead.Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
escapeIdentifier($identifier)
Escapes a identifier for use inm SQL.
estimateRowCount($table, $vars= '*', $conds= '', $fname=__METHOD__, $options=[])
Estimate rows in dataset Returns estimated count, based on SHOWPLAN_ALL output This is not necessaril...
scrollableCursor($value=null)
Called in the installer and updater.
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 $options
indexInfo($table, $index, $fname=__METHOD__)
Returns information about an index If errors are explicitly ignored, returns NULL on failure...
nativeInsertSelect($destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[])
INSERT SELECT wrapper $varMap must be an associative array of the form [ 'dest1' => 'source1'...
fieldInfo($table, $field)
tableExists($table, $fname=__METHOD__)
deleteJoin($delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
makeSelectOptions($options)
makeList($a, $mode=LIST_COMMA, $binaryColumns=[])
Makes an encoded list of strings from an array.
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
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
escapeLikeInternal($s)
MS SQL supports more pattern operators than other databases (ex: [,],^)
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
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
tableName($name, $format= 'quoted')
insertId()
This must be called after nextSequenceVal.
LimitToTopN($sql)
If there is a limit clause, parse it, strip it, and pass the remaining SQL through limitResult() with...
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
$wgDBport
Database port number (for PostgreSQL and Microsoft SQL Server).
insert($table, $arrToInsert, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
limitResult($sql, $limit, $offset=false)
Construct a LIMIT query with optional offset This is used for query pages.
closeConnection()
Closes a database connection, if it is open Returns success, true if already closed.
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 $limit
select($table, $vars, $conds= '', $fname=__METHOD__, $options=[], $join_conds=[])
SELECT wrapper.
Result wrapper for grabbing data queried from an IDatabase object.
open($server, $user, $password, $dbName)
Usually aborts on failure.
dropTable($tableName, $fName=__METHOD__)
Delete a table.
buildLike()
MS SQL requires specifying the escape character used in a LIKE query or using Square brackets to surr...
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
update($table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
selectSQLText($table, $vars, $conds= '', $fname=__METHOD__, $options=[], $join_conds=[])
SELECT wrapper.
prepareStatements($value=null)
Called in the installer and updater.
ignoreErrors(array $value=null)
Called in the installer and updater.
Allows to change the fields on the form that will be generated $name
textFieldSize($table, $field)