2006-09-26 01:44:13 +00:00
|
|
|
<?php
|
2010-02-26 13:18:56 +00:00
|
|
|
/**
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
|
2006-09-26 01:44:13 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-09-26 01:44:13 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2006-09-26 01:44:13 +00:00
|
|
|
*/
|
2017-01-10 09:51:50 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2006-09-26 01:44:13 +00:00
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2007-05-20 23:31:44 +00:00
|
|
|
* A query action to return meta information about the wiki site.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-09-26 01:44:13 +00:00
|
|
|
class ApiQuerySiteinfo extends ApiQueryBase {
|
|
|
|
|
|
2014-03-25 17:22:11 +00:00
|
|
|
public function __construct( ApiQuery $query, $moduleName ) {
|
2010-02-26 13:18:56 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'si' );
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-27 05:13:48 +00:00
|
|
|
public function execute() {
|
2007-06-14 05:18:58 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2016-02-17 09:09:32 +00:00
|
|
|
$done = [];
|
2011-08-17 22:28:08 +00:00
|
|
|
$fit = false;
|
2010-02-26 13:18:56 +00:00
|
|
|
foreach ( $params['prop'] as $p ) {
|
|
|
|
|
switch ( $p ) {
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'general':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendGeneralInfo( $p );
|
2006-09-26 01:44:13 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'namespaces':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendNamespaces( $p );
|
2007-06-14 05:18:58 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'namespacealiases':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendNamespaceAliases( $p );
|
2008-02-03 19:29:59 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'specialpagealiases':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendSpecialPageAliases( $p );
|
2008-03-28 12:47:21 +00:00
|
|
|
break;
|
2008-10-26 13:57:19 +00:00
|
|
|
case 'magicwords':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendMagicWords( $p );
|
2008-10-26 13:57:19 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'interwikimap':
|
2018-07-31 16:15:17 +00:00
|
|
|
$fit = $this->appendInterwikiMap( $p, $params['filteriw'] );
|
2006-09-26 01:44:13 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'dbrepllag':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
|
2007-07-07 04:53:07 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'statistics':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendStatistics( $p );
|
2007-08-09 12:39:41 +00:00
|
|
|
break;
|
2008-07-04 09:21:11 +00:00
|
|
|
case 'usergroups':
|
2009-07-12 12:10:27 +00:00
|
|
|
$fit = $this->appendUserGroups( $p, $params['numberingroup'] );
|
2008-04-03 14:33:36 +00:00
|
|
|
break;
|
2015-02-12 21:09:23 +00:00
|
|
|
case 'libraries':
|
|
|
|
|
$fit = $this->appendInstalledLibraries( $p );
|
|
|
|
|
break;
|
2008-12-14 22:06:32 +00:00
|
|
|
case 'extensions':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendExtensions( $p );
|
2008-12-14 22:06:32 +00:00
|
|
|
break;
|
2009-01-14 22:15:50 +00:00
|
|
|
case 'fileextensions':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendFileExtensions( $p );
|
2009-01-14 22:15:50 +00:00
|
|
|
break;
|
2009-01-31 15:56:52 +00:00
|
|
|
case 'rightsinfo':
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$fit = $this->appendRightsInfo( $p );
|
2009-01-31 15:56:52 +00:00
|
|
|
break;
|
2014-02-06 15:30:00 +00:00
|
|
|
case 'restrictions':
|
|
|
|
|
$fit = $this->appendRestrictions( $p );
|
|
|
|
|
break;
|
2009-06-07 18:20:01 +00:00
|
|
|
case 'languages':
|
|
|
|
|
$fit = $this->appendLanguages( $p );
|
|
|
|
|
break;
|
2017-02-28 20:56:01 +00:00
|
|
|
case 'languagevariants':
|
|
|
|
|
$fit = $this->appendLanguageVariants( $p );
|
|
|
|
|
break;
|
2011-01-23 02:05:26 +00:00
|
|
|
case 'skins':
|
|
|
|
|
$fit = $this->appendSkins( $p );
|
|
|
|
|
break;
|
2011-04-29 23:02:10 +00:00
|
|
|
case 'extensiontags':
|
|
|
|
|
$fit = $this->appendExtensionTags( $p );
|
|
|
|
|
break;
|
|
|
|
|
case 'functionhooks':
|
|
|
|
|
$fit = $this->appendFunctionHooks( $p );
|
|
|
|
|
break;
|
2011-04-29 23:33:38 +00:00
|
|
|
case 'showhooks':
|
|
|
|
|
$fit = $this->appendSubscribedHooks( $p );
|
|
|
|
|
break;
|
2012-06-02 20:34:18 +00:00
|
|
|
case 'variables':
|
|
|
|
|
$fit = $this->appendVariables( $p );
|
|
|
|
|
break;
|
2013-02-14 23:06:15 +00:00
|
|
|
case 'protocols':
|
|
|
|
|
$fit = $this->appendProtocols( $p );
|
|
|
|
|
break;
|
2013-12-09 18:08:39 +00:00
|
|
|
case 'defaultoptions':
|
|
|
|
|
$fit = $this->appendDefaultOptions( $p );
|
|
|
|
|
break;
|
2016-05-05 15:20:05 +00:00
|
|
|
case 'uploaddialog':
|
|
|
|
|
$fit = $this->appendUploadDialog( $p );
|
|
|
|
|
break;
|
2010-02-26 13:18:56 +00:00
|
|
|
default:
|
2018-07-31 16:15:17 +00:00
|
|
|
ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" ); // @codeCoverageIgnore
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !$fit ) {
|
2010-01-23 22:52:40 +00:00
|
|
|
// Abuse siprop as a query-continue parameter
|
|
|
|
|
// and set it to all unprocessed props
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'prop', implode( '|',
|
2013-11-14 13:00:02 +00:00
|
|
|
array_diff( $params['prop'], $done ) ) );
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$done[] = $p;
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendGeneralInfo( $property ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$config = $this->getConfig();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2010-06-19 11:49:26 +00:00
|
|
|
$mainPage = Title::newMainPage();
|
2008-02-24 18:36:16 +00:00
|
|
|
$data['mainpage'] = $mainPage->getPrefixedText();
|
2013-03-27 13:36:05 +00:00
|
|
|
$data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT );
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['sitename'] = $config->get( 'Sitename' );
|
2019-10-04 21:08:59 +00:00
|
|
|
$data['mainpageisdomainroot'] = (bool)$config->get( 'MainPageIsDomainRoot' );
|
2014-01-15 16:08:19 +00:00
|
|
|
|
|
|
|
|
// wgLogo can either be a relative or an absolute path
|
|
|
|
|
// make sure we always return an absolute path
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['logo'] = wfExpandUrl( $config->get( 'Logo' ), PROTO_RELATIVE );
|
|
|
|
|
|
|
|
|
|
$data['generator'] = "MediaWiki {$config->get( 'Version' )}";
|
2014-01-15 16:08:19 +00:00
|
|
|
|
2014-07-09 23:46:35 +00:00
|
|
|
$data['phpversion'] = PHP_VERSION;
|
2013-02-04 03:01:17 +00:00
|
|
|
$data['phpsapi'] = PHP_SAPI;
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['dbtype'] = $config->get( 'DBtype' );
|
2009-05-02 13:35:20 +00:00
|
|
|
$data['dbversion'] = $this->getDB()->getServerVersion();
|
2007-10-06 02:30:00 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$allowFrom = [ '' ];
|
2013-07-11 17:56:35 +00:00
|
|
|
$allowException = true;
|
2014-01-24 02:51:11 +00:00
|
|
|
if ( !$config->get( 'AllowExternalImages' ) ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$data['imagewhitelistenabled'] = (bool)$config->get( 'EnableImageWhitelist' );
|
2014-01-24 02:51:11 +00:00
|
|
|
$allowFrom = $config->get( 'AllowExternalImagesFrom' );
|
2013-07-11 17:56:35 +00:00
|
|
|
$allowException = !empty( $allowFrom );
|
|
|
|
|
}
|
|
|
|
|
if ( $allowException ) {
|
2013-08-31 16:36:02 +00:00
|
|
|
$data['externalimages'] = (array)$allowFrom;
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['externalimages'], 'prefix' );
|
2013-07-11 17:56:35 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-16 19:00:07 +00:00
|
|
|
$data['langconversion'] = !$config->get( 'DisableLangConversion' );
|
|
|
|
|
$data['titleconversion'] = !$config->get( 'DisableTitleConversion' );
|
2013-02-20 19:15:35 +00:00
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
|
|
|
|
if ( $contLang->linkPrefixExtension() ) {
|
|
|
|
|
$linkPrefixCharset = $contLang->linkPrefixCharset();
|
Remove linkprefix message, add $linkPrefixCharset
The existing "linkprefix" message is unlikely to be accurately
customized by message translators (as shown by the fact that, of the 10
distinct customizations prior to Iaa7eaa44 (which made them even more
complicated), 3 were broken or entirely ineffective, 1 was half
ineffective, and 2 more seem to have included the Latin-1 Supplement by
accident) or by local wiki admins. So, like linktrail before it, let's
move it out of the system messages and into a separate language
variable.
At the same time, let's make it a simple character set (like
$wgLegalTitleChars) rather than a complicated regular expression. The
complicated regex now lives in the parser.
This also adjusts the output of the API's action=query&meta=siteinfo and
adds an accessor parallel to the linkTrail accessor to Language.
Note the following changes that are not simply extracting the existing
charset from the linkprefix message for $linkPrefixCharset:
* The En message matched all non-ASCII UTF-8 characters by matching the
component bytes (\\x80-\\xff). The new character set is equivalent.
* Various languages were identical to En and so have no $linkPrefixCharset
set. These are: Ary Az Ce Ga Id Ka Kiu Km Ltg Mk Ms Ne Nn Ro Roa_tara Sc Si
Sr_ec Sr_el Tl Tt_cyrl Tt_latn Ug_arab War
* Cu, Uk, and Udm are changed to match any number of „ or « in the prefix.
* Cv tried to include "«" that was redundant to the range \\x80-\\xff
(see En comment). This was removed.
* Diq was entirely bogus, and so was removed.
* Gu included many additional UTF-8 characters that are redundant to the
range \\x80-\\xff (see En comment). These were removed, and the
resulting character set is equivalent to En.
* Mt has been broken since it was introduced in r37242. The charset used is
equivalent to the broken regex.
Bug: 56031
Change-Id: I3369851b33113fc118a1bace38f3ac310cdd9725
2013-10-23 18:06:19 +00:00
|
|
|
$data['linkprefixcharset'] = $linkPrefixCharset;
|
2014-08-13 17:39:07 +00:00
|
|
|
// For backwards compatibility
|
Remove linkprefix message, add $linkPrefixCharset
The existing "linkprefix" message is unlikely to be accurately
customized by message translators (as shown by the fact that, of the 10
distinct customizations prior to Iaa7eaa44 (which made them even more
complicated), 3 were broken or entirely ineffective, 1 was half
ineffective, and 2 more seem to have included the Latin-1 Supplement by
accident) or by local wiki admins. So, like linktrail before it, let's
move it out of the system messages and into a separate language
variable.
At the same time, let's make it a simple character set (like
$wgLegalTitleChars) rather than a complicated regular expression. The
complicated regex now lives in the parser.
This also adjusts the output of the API's action=query&meta=siteinfo and
adds an accessor parallel to the linkTrail accessor to Language.
Note the following changes that are not simply extracting the existing
charset from the linkprefix message for $linkPrefixCharset:
* The En message matched all non-ASCII UTF-8 characters by matching the
component bytes (\\x80-\\xff). The new character set is equivalent.
* Various languages were identical to En and so have no $linkPrefixCharset
set. These are: Ary Az Ce Ga Id Ka Kiu Km Ltg Mk Ms Ne Nn Ro Roa_tara Sc Si
Sr_ec Sr_el Tl Tt_cyrl Tt_latn Ug_arab War
* Cu, Uk, and Udm are changed to match any number of „ or « in the prefix.
* Cv tried to include "«" that was redundant to the range \\x80-\\xff
(see En comment). This was removed.
* Diq was entirely bogus, and so was removed.
* Gu included many additional UTF-8 characters that are redundant to the
range \\x80-\\xff (see En comment). These were removed, and the
resulting character set is equivalent to En.
* Mt has been broken since it was introduced in r37242. The charset used is
equivalent to the broken regex.
Bug: 56031
Change-Id: I3369851b33113fc118a1bace38f3ac310cdd9725
2013-10-23 18:06:19 +00:00
|
|
|
$data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
|
2013-03-05 23:32:52 +00:00
|
|
|
} else {
|
Remove linkprefix message, add $linkPrefixCharset
The existing "linkprefix" message is unlikely to be accurately
customized by message translators (as shown by the fact that, of the 10
distinct customizations prior to Iaa7eaa44 (which made them even more
complicated), 3 were broken or entirely ineffective, 1 was half
ineffective, and 2 more seem to have included the Latin-1 Supplement by
accident) or by local wiki admins. So, like linktrail before it, let's
move it out of the system messages and into a separate language
variable.
At the same time, let's make it a simple character set (like
$wgLegalTitleChars) rather than a complicated regular expression. The
complicated regex now lives in the parser.
This also adjusts the output of the API's action=query&meta=siteinfo and
adds an accessor parallel to the linkTrail accessor to Language.
Note the following changes that are not simply extracting the existing
charset from the linkprefix message for $linkPrefixCharset:
* The En message matched all non-ASCII UTF-8 characters by matching the
component bytes (\\x80-\\xff). The new character set is equivalent.
* Various languages were identical to En and so have no $linkPrefixCharset
set. These are: Ary Az Ce Ga Id Ka Kiu Km Ltg Mk Ms Ne Nn Ro Roa_tara Sc Si
Sr_ec Sr_el Tl Tt_cyrl Tt_latn Ug_arab War
* Cu, Uk, and Udm are changed to match any number of „ or « in the prefix.
* Cv tried to include "«" that was redundant to the range \\x80-\\xff
(see En comment). This was removed.
* Diq was entirely bogus, and so was removed.
* Gu included many additional UTF-8 characters that are redundant to the
range \\x80-\\xff (see En comment). These were removed, and the
resulting character set is equivalent to En.
* Mt has been broken since it was introduced in r37242. The charset used is
equivalent to the broken regex.
Bug: 56031
Change-Id: I3369851b33113fc118a1bace38f3ac310cdd9725
2013-10-23 18:06:19 +00:00
|
|
|
$data['linkprefixcharset'] = '';
|
2013-03-05 23:32:52 +00:00
|
|
|
$data['linkprefix'] = '';
|
2013-02-22 00:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
$linktrail = $contLang->linkTrail();
|
2015-01-16 19:00:07 +00:00
|
|
|
$data['linktrail'] = $linktrail ?: '';
|
2013-02-22 00:15:15 +00:00
|
|
|
|
2014-11-13 17:35:48 +00:00
|
|
|
$data['legaltitlechars'] = Title::legalChars();
|
2015-05-12 20:39:38 +00:00
|
|
|
$data['invalidusernamechars'] = $config->get( 'InvalidUsernameCharacters' );
|
2014-11-13 17:35:48 +00:00
|
|
|
|
2016-06-26 12:38:17 +00:00
|
|
|
$data['allunicodefixes'] = (bool)$config->get( 'AllUnicodeFixes' );
|
|
|
|
|
$data['fixarabicunicode'] = (bool)$config->get( 'FixArabicUnicode' );
|
|
|
|
|
$data['fixmalayalamunicode'] = (bool)$config->get( 'FixMalayalamUnicode' );
|
|
|
|
|
|
2014-01-24 02:51:11 +00:00
|
|
|
global $IP;
|
|
|
|
|
$git = SpecialVersion::getGitHeadSha1( $IP );
|
2012-06-29 20:04:42 +00:00
|
|
|
if ( $git ) {
|
|
|
|
|
$data['git-hash'] = $git;
|
2014-05-06 19:28:22 +00:00
|
|
|
$data['git-branch'] =
|
|
|
|
|
SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2007-10-06 02:30:00 +00:00
|
|
|
|
2009-04-30 05:25:35 +00:00
|
|
|
// 'case-insensitive' option is reserved for future
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['case'] = $config->get( 'CapitalLinks' ) ? 'first-letter' : 'case-sensitive';
|
|
|
|
|
$data['lang'] = $config->get( 'LanguageCode' );
|
2011-08-05 13:34:22 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$fallbacks = [];
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach ( $contLang->getFallbackLanguages() as $code ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$fallbacks[] = [ 'code' => $code ];
|
2011-08-05 13:34:22 +00:00
|
|
|
}
|
2011-08-18 16:41:07 +00:00
|
|
|
$data['fallback'] = $fallbacks;
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['fallback'], 'lang' );
|
2011-08-05 13:34:22 +00:00
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
if ( $contLang->hasVariants() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$variants = [];
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach ( $contLang->getVariants() as $code ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$variants[] = [
|
2013-12-27 21:25:34 +00:00
|
|
|
'code' => $code,
|
2018-07-29 12:24:54 +00:00
|
|
|
'name' => $contLang->getVariantname( $code ),
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-05-05 17:29:48 +00:00
|
|
|
}
|
|
|
|
|
$data['variants'] = $variants;
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['variants'], 'lang' );
|
2012-05-05 17:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
$data['rtl'] = $contLang->isRTL();
|
|
|
|
|
$data['fallback8bitEncoding'] = $contLang->fallback8bitEncoding();
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2015-01-16 19:00:07 +00:00
|
|
|
$data['readonly'] = wfReadOnly();
|
|
|
|
|
if ( $data['readonly'] ) {
|
2009-05-02 14:24:11 +00:00
|
|
|
$data['readonlyreason'] = wfReadOnlyReason();
|
|
|
|
|
}
|
2017-11-20 23:50:22 +00:00
|
|
|
$data['writeapi'] = true; // Deprecated since MW 1.32
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2016-06-25 16:43:23 +00:00
|
|
|
$data['maxarticlesize'] = $config->get( 'MaxArticleSize' ) * 1024;
|
|
|
|
|
|
2014-01-24 02:51:11 +00:00
|
|
|
$tz = $config->get( 'Localtimezone' );
|
|
|
|
|
$offset = $config->get( 'LocalTZoffset' );
|
2008-07-04 09:21:11 +00:00
|
|
|
$data['timezone'] = $tz;
|
2019-02-25 00:38:33 +00:00
|
|
|
$data['timeoffset'] = (int)$offset;
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['articlepath'] = $config->get( 'ArticlePath' );
|
|
|
|
|
$data['scriptpath'] = $config->get( 'ScriptPath' );
|
|
|
|
|
$data['script'] = $config->get( 'Script' );
|
2014-07-19 21:12:10 +00:00
|
|
|
$data['variantarticlepath'] = $config->get( 'VariantArticlePath' );
|
2015-01-16 19:00:07 +00:00
|
|
|
$data[ApiResult::META_BC_BOOLS][] = 'variantarticlepath';
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['server'] = $config->get( 'Server' );
|
|
|
|
|
$data['servername'] = $config->get( 'ServerName' );
|
2019-03-29 21:30:21 +00:00
|
|
|
$data['wikiid'] = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
|
2010-01-24 10:05:19 +00:00
|
|
|
$data['time'] = wfTimestamp( TS_ISO_8601, time() );
|
2008-07-04 09:21:11 +00:00
|
|
|
|
2015-01-16 19:00:07 +00:00
|
|
|
$data['misermode'] = (bool)$config->get( 'MiserMode' );
|
2011-04-23 11:12:31 +00:00
|
|
|
|
2015-12-09 17:07:38 +00:00
|
|
|
$data['uploadsenabled'] = UploadBase::isEnabled();
|
2012-02-10 14:27:50 +00:00
|
|
|
$data['maxuploadsize'] = UploadBase::getMaxUploadSize();
|
2016-06-08 18:21:42 +00:00
|
|
|
$data['minuploadchunksize'] = (int)$config->get( 'MinUploadChunkSize' );
|
2012-02-10 14:27:50 +00:00
|
|
|
|
2016-11-22 21:34:54 +00:00
|
|
|
$data['galleryoptions'] = $config->get( 'GalleryOptions' );
|
|
|
|
|
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['thumblimits'] = $config->get( 'ThumbLimits' );
|
2015-01-16 19:00:07 +00:00
|
|
|
ApiResult::setArrayType( $data['thumblimits'], 'BCassoc' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['thumblimits'], 'limit' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$data['imagelimits'] = [];
|
2015-01-16 19:00:07 +00:00
|
|
|
ApiResult::setArrayType( $data['imagelimits'], 'BCassoc' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['imagelimits'], 'limit' );
|
2014-01-24 02:51:11 +00:00
|
|
|
foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data['imagelimits'][$k] = [ 'width' => $limit[0], 'height' => $limit[1] ];
|
2013-12-09 18:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-20 19:41:41 +00:00
|
|
|
$favicon = $config->get( 'Favicon' );
|
|
|
|
|
if ( !empty( $favicon ) ) {
|
2014-01-15 16:08:19 +00:00
|
|
|
// wgFavicon can either be a relative or an absolute path
|
|
|
|
|
// make sure we always return an absolute path
|
2014-01-24 02:51:11 +00:00
|
|
|
$data['favicon'] = wfExpandUrl( $favicon, PROTO_RELATIVE );
|
2014-01-13 11:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-08 18:21:42 +00:00
|
|
|
$data['centralidlookupprovider'] = $config->get( 'CentralIdLookupProvider' );
|
|
|
|
|
$providerIds = array_keys( $config->get( 'CentralIdLookupProviders' ) );
|
2015-11-19 20:57:12 +00:00
|
|
|
$data['allcentralidlookupproviders'] = $providerIds;
|
|
|
|
|
|
2016-06-08 18:21:04 +00:00
|
|
|
$data['interwikimagic'] = (bool)$config->get( 'InterwikiMagic' );
|
2016-09-13 22:19:24 +00:00
|
|
|
$data['magiclinks'] = $config->get( 'EnableMagicLinks' );
|
2016-06-08 18:21:04 +00:00
|
|
|
|
2017-11-22 17:02:26 +00:00
|
|
|
$data['categorycollation'] = $config->get( 'CategoryCollation' );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'APIQuerySiteInfoGeneralInfo', [ $this, &$data ] );
|
2011-03-20 13:31:22 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2007-06-14 05:18:58 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendNamespaces( $property ) {
|
2019-08-29 21:34:00 +00:00
|
|
|
$nsProtection = $this->getConfig()->get( 'NamespaceProtection' );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [
|
2015-01-16 19:00:07 +00:00
|
|
|
ApiResult::META_TYPE => 'assoc',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2018-08-05 17:58:51 +00:00
|
|
|
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach (
|
|
|
|
|
MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
|
|
|
|
|
as $ns => $title
|
|
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data[$ns] = [
|
2019-02-25 00:38:33 +00:00
|
|
|
'id' => (int)$ns,
|
2018-08-05 17:58:51 +00:00
|
|
|
'case' => $nsInfo->isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setContentValue( $data[$ns], 'name', $title );
|
2018-08-05 17:58:51 +00:00
|
|
|
$canonical = $nsInfo->getCanonicalName( $ns );
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2018-08-05 17:58:51 +00:00
|
|
|
$data[$ns]['subpages'] = $nsInfo->hasSubpages( $ns );
|
2010-02-26 13:18:56 +00:00
|
|
|
|
|
|
|
|
if ( $canonical ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-05 17:58:51 +00:00
|
|
|
$data[$ns]['content'] = $nsInfo->isContent( $ns );
|
|
|
|
|
$data[$ns]['nonincludable'] = $nsInfo->isNonincludable( $ns );
|
2012-12-13 20:05:15 +00:00
|
|
|
|
2019-08-29 21:34:00 +00:00
|
|
|
if ( isset( $nsProtection[$ns] ) ) {
|
|
|
|
|
if ( is_array( $nsProtection[$ns] ) ) {
|
|
|
|
|
$specificNs = implode( "|", array_filter( $nsProtection[$ns] ) );
|
|
|
|
|
} elseif ( $nsProtection[$ns] !== '' ) {
|
|
|
|
|
$specificNs = $nsProtection[$ns];
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $specificNs ) && $specificNs !== '' ) {
|
|
|
|
|
$data[$ns]['namespaceprotection'] = $specificNs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-05 17:58:51 +00:00
|
|
|
$contentmodel = $nsInfo->getNamespaceContentModel( $ns );
|
2012-12-13 20:05:15 +00:00
|
|
|
if ( $contentmodel ) {
|
|
|
|
|
$data[$ns]['defaultcontentmodel'] = $contentmodel;
|
|
|
|
|
}
|
2007-06-14 05:18:58 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2015-06-20 12:24:31 +00:00
|
|
|
ApiResult::setArrayType( $data, 'assoc' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'ns' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2007-06-14 05:18:58 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendNamespaceAliases( $property ) {
|
2018-07-29 12:24:54 +00:00
|
|
|
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
2014-07-20 19:41:41 +00:00
|
|
|
$aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ),
|
2018-07-29 12:24:54 +00:00
|
|
|
$contLang->getNamespaceAliases() );
|
|
|
|
|
$namespaces = $contLang->getNamespaces();
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $aliases as $title => $ns ) {
|
|
|
|
|
if ( $namespaces[$ns] == $title ) {
|
2009-02-16 12:19:29 +00:00
|
|
|
// Don't list duplicates
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$item = [
|
2019-02-25 00:38:33 +00:00
|
|
|
'id' => (int)$ns
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setContentValue( $item, 'alias', strtr( $title, '_', ' ' ) );
|
2008-02-03 19:29:59 +00:00
|
|
|
$data[] = $item;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2013-08-15 03:06:09 +00:00
|
|
|
sort( $data );
|
|
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'ns' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-02-03 19:29:59 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendSpecialPageAliases( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2018-08-12 09:08:58 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$aliases = $services->getContentLanguage()->getSpecialPageAliases();
|
|
|
|
|
foreach ( $services->getSpecialPageFactory()->getNames() as $specialpage ) {
|
2012-06-02 20:20:14 +00:00
|
|
|
if ( isset( $aliases[$specialpage] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
|
2012-06-02 20:20:14 +00:00
|
|
|
$data[] = $arr;
|
|
|
|
|
}
|
2008-03-28 12:47:21 +00:00
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'specialpage' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-03-28 12:47:21 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2008-10-26 13:57:19 +00:00
|
|
|
protected function appendMagicWords( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach (
|
|
|
|
|
MediaWikiServices::getInstance()->getContentLanguage()->getMagicWords()
|
|
|
|
|
as $magicword => $aliases
|
|
|
|
|
) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$caseSensitive = array_shift( $aliases );
|
2016-02-17 09:09:32 +00:00
|
|
|
$arr = [ 'name' => $magicword, 'aliases' => $aliases ];
|
2015-01-16 19:00:07 +00:00
|
|
|
$arr['case-sensitive'] = (bool)$caseSensitive;
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
|
2008-10-26 13:57:19 +00:00
|
|
|
$data[] = $arr;
|
|
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'magicword' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-10-26 13:57:19 +00:00
|
|
|
}
|
2008-03-28 12:47:21 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendInterwikiMap( $property, $filter ) {
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $filter === 'local' ) {
|
2011-07-19 12:30:18 +00:00
|
|
|
$local = 1;
|
2010-02-26 13:18:56 +00:00
|
|
|
} elseif ( $filter === '!local' ) {
|
2011-07-19 12:30:18 +00:00
|
|
|
$local = 0;
|
2018-07-31 16:15:17 +00:00
|
|
|
} else {
|
|
|
|
|
// $filter === null
|
|
|
|
|
$local = null;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2007-06-14 05:18:58 +00:00
|
|
|
|
2011-07-27 21:16:32 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2017-10-06 22:17:58 +00:00
|
|
|
$langCode = $params['inlanguagecode'] ?? '';
|
2012-03-08 20:56:26 +00:00
|
|
|
$langNames = Language::fetchLanguageNames( $langCode );
|
2011-07-27 21:16:32 +00:00
|
|
|
|
2017-01-10 09:51:50 +00:00
|
|
|
$getPrefixes = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local );
|
2014-06-20 01:29:05 +00:00
|
|
|
$extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' );
|
2014-06-22 05:26:28 +00:00
|
|
|
$localInterwikis = $this->getConfig()->get( 'LocalInterwikis' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2011-07-27 21:16:32 +00:00
|
|
|
|
2011-07-19 12:30:18 +00:00
|
|
|
foreach ( $getPrefixes as $row ) {
|
|
|
|
|
$prefix = $row['iw_prefix'];
|
2016-02-17 09:09:32 +00:00
|
|
|
$val = [];
|
2011-07-19 12:30:18 +00:00
|
|
|
$val['prefix'] = $prefix;
|
2014-08-22 02:24:25 +00:00
|
|
|
if ( isset( $row['iw_local'] ) && $row['iw_local'] == '1' ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$val['local'] = true;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2014-09-15 02:33:16 +00:00
|
|
|
if ( isset( $row['iw_trans'] ) && $row['iw_trans'] == '1' ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$val['trans'] = true;
|
2013-10-23 22:16:02 +00:00
|
|
|
}
|
2014-06-20 01:29:05 +00:00
|
|
|
|
2011-07-19 12:30:18 +00:00
|
|
|
if ( isset( $langNames[$prefix] ) ) {
|
|
|
|
|
$val['language'] = $langNames[$prefix];
|
|
|
|
|
}
|
2014-06-22 05:26:28 +00:00
|
|
|
if ( in_array( $prefix, $localInterwikis ) ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$val['localinterwiki'] = true;
|
2014-06-22 05:26:28 +00:00
|
|
|
}
|
2014-06-20 01:29:05 +00:00
|
|
|
if ( in_array( $prefix, $extraLangPrefixes ) ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$val['extralanglink'] = true;
|
2014-06-20 01:29:05 +00:00
|
|
|
|
|
|
|
|
$linktext = wfMessage( "interlanguage-link-$prefix" );
|
|
|
|
|
if ( !$linktext->isDisabled() ) {
|
|
|
|
|
$val['linktext'] = $linktext->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sitename = wfMessage( "interlanguage-link-sitename-$prefix" );
|
|
|
|
|
if ( !$sitename->isDisabled() ) {
|
|
|
|
|
$val['sitename'] = $sitename->text();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 16:48:37 +00:00
|
|
|
$val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
|
2015-01-16 19:00:07 +00:00
|
|
|
$val['protorel'] = substr( $row['iw_url'], 0, 2 ) == '//';
|
2015-01-30 19:12:33 +00:00
|
|
|
if ( isset( $row['iw_wikiid'] ) && $row['iw_wikiid'] !== '' ) {
|
2011-11-29 16:48:37 +00:00
|
|
|
$val['wikiid'] = $row['iw_wikiid'];
|
2011-07-19 12:30:18 +00:00
|
|
|
}
|
2015-01-30 19:12:33 +00:00
|
|
|
if ( isset( $row['iw_api'] ) && $row['iw_api'] !== '' ) {
|
2011-11-29 16:48:37 +00:00
|
|
|
$val['api'] = $row['iw_api'];
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2008-03-27 15:12:16 +00:00
|
|
|
|
2007-06-14 05:18:58 +00:00
|
|
|
$data[] = $val;
|
|
|
|
|
}
|
2008-03-27 15:12:16 +00:00
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'iw' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2007-06-14 05:18:58 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendDbReplLagInfo( $property, $includeAll ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2018-01-04 16:38:22 +00:00
|
|
|
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
|
2014-01-24 02:51:11 +00:00
|
|
|
$showHostnames = $this->getConfig()->get( 'ShowHostnames' );
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $includeAll ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
if ( !$showHostnames ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-siteinfo-includealldenied', 'includeAllDenied' );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2008-04-08 20:24:31 +00:00
|
|
|
|
|
|
|
|
$lags = $lb->getLagTimes();
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $lags as $i => $lag ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data[] = [
|
2008-04-08 20:24:31 +00:00
|
|
|
'host' => $lb->getServerName( $i ),
|
2008-07-04 09:21:11 +00:00
|
|
|
'lag' => $lag
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2007-07-07 04:53:07 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-12-09 03:27:02 +00:00
|
|
|
list( , $lag, $index ) = $lb->getMaxLag();
|
2016-02-17 09:09:32 +00:00
|
|
|
$data[] = [
|
2014-01-24 02:51:11 +00:00
|
|
|
'host' => $showHostnames
|
2011-06-03 22:59:34 +00:00
|
|
|
? $lb->getServerName( $index )
|
|
|
|
|
: '',
|
2018-03-17 02:51:26 +00:00
|
|
|
'lag' => $lag
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2007-07-07 04:53:07 +00:00
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'db' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2007-06-14 05:18:58 +00:00
|
|
|
|
2008-07-04 09:21:11 +00:00
|
|
|
protected function appendStatistics( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2019-02-25 00:38:33 +00:00
|
|
|
$data['pages'] = (int)SiteStats::pages();
|
|
|
|
|
$data['articles'] = (int)SiteStats::articles();
|
|
|
|
|
$data['edits'] = (int)SiteStats::edits();
|
|
|
|
|
$data['images'] = (int)SiteStats::images();
|
|
|
|
|
$data['users'] = (int)SiteStats::users();
|
|
|
|
|
$data['activeusers'] = (int)SiteStats::activeUsers();
|
|
|
|
|
$data['admins'] = (int)SiteStats::numberingroup( 'sysop' );
|
|
|
|
|
$data['jobs'] = (int)SiteStats::jobs();
|
2013-10-05 21:32:08 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'APIQuerySiteInfoStatisticsInfo', [ &$data ] );
|
2013-10-05 21:32:08 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2008-04-03 14:33:36 +00:00
|
|
|
|
2009-07-12 12:10:27 +00:00
|
|
|
protected function appendUserGroups( $property, $numberInGroup ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$config = $this->getConfig();
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2011-06-30 01:06:17 +00:00
|
|
|
$result = $this->getResult();
|
2016-05-17 13:35:10 +00:00
|
|
|
$allGroups = array_values( User::getAllGroups() );
|
2014-01-24 02:51:11 +00:00
|
|
|
foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$arr = [
|
2010-01-11 15:55:52 +00:00
|
|
|
'name' => $group,
|
2009-07-12 12:10:27 +00:00
|
|
|
'rights' => array_keys( $permissions, true ),
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $numberInGroup ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$autopromote = $config->get( 'Autopromote' );
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2010-09-24 14:40:18 +00:00
|
|
|
if ( $group == 'user' ) {
|
2010-09-24 13:00:46 +00:00
|
|
|
$arr['number'] = SiteStats::users();
|
|
|
|
|
// '*' and autopromote groups have no size
|
2014-01-24 02:51:11 +00:00
|
|
|
} elseif ( $group !== '*' && !isset( $autopromote[$group] ) ) {
|
2015-11-07 21:10:23 +00:00
|
|
|
$arr['number'] = SiteStats::numberingroup( $group );
|
2010-09-24 13:00:46 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$groupArr = [
|
2014-01-24 02:51:11 +00:00
|
|
|
'add' => $config->get( 'AddGroups' ),
|
|
|
|
|
'remove' => $config->get( 'RemoveGroups' ),
|
|
|
|
|
'add-self' => $config->get( 'GroupsAddToSelf' ),
|
|
|
|
|
'remove-self' => $config->get( 'GroupsRemoveFromSelf' )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-12-30 17:06:09 +00:00
|
|
|
|
|
|
|
|
foreach ( $groupArr as $type => $rights ) {
|
|
|
|
|
if ( isset( $rights[$group] ) ) {
|
2016-05-17 13:35:10 +00:00
|
|
|
if ( $rights[$group] === true ) {
|
|
|
|
|
$groups = $allGroups;
|
|
|
|
|
} else {
|
|
|
|
|
$groups = array_intersect( $rights[$group], $allGroups );
|
|
|
|
|
}
|
2014-09-15 01:52:21 +00:00
|
|
|
if ( $groups ) {
|
|
|
|
|
$arr[$type] = $groups;
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $arr[$type], 'BCarray' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $arr[$type], 'group' );
|
2014-09-15 01:52:21 +00:00
|
|
|
}
|
2010-08-06 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $arr['rights'], 'permission' );
|
2008-04-03 14:33:36 +00:00
|
|
|
$data[] = $arr;
|
|
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'group' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-06-30 01:06:17 +00:00
|
|
|
return $result->addValue( 'query', $property, $data );
|
2008-04-03 14:33:36 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2009-01-14 22:15:50 +00:00
|
|
|
protected function appendFileExtensions( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2014-01-24 02:51:11 +00:00
|
|
|
foreach ( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) as $ext ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data[] = [ 'ext' => $ext ];
|
2009-01-14 22:15:50 +00:00
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'fe' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2009-01-14 22:15:50 +00:00
|
|
|
}
|
2008-04-03 14:33:36 +00:00
|
|
|
|
2015-02-12 21:09:23 +00:00
|
|
|
protected function appendInstalledLibraries( $property ) {
|
|
|
|
|
global $IP;
|
2015-10-25 23:55:47 +00:00
|
|
|
$path = "$IP/vendor/composer/installed.json";
|
2015-02-12 21:09:23 +00:00
|
|
|
if ( !file_exists( $path ) ) {
|
2015-10-25 23:55:47 +00:00
|
|
|
return true;
|
2015-02-12 21:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2015-10-25 23:55:47 +00:00
|
|
|
$installed = new ComposerInstalled( $path );
|
|
|
|
|
foreach ( $installed->getInstalledDependencies() as $name => $info ) {
|
2015-02-12 21:09:23 +00:00
|
|
|
if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) {
|
|
|
|
|
// Skip any extensions or skins since they'll be listed
|
|
|
|
|
// in their proper section
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$data[] = [
|
2015-02-12 21:09:23 +00:00
|
|
|
'name' => $name,
|
|
|
|
|
'version' => $info['version'],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2015-02-12 21:09:23 +00:00
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'library' );
|
2015-02-12 21:09:23 +00:00
|
|
|
|
|
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-14 22:06:32 +00:00
|
|
|
protected function appendExtensions( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2014-01-24 02:51:11 +00:00
|
|
|
foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as $type => $extensions ) {
|
2008-12-14 22:06:32 +00:00
|
|
|
foreach ( $extensions as $ext ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$ret = [];
|
2008-12-14 22:06:32 +00:00
|
|
|
$ret['type'] = $type;
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $ext['name'] ) ) {
|
2008-12-14 22:06:32 +00:00
|
|
|
$ret['name'] = $ext['name'];
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2014-06-21 10:33:54 +00:00
|
|
|
if ( isset( $ext['namemsg'] ) ) {
|
|
|
|
|
$ret['namemsg'] = $ext['namemsg'];
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $ext['description'] ) ) {
|
2008-12-14 22:06:32 +00:00
|
|
|
$ret['description'] = $ext['description'];
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-01-24 12:11:18 +00:00
|
|
|
if ( isset( $ext['descriptionmsg'] ) ) {
|
2016-07-25 01:25:09 +00:00
|
|
|
// Can be a string or [ key, param1, param2, ... ]
|
2010-01-24 12:11:18 +00:00
|
|
|
if ( is_array( $ext['descriptionmsg'] ) ) {
|
|
|
|
|
$ret['descriptionmsg'] = $ext['descriptionmsg'][0];
|
|
|
|
|
$ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
|
2010-01-24 12:11:18 +00:00
|
|
|
} else {
|
|
|
|
|
$ret['descriptionmsg'] = $ext['descriptionmsg'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-14 22:06:32 +00:00
|
|
|
if ( isset( $ext['author'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$ret['author'] = is_array( $ext['author'] ) ?
|
2013-02-03 18:47:42 +00:00
|
|
|
implode( ', ', $ext['author'] ) : $ext['author'];
|
2008-12-14 22:06:32 +00:00
|
|
|
}
|
2010-01-24 10:19:16 +00:00
|
|
|
if ( isset( $ext['url'] ) ) {
|
2010-01-24 12:11:18 +00:00
|
|
|
$ret['url'] = $ext['url'];
|
2010-01-24 10:19:16 +00:00
|
|
|
}
|
2008-12-14 22:06:32 +00:00
|
|
|
if ( isset( $ext['version'] ) ) {
|
2013-11-14 13:00:02 +00:00
|
|
|
$ret['version'] = $ext['version'];
|
2008-12-14 22:06:32 +00:00
|
|
|
}
|
2013-05-24 11:19:49 +00:00
|
|
|
if ( isset( $ext['path'] ) ) {
|
|
|
|
|
$extensionPath = dirname( $ext['path'] );
|
|
|
|
|
$gitInfo = new GitInfo( $extensionPath );
|
|
|
|
|
$vcsVersion = $gitInfo->getHeadSHA1();
|
|
|
|
|
if ( $vcsVersion !== false ) {
|
|
|
|
|
$ret['vcs-system'] = 'git';
|
2014-02-05 11:02:29 +00:00
|
|
|
$ret['vcs-version'] = $vcsVersion;
|
2013-05-24 11:19:49 +00:00
|
|
|
$ret['vcs-url'] = $gitInfo->getHeadViewUrl();
|
2014-05-05 14:23:30 +00:00
|
|
|
$vcsDate = $gitInfo->getHeadCommitDate();
|
|
|
|
|
if ( $vcsDate !== false ) {
|
|
|
|
|
$ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $vcsDate );
|
|
|
|
|
}
|
2013-05-24 11:19:49 +00:00
|
|
|
}
|
2014-02-05 10:20:17 +00:00
|
|
|
|
2013-05-24 11:19:49 +00:00
|
|
|
if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
|
2017-10-06 22:17:58 +00:00
|
|
|
$ret['license-name'] = $ext['license-name'] ?? '';
|
2014-02-05 10:20:17 +00:00
|
|
|
$ret['license'] = SpecialPage::getTitleFor(
|
|
|
|
|
'Version',
|
|
|
|
|
"License/{$ext['name']}"
|
|
|
|
|
)->getLinkURL();
|
2013-05-24 11:19:49 +00:00
|
|
|
}
|
2014-02-05 10:20:17 +00:00
|
|
|
|
2013-05-24 11:19:49 +00:00
|
|
|
if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) {
|
2014-02-05 10:20:17 +00:00
|
|
|
$ret['credits'] = SpecialPage::getTitleFor(
|
|
|
|
|
'Version',
|
|
|
|
|
"Credits/{$ext['name']}"
|
|
|
|
|
)->getLinkURL();
|
2013-05-24 11:19:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-14 22:06:32 +00:00
|
|
|
$data[] = $ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'ext' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2008-12-14 22:06:32 +00:00
|
|
|
}
|
2009-01-20 22:57:05 +00:00
|
|
|
|
2009-01-31 15:56:52 +00:00
|
|
|
protected function appendRightsInfo( $property ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$config = $this->getConfig();
|
2015-04-06 17:24:15 +00:00
|
|
|
$rightsPage = $config->get( 'RightsPage' );
|
|
|
|
|
if ( is_string( $rightsPage ) ) {
|
|
|
|
|
$title = Title::newFromText( $rightsPage );
|
|
|
|
|
$url = wfExpandUrl( $title, PROTO_CURRENT );
|
|
|
|
|
} else {
|
|
|
|
|
$title = false;
|
|
|
|
|
$url = $config->get( 'RightsUrl' );
|
|
|
|
|
}
|
2014-01-24 02:51:11 +00:00
|
|
|
$text = $config->get( 'RightsText' );
|
2018-07-31 16:15:17 +00:00
|
|
|
if ( $title && !strlen( $text ) ) {
|
2009-01-31 15:56:52 +00:00
|
|
|
$text = $title->getPrefixedText();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [
|
2019-03-27 10:13:08 +00:00
|
|
|
'url' => (string)$url,
|
|
|
|
|
'text' => (string)$text,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2009-01-31 15:56:52 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
2009-01-31 15:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-06 15:30:00 +00:00
|
|
|
protected function appendRestrictions( $property ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$config = $this->getConfig();
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [
|
2014-01-24 02:51:11 +00:00
|
|
|
'types' => $config->get( 'RestrictionTypes' ),
|
|
|
|
|
'levels' => $config->get( 'RestrictionLevels' ),
|
|
|
|
|
'cascadinglevels' => $config->get( 'CascadingRestrictionLevels' ),
|
|
|
|
|
'semiprotectedlevels' => $config->get( 'SemiprotectedRestrictionLevels' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2014-02-06 15:30:00 +00:00
|
|
|
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $data['types'], 'BCarray' );
|
|
|
|
|
ApiResult::setArrayType( $data['levels'], 'BCarray' );
|
|
|
|
|
ApiResult::setArrayType( $data['cascadinglevels'], 'BCarray' );
|
|
|
|
|
ApiResult::setArrayType( $data['semiprotectedlevels'], 'BCarray' );
|
|
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data['types'], 'type' );
|
|
|
|
|
ApiResult::setIndexedTagName( $data['levels'], 'level' );
|
|
|
|
|
ApiResult::setIndexedTagName( $data['cascadinglevels'], 'level' );
|
|
|
|
|
ApiResult::setIndexedTagName( $data['semiprotectedlevels'], 'level' );
|
2014-02-06 15:30:00 +00:00
|
|
|
|
|
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-07 18:20:01 +00:00
|
|
|
public function appendLanguages( $property ) {
|
2011-07-27 21:16:32 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2017-10-06 22:17:58 +00:00
|
|
|
$langCode = $params['inlanguagecode'] ?? '';
|
2012-03-10 02:07:31 +00:00
|
|
|
$langNames = Language::fetchLanguageNames( $langCode );
|
2011-07-27 21:16:32 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2011-07-27 21:16:32 +00:00
|
|
|
|
|
|
|
|
foreach ( $langNames as $code => $name ) {
|
2018-06-26 20:39:57 +00:00
|
|
|
$lang = [
|
|
|
|
|
'code' => $code,
|
|
|
|
|
'bcp47' => LanguageCode::bcp47( $code ),
|
|
|
|
|
];
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setContentValue( $lang, 'name', $name );
|
2009-06-07 18:20:01 +00:00
|
|
|
$data[] = $lang;
|
|
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'lang' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2009-06-07 18:20:01 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 20:56:01 +00:00
|
|
|
// Export information about which page languages will trigger
|
|
|
|
|
// language conversion. (T153341)
|
|
|
|
|
public function appendLanguageVariants( $property ) {
|
|
|
|
|
$langNames = LanguageConverter::$languagesWithVariants;
|
|
|
|
|
if ( $this->getConfig()->get( 'DisableLangConversion' ) ) {
|
|
|
|
|
// Ensure result is empty if language conversion is disabled.
|
|
|
|
|
$langNames = [];
|
|
|
|
|
}
|
|
|
|
|
sort( $langNames );
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
foreach ( $langNames as $langCode ) {
|
2019-08-26 12:24:37 +00:00
|
|
|
$lang = MediaWikiServices::getInstance()->getLanguageFactory()
|
|
|
|
|
->getLanguage( $langCode );
|
2017-02-28 20:56:01 +00:00
|
|
|
if ( $lang->getConverter() instanceof FakeConverter ) {
|
|
|
|
|
// Only languages which do not return instances of
|
|
|
|
|
// FakeConverter implement language conversion.
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$data[$langCode] = [];
|
|
|
|
|
ApiResult::setIndexedTagName( $data[$langCode], 'variant' );
|
|
|
|
|
ApiResult::setArrayType( $data[$langCode], 'kvp', 'code' );
|
|
|
|
|
|
|
|
|
|
$variants = $lang->getVariants();
|
|
|
|
|
sort( $variants );
|
|
|
|
|
foreach ( $variants as $v ) {
|
|
|
|
|
$fallbacks = $lang->getConverter()->getVariantFallbacks( $v );
|
|
|
|
|
if ( !is_array( $fallbacks ) ) {
|
|
|
|
|
$fallbacks = [ $fallbacks ];
|
|
|
|
|
}
|
|
|
|
|
$data[$langCode][$v] = [
|
|
|
|
|
'fallbacks' => $fallbacks,
|
|
|
|
|
];
|
|
|
|
|
ApiResult::setIndexedTagName(
|
|
|
|
|
$data[$langCode][$v]['fallbacks'], 'variant'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ApiResult::setIndexedTagName( $data, 'lang' );
|
|
|
|
|
ApiResult::setArrayType( $data, 'kvp', 'code' );
|
|
|
|
|
|
|
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-23 02:05:26 +00:00
|
|
|
public function appendSkins( $property ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2013-05-25 13:05:55 +00:00
|
|
|
$allowed = Skin::getAllowedSkins();
|
2013-04-15 14:54:51 +00:00
|
|
|
$default = Skin::normalizeKey( 'default' );
|
2011-01-23 02:05:26 +00:00
|
|
|
foreach ( Skin::getSkinNames() as $name => $displayName ) {
|
2014-08-29 19:51:56 +00:00
|
|
|
$msg = $this->msg( "skinname-{$name}" );
|
|
|
|
|
$code = $this->getParameter( 'inlanguagecode' );
|
|
|
|
|
if ( $code && Language::isValidCode( $code ) ) {
|
|
|
|
|
$msg->inLanguage( $code );
|
|
|
|
|
} else {
|
|
|
|
|
$msg->inContentLanguage();
|
|
|
|
|
}
|
|
|
|
|
if ( $msg->exists() ) {
|
|
|
|
|
$displayName = $msg->text();
|
|
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$skin = [ 'code' => $name ];
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setContentValue( $skin, 'name', $displayName );
|
2013-05-25 13:05:55 +00:00
|
|
|
if ( !isset( $allowed[$name] ) ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$skin['unusable'] = true;
|
2013-04-15 14:54:51 +00:00
|
|
|
}
|
|
|
|
|
if ( $name === $default ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$skin['default'] = true;
|
2013-04-15 14:54:51 +00:00
|
|
|
}
|
2011-01-23 02:05:26 +00:00
|
|
|
$data[] = $skin;
|
|
|
|
|
}
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'skin' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-01-23 02:05:26 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 23:02:10 +00:00
|
|
|
public function appendExtensionTags( $property ) {
|
2018-07-31 16:15:17 +00:00
|
|
|
$tags = array_map(
|
|
|
|
|
function ( $item ) {
|
|
|
|
|
return "<$item>";
|
|
|
|
|
},
|
2019-04-11 13:36:15 +00:00
|
|
|
MediaWikiServices::getInstance()->getParser()->getTags()
|
2018-07-31 16:15:17 +00:00
|
|
|
);
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $tags, 'BCarray' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $tags, 't' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-04-29 23:02:10 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $tags );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function appendFunctionHooks( $property ) {
|
2019-04-11 13:36:15 +00:00
|
|
|
$hooks = MediaWikiServices::getInstance()->getParser()->getFunctionHooks();
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $hooks, 'BCarray' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $hooks, 'h' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-04-29 23:02:10 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $hooks );
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-02 20:34:18 +00:00
|
|
|
public function appendVariables( $property ) {
|
2018-07-30 14:18:09 +00:00
|
|
|
$variables = MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs();
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $variables, 'BCarray' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $variables, 'v' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2012-06-02 20:34:18 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $variables );
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-14 23:06:15 +00:00
|
|
|
public function appendProtocols( $property ) {
|
2017-02-20 22:28:10 +00:00
|
|
|
// Make a copy of the global so we don't try to set the _element key of it - T47130
|
2014-01-24 02:51:11 +00:00
|
|
|
$protocols = array_values( $this->getConfig()->get( 'UrlProtocols' ) );
|
2015-06-16 16:55:11 +00:00
|
|
|
ApiResult::setArrayType( $protocols, 'BCarray' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $protocols, 'p' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2013-02-18 20:57:00 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $protocols );
|
2013-02-14 23:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-09 18:08:39 +00:00
|
|
|
public function appendDefaultOptions( $property ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$options = User::getDefaultOptions();
|
|
|
|
|
$options[ApiResult::META_BC_BOOLS] = array_keys( $options );
|
|
|
|
|
return $this->getResult()->addValue( 'query', $property, $options );
|
2013-12-09 18:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-05 15:20:05 +00:00
|
|
|
public function appendUploadDialog( $property ) {
|
|
|
|
|
$config = $this->getConfig()->get( 'UploadDialog' );
|
|
|
|
|
return $this->getResult()->addValue( 'query', $property, $config );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 23:33:38 +00:00
|
|
|
public function appendSubscribedHooks( $property ) {
|
2014-01-24 02:51:11 +00:00
|
|
|
$hooks = $this->getConfig()->get( 'Hooks' );
|
|
|
|
|
$myWgHooks = $hooks;
|
2011-04-29 23:33:38 +00:00
|
|
|
ksort( $myWgHooks );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [];
|
2014-01-24 02:51:11 +00:00
|
|
|
foreach ( $myWgHooks as $name => $subscribers ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$arr = [
|
2014-01-24 02:51:11 +00:00
|
|
|
'name' => $name,
|
2018-01-13 00:02:09 +00:00
|
|
|
'subscribers' => array_map( [ SpecialVersion::class, 'arrayToString' ], $subscribers ),
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2011-04-29 23:33:38 +00:00
|
|
|
|
2015-10-29 17:40:52 +00:00
|
|
|
ApiResult::setArrayType( $arr['subscribers'], 'array' );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $arr['subscribers'], 's' );
|
2011-04-29 23:33:38 +00:00
|
|
|
$data[] = $arr;
|
|
|
|
|
}
|
|
|
|
|
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $data, 'hook' );
|
2013-11-14 13:00:02 +00:00
|
|
|
|
2011-04-29 23:33:38 +00:00
|
|
|
return $this->getResult()->addValue( 'query', $property, $data );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
public function getCacheMode( $params ) {
|
2014-06-20 01:29:05 +00:00
|
|
|
// Messages for $wgExtraInterlanguageLinkPrefixes depend on user language
|
|
|
|
|
if (
|
|
|
|
|
count( $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ) ) &&
|
2020-01-09 23:48:34 +00:00
|
|
|
$params['prop'] !== null &&
|
2014-06-20 01:29:05 +00:00
|
|
|
in_array( 'interwikimap', $params['prop'] )
|
|
|
|
|
) {
|
|
|
|
|
return 'anon-public-user-private';
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
return 'public';
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'prop' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'general',
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
ApiBase::PARAM_TYPE => [
|
2006-09-26 01:44:13 +00:00
|
|
|
'general',
|
2007-06-14 05:18:58 +00:00
|
|
|
'namespaces',
|
2008-02-03 19:29:59 +00:00
|
|
|
'namespacealiases',
|
2008-03-28 12:47:21 +00:00
|
|
|
'specialpagealiases',
|
2008-10-26 13:57:19 +00:00
|
|
|
'magicwords',
|
2007-07-07 04:53:07 +00:00
|
|
|
'interwikimap',
|
2007-07-07 04:58:52 +00:00
|
|
|
'dbrepllag',
|
2007-08-09 12:39:41 +00:00
|
|
|
'statistics',
|
2008-04-03 14:33:36 +00:00
|
|
|
'usergroups',
|
2015-02-12 21:09:23 +00:00
|
|
|
'libraries',
|
2008-12-14 22:06:32 +00:00
|
|
|
'extensions',
|
2009-01-14 22:15:50 +00:00
|
|
|
'fileextensions',
|
2009-01-31 15:56:52 +00:00
|
|
|
'rightsinfo',
|
2014-02-06 15:30:00 +00:00
|
|
|
'restrictions',
|
2009-06-07 18:20:01 +00:00
|
|
|
'languages',
|
2017-02-28 20:56:01 +00:00
|
|
|
'languagevariants',
|
2011-01-23 02:05:26 +00:00
|
|
|
'skins',
|
2011-04-29 23:02:10 +00:00
|
|
|
'extensiontags',
|
|
|
|
|
'functionhooks',
|
2011-04-29 23:33:38 +00:00
|
|
|
'showhooks',
|
2012-06-02 20:34:18 +00:00
|
|
|
'variables',
|
2013-02-14 23:06:15 +00:00
|
|
|
'protocols',
|
2013-12-09 18:08:39 +00:00
|
|
|
'defaultoptions',
|
2016-05-05 15:20:05 +00:00
|
|
|
'uploaddialog',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
|
|
|
|
|
],
|
|
|
|
|
'filteriw' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => [
|
2007-06-14 05:18:58 +00:00
|
|
|
'local',
|
|
|
|
|
'!local',
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
],
|
2007-07-07 04:53:07 +00:00
|
|
|
'showalldb' => false,
|
2009-07-12 12:10:27 +00:00
|
|
|
'numberingroup' => false,
|
2011-11-17 19:06:30 +00:00
|
|
|
'inlanguagecode' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2014-09-18 17:38:23 +00:00
|
|
|
'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics'
|
|
|
|
|
=> 'apihelp-query+siteinfo-example-simple',
|
|
|
|
|
'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local'
|
|
|
|
|
=> 'apihelp-query+siteinfo-example-interwiki',
|
|
|
|
|
'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb='
|
|
|
|
|
=> 'apihelp-query+siteinfo-example-replag',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
2006-10-01 21:20:55 +00:00
|
|
|
|
2011-07-17 16:51:11 +00:00
|
|
|
public function getHelpUrls() {
|
2017-04-04 22:52:57 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Siteinfo';
|
2011-07-17 16:51:11 +00:00
|
|
|
}
|
2009-04-30 05:25:35 +00:00
|
|
|
}
|