2007-07-07 03:05:09 +00:00
|
|
|
<?php
|
2010-02-24 14:00:23 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2007-07-07 03:05:09 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on July 6, 2007
|
|
|
|
|
*
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
|
2007-07-07 03:05:09 +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.
|
2007-07-07 03:05:09 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2007-07-07 03:05:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A query action to get image information and upload history.
|
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-07-07 03:05:09 +00:00
|
|
|
*/
|
|
|
|
|
class ApiQueryImageInfo extends ApiQueryBase {
|
2013-02-01 23:14:09 +00:00
|
|
|
const TRANSFORM_LIMIT = 50;
|
|
|
|
|
private static $transformCount = 0;
|
2007-07-07 03:05:09 +00:00
|
|
|
|
2010-11-03 04:32:41 +00:00
|
|
|
public function __construct( $query, $moduleName, $prefix = 'ii' ) {
|
2013-11-14 16:17:22 +00:00
|
|
|
// We allow a subclass to override the prefix, to create a related API
|
|
|
|
|
// module. Some other parts of MediaWiki construct this with a null
|
|
|
|
|
// $prefix, which used to be ignored when this only took two arguments
|
2010-11-03 04:32:41 +00:00
|
|
|
if ( is_null( $prefix ) ) {
|
|
|
|
|
$prefix = 'ii';
|
|
|
|
|
}
|
|
|
|
|
parent::__construct( $query, $moduleName, $prefix );
|
2007-07-07 03:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$prop = array_flip( $params['prop'] );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-02-13 07:30:49 +00:00
|
|
|
$scale = $this->getScale( $params );
|
2007-07-07 03:05:09 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$opts = array(
|
2013-08-12 16:18:29 +00:00
|
|
|
'version' => $params['metadataversion'],
|
2013-10-28 18:18:05 +00:00
|
|
|
'language' => $params['extmetadatalanguage'],
|
|
|
|
|
'multilang' => $params['extmetadatamultilang'],
|
2013-11-14 19:26:00 +00:00
|
|
|
'extmetadatafilter' => $params['extmetadatafilter'],
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
'revdelUser' => $this->getUser(),
|
2013-08-12 16:18:29 +00:00
|
|
|
);
|
|
|
|
|
|
2007-07-07 03:05:09 +00:00
|
|
|
$pageIds = $this->getPageSet()->getAllTitlesByNamespace();
|
2009-02-18 06:04:09 +00:00
|
|
|
if ( !empty( $pageIds[NS_FILE] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$titles = array_keys( $pageIds[NS_FILE] );
|
|
|
|
|
asort( $titles ); // Ensure the order is always the same
|
2009-02-18 06:04:09 +00:00
|
|
|
|
2013-02-01 22:17:19 +00:00
|
|
|
$fromTitle = null;
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !is_null( $params['continue'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$cont = explode( '|', $params['continue'] );
|
2013-01-15 02:19:16 +00:00
|
|
|
$this->dieContinueUsageIf( count( $cont ) != 2 );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fromTitle = strval( $cont[0] );
|
2009-02-10 19:10:58 +00:00
|
|
|
$fromTimestamp = $cont[1];
|
|
|
|
|
// Filter out any titles before $fromTitle
|
2010-02-24 14:00:23 +00:00
|
|
|
foreach ( $titles as $key => $title ) {
|
|
|
|
|
if ( $title < $fromTitle ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
unset( $titles[$key] );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2009-02-10 19:10:58 +00:00
|
|
|
break;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-02-10 19:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$findTitles = array_map( function ( $title ) use ( $user ) {
|
|
|
|
|
return array(
|
|
|
|
|
'title' => $title,
|
|
|
|
|
'private' => $user,
|
|
|
|
|
);
|
|
|
|
|
}, $titles );
|
|
|
|
|
|
2013-04-19 18:03:05 +00:00
|
|
|
if ( $params['localonly'] ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$images = RepoGroup::singleton()->getLocalRepo()->findFiles( $findTitles );
|
2012-08-01 17:51:23 +00:00
|
|
|
} else {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$images = RepoGroup::singleton()->findFiles( $findTitles );
|
2012-08-01 17:51:23 +00:00
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
|
|
|
|
|
$result = $this->getResult();
|
2012-12-26 15:40:43 +00:00
|
|
|
foreach ( $titles as $title ) {
|
2013-02-01 22:17:19 +00:00
|
|
|
$pageId = $pageIds[NS_FILE][$title];
|
|
|
|
|
$start = $title === $fromTitle ? $fromTimestamp : $params['start'];
|
|
|
|
|
|
2012-12-26 15:40:43 +00:00
|
|
|
if ( !isset( $images[$title] ) ) {
|
2013-05-26 16:25:30 +00:00
|
|
|
if ( isset( $prop['uploadwarning'] ) ) {
|
|
|
|
|
// Uploadwarning needs info about non-existing files
|
|
|
|
|
$images[$title] = wfLocalFile( $title );
|
|
|
|
|
} else {
|
|
|
|
|
$result->addValue(
|
|
|
|
|
array( 'query', 'pages', intval( $pageId ) ),
|
|
|
|
|
'imagerepository', ''
|
|
|
|
|
);
|
|
|
|
|
// The above can't fail because it doesn't increase the result size
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-11 03:45:51 +00:00
|
|
|
/** @var $img File */
|
2012-12-26 15:40:43 +00:00
|
|
|
$img = $images[$title];
|
* 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
|
|
|
|
2013-02-01 23:14:09 +00:00
|
|
|
if ( self::getTransformCount() >= self::TRANSFORM_LIMIT ) {
|
|
|
|
|
if ( count( $pageIds[NS_FILE] ) == 1 ) {
|
|
|
|
|
// See the 'the user is screwed' comment below
|
|
|
|
|
$this->setContinueEnumParameter( 'start',
|
|
|
|
|
$start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$this->setContinueEnumParameter( 'continue',
|
|
|
|
|
$this->getContinueStr( $img, $start ) );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
* 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 = $result->addValue(
|
2010-01-11 15:55:52 +00:00
|
|
|
array( 'query', 'pages', intval( $pageId ) ),
|
* 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
|
|
|
'imagerepository', $img->getRepoName()
|
|
|
|
|
);
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !$fit ) {
|
2012-06-24 19:50:10 +00:00
|
|
|
if ( count( $pageIds[NS_FILE] ) == 1 ) {
|
2010-01-23 22:52:40 +00:00
|
|
|
// The user is screwed. imageinfo can't be solely
|
|
|
|
|
// responsible for exceeding the limit in this case,
|
|
|
|
|
// so set a query-continue that just returns the same
|
|
|
|
|
// thing again. When the violating queries have been
|
|
|
|
|
// out-continued, the result will get through
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start',
|
2013-02-01 22:17:19 +00:00
|
|
|
$start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
|
|
|
|
|
);
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue',
|
2013-02-01 22:17:19 +00:00
|
|
|
$this->getContinueStr( $img, $start ) );
|
2010-02-24 14:00:23 +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
|
|
|
break;
|
|
|
|
|
}
|
2011-04-04 21:13:34 +00:00
|
|
|
|
2011-02-13 07:30:49 +00:00
|
|
|
// Check if we can make the requested thumbnail, and get transform parameters.
|
|
|
|
|
$finalThumbParams = $this->mergeThumbParams( $img, $scale, $params['urlparam'] );
|
* 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
|
|
|
|
2008-05-20 17:05:57 +00:00
|
|
|
// Get information about the current version first
|
|
|
|
|
// Check that the current version is within the start-end boundaries
|
* 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
|
|
|
$gotOne = false;
|
2010-02-24 14:00:23 +00:00
|
|
|
if (
|
|
|
|
|
( is_null( $start ) || $img->getTimestamp() <= $start ) &&
|
|
|
|
|
( is_null( $params['end'] ) || $img->getTimestamp() >= $params['end'] )
|
2011-02-19 00:30:18 +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
|
|
|
$gotOne = true;
|
2011-04-04 21:13:34 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$fit = $this->addPageSubItem( $pageId,
|
2011-04-16 01:23:15 +00:00
|
|
|
self::getInfo( $img, $prop, $result,
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$finalThumbParams, $opts
|
2013-08-12 16:18:29 +00:00
|
|
|
)
|
|
|
|
|
);
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !$fit ) {
|
2012-06-24 19:50:10 +00:00
|
|
|
if ( count( $pageIds[NS_FILE] ) == 1 ) {
|
2010-01-23 22:52:40 +00:00
|
|
|
// See the 'the user is screwed' comment above
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start',
|
|
|
|
|
wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue',
|
|
|
|
|
$this->getContinueStr( $img ) );
|
2010-02-24 14:00:23 +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
|
|
|
break;
|
|
|
|
|
}
|
2008-05-20 17:05:57 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-05-20 17:05:57 +00:00
|
|
|
// Now get the old revisions
|
|
|
|
|
// Get one more to facilitate query-continue functionality
|
2010-01-11 15:55:52 +00:00
|
|
|
$count = ( $gotOne ? 1 : 0 );
|
|
|
|
|
$oldies = $img->getHistory( $params['limit'] - $count + 1, $start, $params['end'] );
|
2013-03-11 03:45:51 +00:00
|
|
|
/** @var $oldie File */
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $oldies as $oldie ) {
|
|
|
|
|
if ( ++$count > $params['limit'] ) {
|
2013-11-14 16:17:22 +00:00
|
|
|
// We've reached the extra one which shows that there are
|
|
|
|
|
// additional pages to be had. Stop here...
|
2008-05-20 17:05:57 +00:00
|
|
|
// Only set a query-continue if there was only one title
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( count( $pageIds[NS_FILE] ) == 1 ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start',
|
|
|
|
|
wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
|
2009-02-10 19:10:58 +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
|
|
|
break;
|
|
|
|
|
}
|
2013-04-03 16:03:44 +00:00
|
|
|
$fit = self::getTransformCount() < self::TRANSFORM_LIMIT &&
|
|
|
|
|
$this->addPageSubItem( $pageId,
|
|
|
|
|
self::getInfo( $oldie, $prop, $result,
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$finalThumbParams, $opts
|
2013-04-03 16:03:44 +00:00
|
|
|
)
|
|
|
|
|
);
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !$fit ) {
|
2012-06-24 19:50:10 +00:00
|
|
|
if ( count( $pageIds[NS_FILE] ) == 1 ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'start',
|
|
|
|
|
wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue',
|
|
|
|
|
$this->getContinueStr( $oldie ) );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2008-05-20 17:05:57 +00:00
|
|
|
break;
|
2008-01-20 13:09:32 +00:00
|
|
|
}
|
2007-07-07 03:05:09 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !$fit ) {
|
* 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;
|
2010-02-24 14:00:23 +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
|
|
|
}
|
2007-07-07 03:05:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-03 04:32:41 +00:00
|
|
|
/**
|
2010-12-30 00:56:30 +00:00
|
|
|
* From parameters, construct a 'scale' array
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $params Parameters passed to api.
|
2010-11-13 00:32:54 +00:00
|
|
|
* @return Array or Null: key-val array of 'width' and 'height', or null
|
2010-12-30 00:56:30 +00:00
|
|
|
*/
|
2010-11-03 04:32:41 +00:00
|
|
|
public function getScale( $params ) {
|
|
|
|
|
$p = $this->getModulePrefix();
|
2011-02-05 08:49:48 +00:00
|
|
|
|
2010-11-03 04:32:41 +00:00
|
|
|
if ( $params['urlwidth'] != -1 ) {
|
|
|
|
|
$scale = array();
|
|
|
|
|
$scale['width'] = $params['urlwidth'];
|
|
|
|
|
$scale['height'] = $params['urlheight'];
|
2013-04-23 03:46:15 +00:00
|
|
|
} elseif ( $params['urlheight'] != -1 ) {
|
|
|
|
|
// Height is specified but width isn't
|
|
|
|
|
// Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
|
|
|
|
|
$scale = array();
|
|
|
|
|
$scale['height'] = $params['urlheight'];
|
2010-11-03 04:32:41 +00:00
|
|
|
} else {
|
|
|
|
|
$scale = null;
|
2011-02-05 08:49:48 +00:00
|
|
|
if ( $params['urlparam'] ) {
|
|
|
|
|
$this->dieUsage( "{$p}urlparam requires {$p}urlwidth", "urlparam_no_width" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-03 04:32:41 +00:00
|
|
|
return $scale;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-13 07:30:49 +00:00
|
|
|
/** Validate and merge scale parameters with handler thumb parameters, give error if invalid.
|
2011-02-05 08:49:48 +00:00
|
|
|
*
|
2011-02-13 07:30:49 +00:00
|
|
|
* We do this later than getScale, since we need the image
|
2011-02-05 08:49:48 +00:00
|
|
|
* to know which handler, since handlers can make their own parameters.
|
|
|
|
|
* @param File $image Image that params are for.
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $thumbParams thumbnail parameters from getScale
|
|
|
|
|
* @param string $otherParams of otherParams (iiurlparam).
|
2011-02-13 07:30:49 +00:00
|
|
|
* @return Array of parameters for transform.
|
2011-02-05 08:49:48 +00:00
|
|
|
*/
|
2013-03-18 19:44:43 +00:00
|
|
|
protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
|
2013-06-21 15:46:29 +00:00
|
|
|
global $wgThumbLimits;
|
2013-04-23 03:46:15 +00:00
|
|
|
|
|
|
|
|
if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
|
2013-06-21 15:46:29 +00:00
|
|
|
// We want to limit only by height in this situation, so pass the
|
|
|
|
|
// image's full width as the limiting width. But some file types
|
|
|
|
|
// don't have a width of their own, so pick something arbitrary so
|
|
|
|
|
// thumbnailing the default icon works.
|
|
|
|
|
if ( $image->getWidth() <= 0 ) {
|
|
|
|
|
$thumbParams['width'] = max( $wgThumbLimits );
|
|
|
|
|
} else {
|
|
|
|
|
$thumbParams['width'] = $image->getWidth();
|
|
|
|
|
}
|
2013-04-23 03:46:15 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-27 00:40:06 +00:00
|
|
|
if ( !$otherParams ) {
|
|
|
|
|
return $thumbParams;
|
|
|
|
|
}
|
2011-02-05 08:49:48 +00:00
|
|
|
$p = $this->getModulePrefix();
|
|
|
|
|
|
|
|
|
|
$h = $image->getHandler();
|
2011-02-08 22:08:58 +00:00
|
|
|
if ( !$h ) {
|
2011-06-17 16:03:52 +00:00
|
|
|
$this->setWarning( 'Could not create thumbnail because ' .
|
2011-02-11 15:31:52 +00:00
|
|
|
$image->getName() . ' does not have an associated image handler' );
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2011-02-13 07:30:49 +00:00
|
|
|
return $thumbParams;
|
2011-02-05 08:49:48 +00:00
|
|
|
}
|
2011-02-13 07:30:49 +00:00
|
|
|
|
|
|
|
|
$paramList = $h->parseParamString( $otherParams );
|
|
|
|
|
if ( !$paramList ) {
|
|
|
|
|
// Just set a warning (instead of dieUsage), as in many cases
|
|
|
|
|
// we could still render the image using width and height parameters,
|
|
|
|
|
// and this type of thing could happen between different versions of
|
|
|
|
|
// handlers.
|
|
|
|
|
$this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
|
|
|
|
|
. '. Using only width and height' );
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2011-02-13 07:30:49 +00:00
|
|
|
return $thumbParams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $paramList['width'] ) ) {
|
2011-02-13 20:38:05 +00:00
|
|
|
if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
|
2013-04-23 03:46:15 +00:00
|
|
|
$this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) "
|
2013-11-14 16:17:22 +00:00
|
|
|
. "in favor of width value derived from {$p}urlwidth/{$p}urlheight "
|
|
|
|
|
. "({$thumbParams['width']})" );
|
2011-02-13 07:30:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ( $paramList as $name => $value ) {
|
2011-02-05 08:49:48 +00:00
|
|
|
if ( !$h->validateParam( $name, $value ) ) {
|
|
|
|
|
$this->dieUsage( "Invalid value for {$p}urlparam ($name=$value)", "urlparam" );
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-13 07:30:49 +00:00
|
|
|
|
|
|
|
|
return $thumbParams + $paramList;
|
2011-02-05 08:49:48 +00:00
|
|
|
}
|
2010-11-03 04:32:41 +00:00
|
|
|
|
2008-01-20 13:09:32 +00:00
|
|
|
/**
|
|
|
|
|
* Get result information for an image revision
|
2010-03-07 17:26:23 +00:00
|
|
|
*
|
|
|
|
|
* @param $file File object
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $prop of properties to get (in the keys)
|
2010-03-07 17:26:23 +00:00
|
|
|
* @param $result ApiResult object
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $thumbParams containing 'width' and 'height' items, or null
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
* @param array|bool|string $opts Options for data fetching.
|
2013-08-12 16:18:29 +00:00
|
|
|
* This is an array consisting of the keys:
|
|
|
|
|
* 'version': The metadata version for the metadata option
|
2013-10-28 18:18:05 +00:00
|
|
|
* 'language': The language for extmetadata property
|
|
|
|
|
* 'multilang': Return all translations in extmetadata property
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
* 'revdelUser': User to use when checking whether to show revision-deleted fields.
|
2010-03-07 17:26:23 +00:00
|
|
|
* @return Array: result array
|
2008-01-20 13:09:32 +00:00
|
|
|
*/
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
|
2013-10-28 18:18:05 +00:00
|
|
|
global $wgContLang;
|
|
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = false;
|
|
|
|
|
|
|
|
|
|
if ( !$opts || is_string( $opts ) ) {
|
|
|
|
|
$opts = array(
|
|
|
|
|
'version' => $opts ?: 'latest',
|
2013-10-28 18:18:05 +00:00
|
|
|
'language' => $wgContLang,
|
|
|
|
|
'multilang' => false,
|
2013-11-14 19:26:00 +00:00
|
|
|
'extmetadatafilter' => array(),
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
'revdelUser' => null,
|
2013-08-12 16:18:29 +00:00
|
|
|
);
|
|
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$version = $opts['version'];
|
2008-01-20 13:09:32 +00:00
|
|
|
$vals = array();
|
2011-02-25 20:16:19 +00:00
|
|
|
// Timestamp is shown even if the file is revdelete'd in interface
|
|
|
|
|
// so do same here.
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( isset( $prop['timestamp'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2011-02-25 20:16:19 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
// Handle external callers who don't pass revdelUser
|
|
|
|
|
if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
|
|
|
|
|
$revdelUser = $opts['revdelUser'];
|
|
|
|
|
$canShowField = function ( $field ) use ( $file, $revdelUser ) {
|
|
|
|
|
return $file->userCan( $field, $revdelUser );
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
$canShowField = function ( $field ) use ( $file ) {
|
|
|
|
|
return !$file->isDeleted( $field );
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
$user = isset( $prop['user'] );
|
|
|
|
|
$userid = isset( $prop['userid'] );
|
|
|
|
|
|
|
|
|
|
if ( $user || $userid ) {
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_USER ) ) {
|
|
|
|
|
$vals['userhidden'] = '';
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $canShowField( File::DELETED_USER ) ) {
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $user ) {
|
2011-02-25 19:51:37 +00:00
|
|
|
$vals['user'] = $file->getUser();
|
|
|
|
|
}
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $userid ) {
|
2011-02-25 19:51:37 +00:00
|
|
|
$vals['userid'] = $file->getUser( 'id' );
|
|
|
|
|
}
|
|
|
|
|
if ( !$file->getUser( 'id' ) ) {
|
|
|
|
|
$vals['anon'] = '';
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2008-01-20 13:09:32 +00:00
|
|
|
}
|
2011-02-25 20:22:54 +00:00
|
|
|
|
2011-02-25 20:16:19 +00:00
|
|
|
// This is shown even if the file is revdelete'd in interface
|
|
|
|
|
// so do same here.
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
|
2008-05-20 14:32:52 +00:00
|
|
|
$vals['size'] = intval( $file->getSize() );
|
|
|
|
|
$vals['width'] = intval( $file->getWidth() );
|
|
|
|
|
$vals['height'] = intval( $file->getHeight() );
|
2010-12-30 00:56:30 +00:00
|
|
|
|
2010-11-27 18:51:17 +00:00
|
|
|
$pageCount = $file->pageCount();
|
|
|
|
|
if ( $pageCount !== false ) {
|
|
|
|
|
$vals['pagecount'] = $pageCount;
|
|
|
|
|
}
|
2008-01-20 13:09:32 +00:00
|
|
|
}
|
2011-02-25 20:16:19 +00:00
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
$pcomment = isset( $prop['parsedcomment'] );
|
|
|
|
|
$comment = isset( $prop['comment'] );
|
|
|
|
|
|
|
|
|
|
if ( $pcomment || $comment ) {
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
|
|
|
|
|
$vals['commenthidden'] = '';
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $canShowField( File::DELETED_COMMENT ) ) {
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $pcomment ) {
|
2011-09-16 19:35:14 +00:00
|
|
|
$vals['parsedcomment'] = Linker::formatComment(
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$file->getDescription( File::RAW ), $file->getTitle() );
|
2011-02-25 21:41:19 +00:00
|
|
|
}
|
|
|
|
|
if ( $comment ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$vals['comment'] = $file->getDescription( File::RAW );
|
2011-02-25 21:41:19 +00:00
|
|
|
}
|
2011-02-25 20:16:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 16:22:27 +00:00
|
|
|
$canonicaltitle = isset( $prop['canonicaltitle'] );
|
2011-02-25 21:41:19 +00:00
|
|
|
$url = isset( $prop['url'] );
|
|
|
|
|
$sha1 = isset( $prop['sha1'] );
|
|
|
|
|
$meta = isset( $prop['metadata'] );
|
2013-08-12 16:18:29 +00:00
|
|
|
$extmetadata = isset( $prop['extmetadata'] );
|
2011-02-25 21:41:19 +00:00
|
|
|
$mime = isset( $prop['mime'] );
|
2011-03-05 14:56:49 +00:00
|
|
|
$mediatype = isset( $prop['mediatype'] );
|
2011-02-25 21:41:19 +00:00
|
|
|
$archive = isset( $prop['archivename'] );
|
|
|
|
|
$bitdepth = isset( $prop['bitdepth'] );
|
2013-05-26 16:25:30 +00:00
|
|
|
$uploadwarning = isset( $prop['uploadwarning'] );
|
2011-02-25 21:41:19 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $uploadwarning ) {
|
|
|
|
|
$vals['html'] = SpecialUpload::getExistsWarning( UploadBase::getExistsWarning( $file ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_FILE ) ) {
|
2011-02-25 20:16:19 +00:00
|
|
|
$vals['filehidden'] = '';
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $anyHidden && $file->isDeleted( File::DELETED_RESTRICTED ) ) {
|
|
|
|
|
$vals['suppressed'] = true;
|
|
|
|
|
}
|
2010-07-23 07:33:40 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( !$canShowField( File::DELETED_FILE ) ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
//Early return, tidier than indenting all following things one level
|
|
|
|
|
return $vals;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 16:22:27 +00:00
|
|
|
if ( $canonicaltitle ) {
|
|
|
|
|
$vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $url ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
if ( !is_null( $thumbParams ) ) {
|
|
|
|
|
$mto = $file->transform( $thumbParams );
|
2013-02-01 23:14:09 +00:00
|
|
|
self::$transformCount++;
|
2011-02-25 20:22:54 +00:00
|
|
|
if ( $mto && !$mto->isError() ) {
|
2011-08-19 15:46:08 +00:00
|
|
|
$vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
|
2011-02-25 20:22:54 +00:00
|
|
|
|
|
|
|
|
// bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
|
|
|
|
|
// thumbnail sizes for the thumbnail actual size
|
|
|
|
|
if ( $mto->getUrl() !== $file->getUrl() ) {
|
|
|
|
|
$vals['thumbwidth'] = intval( $mto->getWidth() );
|
|
|
|
|
$vals['thumbheight'] = intval( $mto->getHeight() );
|
|
|
|
|
} else {
|
|
|
|
|
$vals['thumbwidth'] = intval( $file->getWidth() );
|
|
|
|
|
$vals['thumbheight'] = intval( $file->getHeight() );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-02 14:49:12 +00:00
|
|
|
if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
|
2012-12-09 03:27:02 +00:00
|
|
|
list( , $mime ) = $file->getHandler()->getThumbType(
|
2012-07-13 15:07:56 +00:00
|
|
|
$mto->getExtension(), $file->getMimeType(), $thumbParams );
|
2011-04-02 14:49:12 +00:00
|
|
|
$vals['thumbmime'] = $mime;
|
2010-06-08 12:40:11 +00:00
|
|
|
}
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif ( $mto && $mto->isError() ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
$vals['thumberror'] = $mto->toText();
|
2011-02-11 15:40:39 +00:00
|
|
|
}
|
2008-01-20 13:09:32 +00:00
|
|
|
}
|
2011-08-19 15:46:08 +00:00
|
|
|
$vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT );
|
|
|
|
|
$vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
|
2011-02-25 20:22:54 +00:00
|
|
|
}
|
2010-12-30 00:56:30 +00:00
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $sha1 ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
$vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
|
|
|
|
|
}
|
2011-02-25 20:16:19 +00:00
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $meta ) {
|
2012-09-23 18:52:00 +00:00
|
|
|
wfSuppressWarnings();
|
2011-04-16 01:23:15 +00:00
|
|
|
$metadata = unserialize( $file->getMetadata() );
|
2012-09-23 18:52:00 +00:00
|
|
|
wfRestoreWarnings();
|
|
|
|
|
if ( $metadata && $version !== 'latest' ) {
|
2011-04-16 01:23:15 +00:00
|
|
|
$metadata = $file->convertMetadataVersion( $metadata, $version );
|
|
|
|
|
}
|
|
|
|
|
$vals['metadata'] = $metadata ? self::processMetaData( $metadata, $result ) : null;
|
2011-02-25 20:22:54 +00:00
|
|
|
}
|
2011-02-25 20:16:19 +00:00
|
|
|
|
2013-08-12 16:18:29 +00:00
|
|
|
if ( $extmetadata ) {
|
|
|
|
|
// Note, this should return an array where all the keys
|
|
|
|
|
// start with a letter, and all the values are strings.
|
|
|
|
|
// Thus there should be no issue with format=xml.
|
|
|
|
|
$format = new FormatMetadata;
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$format->setSingleLanguage( !$opts['multilang'] );
|
|
|
|
|
$format->getContext()->setLanguage( $opts['language'] );
|
2013-08-12 16:18:29 +00:00
|
|
|
$extmetaArray = $format->fetchExtendedMetadata( $file );
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $opts['extmetadatafilter'] ) {
|
2013-11-14 19:26:00 +00:00
|
|
|
$extmetaArray = array_intersect_key(
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$extmetaArray, array_flip( $opts['extmetadatafilter'] )
|
2013-11-14 19:26:00 +00:00
|
|
|
);
|
|
|
|
|
}
|
2013-08-12 16:18:29 +00:00
|
|
|
$vals['extmetadata'] = $extmetaArray;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $mime ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
$vals['mime'] = $file->getMimeType();
|
|
|
|
|
}
|
2011-04-04 21:13:34 +00:00
|
|
|
|
2011-03-05 14:56:49 +00:00
|
|
|
if ( $mediatype ) {
|
|
|
|
|
$vals['mediatype'] = $file->getMediaType();
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $archive && $file->isOld() ) {
|
2011-02-25 20:22:54 +00:00
|
|
|
$vals['archivename'] = $file->getArchiveName();
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2011-02-25 21:41:19 +00:00
|
|
|
if ( $bitdepth ) {
|
2011-02-25 20:24:08 +00:00
|
|
|
$vals['bitdepth'] = $file->getBitDepth();
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-01-20 13:09:32 +00:00
|
|
|
return $vals;
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2013-02-01 23:14:09 +00:00
|
|
|
/**
|
|
|
|
|
* Get the count of image transformations performed
|
|
|
|
|
*
|
|
|
|
|
* If this is >= TRANSFORM_LIMIT, you should probably stop processing images.
|
|
|
|
|
*
|
|
|
|
|
* @return integer count
|
|
|
|
|
*/
|
|
|
|
|
static function getTransformCount() {
|
|
|
|
|
return self::$transformCount;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-19 00:30:18 +00:00
|
|
|
/**
|
2010-09-25 16:56:03 +00:00
|
|
|
*
|
2010-09-25 17:17:27 +00:00
|
|
|
* @param $metadata Array
|
|
|
|
|
* @param $result ApiResult
|
|
|
|
|
* @return Array
|
2010-09-25 16:56:03 +00:00
|
|
|
*/
|
2010-02-24 14:00:23 +00:00
|
|
|
public static function processMetaData( $metadata, $result ) {
|
2009-02-03 16:25:50 +00:00
|
|
|
$retval = array();
|
2009-03-25 13:59:06 +00:00
|
|
|
if ( is_array( $metadata ) ) {
|
2010-02-24 14:00:23 +00:00
|
|
|
foreach ( $metadata as $key => $value ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$r = array( 'name' => $key );
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( is_array( $value ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$r['value'] = self::processMetaData( $value, $result );
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2009-03-25 13:59:06 +00:00
|
|
|
$r['value'] = $value;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2009-03-25 13:59:06 +00:00
|
|
|
$retval[] = $r;
|
|
|
|
|
}
|
2009-02-03 16:25:50 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$result->setIndexedTagName( $retval, 'metadata' );
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2009-02-03 16:25:50 +00:00
|
|
|
return $retval;
|
|
|
|
|
}
|
2008-01-20 13:09:32 +00:00
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
public function getCacheMode( $params ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $this->userCanSeeRevDel() ) {
|
|
|
|
|
return 'private';
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
return 'public';
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-19 00:30:18 +00:00
|
|
|
/**
|
|
|
|
|
* @param $img File
|
2013-03-11 03:45:51 +00:00
|
|
|
* @param null|string $start
|
2011-02-19 00:30:18 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-02-01 22:17:19 +00:00
|
|
|
protected function getContinueStr( $img, $start = null ) {
|
|
|
|
|
if ( $start === null ) {
|
|
|
|
|
$start = $img->getTimestamp();
|
|
|
|
|
}
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2013-07-15 15:41:06 +00:00
|
|
|
return $img->getOriginalTitle()->getDBkey() . '|' . $start;
|
2009-02-10 19:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2013-10-28 18:18:05 +00:00
|
|
|
global $wgContLang;
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
|
|
|
|
'prop' => array(
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_DFLT => 'timestamp|user',
|
|
|
|
|
ApiBase::PARAM_TYPE => self::getPropertyNames()
|
2007-07-07 03:05:09 +00:00
|
|
|
),
|
2008-01-20 13:09:32 +00:00
|
|
|
'limit' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase::PARAM_DFLT => 1,
|
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
|
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
|
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2008-01-20 13:09:32 +00:00
|
|
|
),
|
|
|
|
|
'start' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2008-01-20 13:09:32 +00:00
|
|
|
),
|
|
|
|
|
'end' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2008-01-20 13:09:32 +00:00
|
|
|
),
|
2008-01-18 20:17:26 +00:00
|
|
|
'urlwidth' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
2010-11-03 04:32:41 +00:00
|
|
|
ApiBase::PARAM_DFLT => -1
|
2008-01-18 20:17:26 +00:00
|
|
|
),
|
|
|
|
|
'urlheight' => array(
|
2010-02-24 14:00:23 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
2010-11-03 04:32:41 +00:00
|
|
|
ApiBase::PARAM_DFLT => -1
|
* 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
|
|
|
),
|
2011-04-16 01:23:15 +00:00
|
|
|
'metadataversion' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_DFLT => '1',
|
|
|
|
|
),
|
2013-10-28 18:18:05 +00:00
|
|
|
'extmetadatalanguage' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_DFLT => $wgContLang->getCode(),
|
|
|
|
|
),
|
|
|
|
|
'extmetadatamultilang' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'boolean',
|
|
|
|
|
ApiBase::PARAM_DFLT => false,
|
|
|
|
|
),
|
2013-11-14 19:26:00 +00:00
|
|
|
'extmetadatafilter' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
),
|
2011-02-05 08:49:48 +00:00
|
|
|
'urlparam' => array(
|
2011-02-13 07:30:49 +00:00
|
|
|
ApiBase::PARAM_DFLT => '',
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
2011-02-05 08:49:48 +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
|
|
|
'continue' => null,
|
2012-08-01 17:51:23 +00:00
|
|
|
'localonly' => false,
|
2007-07-07 03:05:09 +00:00
|
|
|
);
|
|
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2009-08-26 17:30:36 +00:00
|
|
|
/**
|
|
|
|
|
* Returns all possible parameters to iiprop
|
2011-03-21 23:51:26 +00:00
|
|
|
*
|
|
|
|
|
* @param array $filter List of properties to filter out
|
|
|
|
|
*
|
2011-02-06 23:59:03 +00:00
|
|
|
* @return Array
|
2009-08-26 17:30:36 +00:00
|
|
|
*/
|
2011-03-21 23:51:26 +00:00
|
|
|
public static function getPropertyNames( $filter = array() ) {
|
|
|
|
|
return array_diff( array_keys( self::getProperties() ), $filter );
|
2011-03-20 23:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-03-21 23:51:26 +00:00
|
|
|
* Returns array key value pairs of properties and their descriptions
|
2011-03-20 23:50:59 +00:00
|
|
|
*
|
2013-03-11 03:45:51 +00:00
|
|
|
* @param string $modulePrefix
|
2011-03-20 23:50:59 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2012-07-13 15:25:22 +00:00
|
|
|
private static function getProperties( $modulePrefix = '' ) {
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
2011-03-20 23:50:59 +00:00
|
|
|
'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
|
|
|
|
|
'user' => ' user - Adds the user who uploaded the image version',
|
|
|
|
|
'userid' => ' userid - Add the user ID that uploaded the image version',
|
|
|
|
|
'comment' => ' comment - Comment on the version',
|
|
|
|
|
'parsedcomment' => ' parsedcomment - Parse the comment on the version',
|
2013-12-09 16:22:27 +00:00
|
|
|
'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
|
2011-03-20 23:50:59 +00:00
|
|
|
'url' => ' url - Gives URL to the image and the description page',
|
2013-11-14 16:17:22 +00:00
|
|
|
'size' => ' size - Adds the size of the image in bytes ' .
|
|
|
|
|
'and the height, width and page count (if applicable)',
|
|
|
|
|
'dimensions' => ' dimensions - Alias for size', // B/C with Allimages
|
2011-03-20 23:50:59 +00:00
|
|
|
'sha1' => ' sha1 - Adds SHA-1 hash for the image',
|
|
|
|
|
'mime' => ' mime - Adds MIME type of the image',
|
2012-07-13 15:25:22 +00:00
|
|
|
'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
|
|
|
|
|
' (requires url and param ' . $modulePrefix . 'urlwidth)',
|
2011-03-20 23:50:59 +00:00
|
|
|
'mediatype' => ' mediatype - Adds the media type of the image',
|
2013-05-10 11:51:06 +00:00
|
|
|
'metadata' => ' metadata - Lists Exif metadata for the version of the image',
|
2013-11-14 16:17:22 +00:00
|
|
|
'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
|
|
|
|
|
'from multiple sources. Results are HTML formatted.',
|
|
|
|
|
'archivename' => ' archivename - Adds the file name of the archive ' .
|
|
|
|
|
'version for non-latest versions',
|
2011-03-20 23:50:59 +00:00
|
|
|
'bitdepth' => ' bitdepth - Adds the bit depth of the version',
|
2013-11-14 16:17:22 +00:00
|
|
|
'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
|
|
|
|
|
'get information about an existing file. Not intended for use outside MediaWiki core',
|
2010-02-24 14:00:23 +00:00
|
|
|
);
|
2009-08-26 17:30:36 +00:00
|
|
|
}
|
2007-07-07 03:05:09 +00:00
|
|
|
|
2010-11-03 04:32:41 +00:00
|
|
|
/**
|
2011-02-06 23:59:03 +00:00
|
|
|
* Returns the descriptions for the properties provided by getPropertyNames()
|
2011-06-17 16:03:52 +00:00
|
|
|
*
|
2011-03-21 23:51:26 +00:00
|
|
|
* @param array $filter List of properties to filter out
|
2013-04-01 17:16:34 +00:00
|
|
|
* @param string $modulePrefix
|
2011-02-06 23:59:03 +00:00
|
|
|
* @return array
|
2010-11-03 04:32:41 +00:00
|
|
|
*/
|
2012-07-13 15:25:22 +00:00
|
|
|
public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
|
2011-03-20 23:50:59 +00:00
|
|
|
return array_merge(
|
|
|
|
|
array( 'What image information to get:' ),
|
2012-07-13 15:25:22 +00:00
|
|
|
array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) )
|
2011-03-20 23:50:59 +00:00
|
|
|
);
|
2011-02-06 23:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the API documentation for the parameters.
|
2011-06-05 23:44:37 +00:00
|
|
|
* @return Array parameter documentation.
|
2011-02-06 23:59:03 +00:00
|
|
|
*/
|
|
|
|
|
public function getParamDescription() {
|
|
|
|
|
$p = $this->getModulePrefix();
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2011-02-06 23:59:03 +00:00
|
|
|
return array(
|
2012-07-13 15:25:22 +00:00
|
|
|
'prop' => self::getPropertyDescriptions( array(), $p ),
|
2013-11-14 16:17:22 +00:00
|
|
|
'urlwidth' => array(
|
|
|
|
|
"If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
|
2013-04-04 15:34:22 +00:00
|
|
|
'For performance reasons if this option is used, ' .
|
2013-11-14 16:17:22 +00:00
|
|
|
'no more than ' . self::TRANSFORM_LIMIT . ' scaled images will be returned.'
|
|
|
|
|
),
|
2013-04-23 03:46:15 +00:00
|
|
|
'urlheight' => "Similar to {$p}urlwidth.",
|
2011-02-13 07:30:49 +00:00
|
|
|
'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
|
|
|
|
|
"might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
|
2013-04-04 15:34:22 +00:00
|
|
|
'limit' => 'How many image revisions to return per image',
|
2010-11-03 04:32:41 +00:00
|
|
|
'start' => 'Timestamp to start listing from',
|
|
|
|
|
'end' => 'Timestamp to stop listing at',
|
2013-11-14 16:17:22 +00:00
|
|
|
'metadataversion'
|
|
|
|
|
=> array( "Version of metadata to use. if 'latest' is specified, use latest version.",
|
2013-11-14 12:53:20 +00:00
|
|
|
"Defaults to '1' for backwards compatibility" ),
|
2013-11-14 16:17:22 +00:00
|
|
|
'extmetadatalanguage' => array(
|
|
|
|
|
'What language to fetch extmetadata in. This affects both which',
|
2013-11-14 12:53:20 +00:00
|
|
|
'translation to fetch, if multiple are available, as well as how things',
|
2013-11-14 16:17:22 +00:00
|
|
|
'like numbers and various values are formatted.'
|
|
|
|
|
),
|
|
|
|
|
'extmetadatamultilang'
|
|
|
|
|
=>'If translations for extmetadata property are available, fetch all of them.',
|
|
|
|
|
'extmetadatafilter'
|
|
|
|
|
=> "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
|
2013-11-16 19:09:17 +00:00
|
|
|
'continue' => 'If the query response includes a continue value, ' .
|
|
|
|
|
'use it here to get another page of results',
|
2012-08-01 17:51:23 +00:00
|
|
|
'localonly' => 'Look only for files in the local repository',
|
2007-07-07 03:05:09 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
public static function getResultPropertiesFiltered( $filter = array() ) {
|
|
|
|
|
$props = array(
|
|
|
|
|
'timestamp' => array(
|
|
|
|
|
'timestamp' => 'timestamp'
|
|
|
|
|
),
|
|
|
|
|
'user' => array(
|
|
|
|
|
'userhidden' => 'boolean',
|
|
|
|
|
'user' => 'string',
|
|
|
|
|
'anon' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'userid' => array(
|
|
|
|
|
'userhidden' => 'boolean',
|
|
|
|
|
'userid' => 'integer',
|
|
|
|
|
'anon' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'size' => array(
|
|
|
|
|
'size' => 'integer',
|
|
|
|
|
'width' => 'integer',
|
|
|
|
|
'height' => 'integer',
|
|
|
|
|
'pagecount' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
2012-10-31 19:11:09 +00:00
|
|
|
'dimensions' => array(
|
|
|
|
|
'size' => 'integer',
|
|
|
|
|
'width' => 'integer',
|
|
|
|
|
'height' => 'integer',
|
|
|
|
|
'pagecount' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
'comment' => array(
|
|
|
|
|
'commenthidden' => 'boolean',
|
|
|
|
|
'comment' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'parsedcomment' => array(
|
|
|
|
|
'commenthidden' => 'boolean',
|
|
|
|
|
'parsedcomment' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
2013-12-09 16:22:27 +00:00
|
|
|
'canonicaltitle' => array(
|
|
|
|
|
'canonicaltitle' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
'url' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'thumburl' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'thumbwidth' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'thumbheight' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'thumberror' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'url' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'descriptionurl' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'sha1' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'sha1' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'mime' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'mime' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
2012-10-31 19:11:09 +00:00
|
|
|
'thumbmime' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'thumbmime' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
'mediatype' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'mediatype' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'archivename' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'archivename' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'bitdepth' => array(
|
|
|
|
|
'filehidden' => 'boolean',
|
|
|
|
|
'bitdepth' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
);
|
2013-11-14 12:53:20 +00:00
|
|
|
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
return array_diff_key( $props, array_flip( $filter ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResultProperties() {
|
|
|
|
|
return self::getResultPropertiesFiltered();
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2010-05-25 20:46:09 +00:00
|
|
|
return 'Returns image information and upload history';
|
2010-02-13 01:41:37 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2010-02-13 00:48:31 +00:00
|
|
|
public function getPossibleErrors() {
|
2011-02-05 08:49:48 +00:00
|
|
|
$p = $this->getModulePrefix();
|
2013-11-14 12:53:20 +00:00
|
|
|
|
2010-02-13 00:48:31 +00:00
|
|
|
return array_merge( parent::getPossibleErrors(), array(
|
2011-02-20 13:59:40 +00:00
|
|
|
array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ),
|
2011-02-05 08:49:48 +00:00
|
|
|
array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ),
|
2011-02-13 07:30:49 +00:00
|
|
|
array( 'code' => 'urlparam_no_width', 'info' => "{$p}urlparam requires {$p}urlwidth" ),
|
2010-02-13 00:48:31 +00:00
|
|
|
) );
|
2007-07-07 03:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getExamples() {
|
2010-02-24 14:00:23 +00:00
|
|
|
return array(
|
2009-03-09 10:44:34 +00:00
|
|
|
'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
|
2013-11-14 16:17:22 +00:00
|
|
|
'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
|
|
|
|
|
'iiend=20071231235959&iiprop=timestamp|user|url',
|
2007-07-07 03:05:09 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:51:11 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
|
2011-07-17 16:51:11 +00:00
|
|
|
}
|
2007-07-07 03:05:09 +00:00
|
|
|
}
|