36 switch ( $moduleName ) {
38 $this->
table =
'pagelinks';
40 $this->titlesParam =
'titles';
41 $this->helpUrl =
'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Links';
44 $this->
table =
'templatelinks';
46 $this->titlesParam =
'templates';
47 $this->helpUrl =
'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Templates';
53 parent::__construct(
$query, $moduleName, $this->prefix );
65 $this->
run( $resultPageSet );
71 private function run( $resultPageSet =
null ) {
72 if ( $this->
getPageSet()->getGoodTitleCount() == 0 ) {
79 'pl_from' => $this->prefix .
'_from',
80 'pl_namespace' => $this->prefix .
'_namespace',
81 'pl_title' => $this->prefix .
'_title'
89 if (
$params[$this->titlesParam] ) {
91 $filterNS =
$params[
'namespace'] ? array_flip(
$params[
'namespace'] ) :
false;
98 } elseif ( !$filterNS || isset( $filterNS[
$title->getNamespace()] ) ) {
102 $cond = $lb->constructSet( $this->prefix, $this->
getDB() );
105 $multiNS = count( $lb->data ) !== 1;
106 $multiTitle = count( array_merge( ...$lb->data ) ) !== 1;
111 } elseif (
$params[
'namespace'] ) {
113 $multiNS =
$params[
'namespace'] ===
null || count(
$params[
'namespace'] ) !== 1;
116 if ( !is_null(
$params[
'continue'] ) ) {
117 $cont = explode(
'|',
$params[
'continue'] );
119 $op =
$params[
'dir'] ==
'descending' ?
'<' :
'>';
120 $plfrom = intval( $cont[0] );
121 $plns = intval( $cont[1] );
122 $pltitle = $this->
getDB()->addQuotes( $cont[2] );
124 "{$this->prefix}_from $op $plfrom OR " .
125 "({$this->prefix}_from = $plfrom AND " .
126 "({$this->prefix}_namespace $op $plns OR " .
127 "({$this->prefix}_namespace = $plns AND " .
128 "{$this->prefix}_title $op= $pltitle)))"
132 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
139 if ( count( $this->
getPageSet()->getGoodTitles() ) != 1 ) {
140 $order[] = $this->prefix .
'_from' .
$sort;
143 $order[] = $this->prefix .
'_namespace' .
$sort;
146 $order[] = $this->prefix .
'_title' .
$sort;
155 if ( is_null( $resultPageSet ) ) {
157 foreach (
$res as $row ) {
158 if ( ++$count >
$params[
'limit'] ) {
162 "{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
170 "{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
177 foreach (
$res as $row ) {
178 if ( ++$count >
$params[
'limit'] ) {
182 "{$row->pl_from}|{$row->pl_namespace}|{$row->pl_title}" );
185 $titles[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
187 $resultPageSet->populateFromTitles(
$titles );
208 $this->titlesParam => [
226 "action=query&prop={$name}&titles=Main%20Page"
227 =>
"apihelp-{$path}-example-simple",
228 "action=query&generator={$name}&titles=Main%20Page&prop=info"
229 =>
"apihelp-{$path}-example-generator",
230 "action=query&prop={$name}&titles=Main%20Page&{$this->prefix}namespace=2|10"
231 =>
"apihelp-{$path}-example-namespaces",
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModulePath()
Get the path to this module.
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
addFields( $value)
Add a set of fields to select to the internal array.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getPageSet()
Get the PageSet object to work on.
A query module to list all wiki links on a given set of pages.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName)
getExamplesMessages()
Returns usage examples for this module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
executeGenerator( $resultPageSet)
Execute this module as a generator.
run( $resultPageSet=null)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
This is the main query class.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
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 select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
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 so it s not worth the trouble Since there is a job queue in the jobs table
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
namespace and then decline to actually register it file or subcat img or subcat $title
Allows to change the fields on the form that will be generated $name
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
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
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles