# Run the extension hook
$bad = false;
if ( !Hooks::run( 'BadImage', [ $name, &$bad ] ) ) {
- return $bad;
+ return (bool)$bad;
}
$cache = ObjectCache::getLocalServerInstance( 'hash' );
'revdelUser' => $this->getUser(),
];
+ if ( isset( $params['badfilecontexttitle'] ) ) {
+ $badFileContextTitle = Title::newFromText( $params['badfilecontexttitle'] );
+ if ( !$badFileContextTitle ) {
+ $this->dieUsage( 'Invalid title in badfilecontexttitle parameter', 'invalid-title' );
+ }
+ } else {
+ $badFileContextTitle = false;
+ }
+
$pageIds = $this->getPageSet()->getGoodAndMissingTitlesByNamespace();
if ( !empty( $pageIds[NS_FILE] ) ) {
$titles = array_keys( $pageIds[NS_FILE] );
$result = $this->getResult();
foreach ( $titles as $title ) {
+ $info = [];
$pageId = $pageIds[NS_FILE][$title];
$start = $title === $fromTitle ? $fromTimestamp : $params['start'];
if ( !isset( $images[$title] ) ) {
- if ( isset( $prop['uploadwarning'] ) ) {
- // Uploadwarning needs info about non-existing files
+ if ( isset( $prop['uploadwarning'] ) || isset( $prop['badfile'] ) ) {
+ // uploadwarning and badfile need info about non-existing files
$images[$title] = wfLocalFile( $title );
+ // Doesn't exist, so set an empty image repository
+ $info['imagerepository'] = '';
} else {
$result->addValue(
[ 'query', 'pages', intval( $pageId ) ],
break;
}
- $fit = $result->addValue(
- [ 'query', 'pages', intval( $pageId ) ],
- 'imagerepository', $img->getRepoName()
- );
+ if ( !isset( $info['imagerepository'] ) ) {
+ $info['imagerepository'] = $img->getRepoName();
+ }
+ if ( isset( $prop['badfile'] ) ) {
+ $info['badfile'] = (bool)wfIsBadImage( $title, $badFileContextTitle );
+ }
+
+ $fit = $result->addValue( [ 'query', 'pages' ], intval( $pageId ), $info );
if ( !$fit ) {
if ( count( $pageIds[NS_FILE] ) == 1 ) {
// The user is screwed. imageinfo can't be solely
ApiBase::PARAM_DFLT => '',
ApiBase::PARAM_TYPE => 'string',
],
+ 'badfilecontexttitle' => [
+ ApiBase::PARAM_TYPE => 'string',
+ ],
'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
],
'archivename' => 'apihelp-query+imageinfo-paramvalue-prop-archivename',
'bitdepth' => 'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
'uploadwarning' => 'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
+ 'badfile' => 'apihelp-query+imageinfo-paramvalue-prop-badfile',
],
array_flip( $filter )
);
"apihelp-query+imageinfo-paramvalue-prop-archivename": "Adds the filename of the archive version for non-latest versions.",
"apihelp-query+imageinfo-paramvalue-prop-bitdepth": "Adds the bit depth of the version.",
"apihelp-query+imageinfo-paramvalue-prop-uploadwarning": "Used by the Special:Upload page to get information about an existing file. Not intended for use outside MediaWiki core.",
+ "apihelp-query+imageinfo-paramvalue-prop-badfile": "Adds whether the file is on the [[MediaWiki:Bad image list]]",
"apihelp-query+imageinfo-param-limit": "How many file revisions to return per file.",
"apihelp-query+imageinfo-param-start": "Timestamp to start listing from.",
"apihelp-query+imageinfo-param-end": "Timestamp to stop listing at.",
"apihelp-query+imageinfo-param-extmetadatamultilang": "If translations for extmetadata property are available, fetch all of them.",
"apihelp-query+imageinfo-param-extmetadatafilter": "If specified and non-empty, only these keys will be returned for $1prop=extmetadata.",
"apihelp-query+imageinfo-param-urlparam": "A handler specific parameter string. For example, PDFs might use <kbd>page15-100px</kbd>. <var>$1urlwidth</var> must be used and be consistent with <var>$1urlparam</var>.",
+ "apihelp-query+imageinfo-param-badfilecontexttitle": "If <kbd>$2prop=badfile</kbd> is set, this is the page title used when evaluting the [[MediaWiki:Bad image list]]",
"apihelp-query+imageinfo-param-localonly": "Look only for files in the local repository.",
"apihelp-query+imageinfo-example-simple": "Fetch information about the current version of [[:File:Albert Einstein Head.jpg]].",
"apihelp-query+imageinfo-example-dated": "Fetch information about versions of [[:File:Test.jpg]] from 2008 and later.",
"apihelp-query+imageinfo-paramvalue-prop-archivename": "{{doc-apihelp-paramvalue|query+imageinfo|prop|archivename}}",
"apihelp-query+imageinfo-paramvalue-prop-bitdepth": "{{doc-apihelp-paramvalue|query+imageinfo|prop|bitdepth}}",
"apihelp-query+imageinfo-paramvalue-prop-uploadwarning": "{{doc-apihelp-paramvalue|query+imageinfo|prop|uploadwarning}}",
+ "apihelp-query+imageinfo-paramvalue-prop-badfile": "{{doc-apihelp-paramvalue|query+imageinfo|prop|badfile}}",
"apihelp-query+imageinfo-param-limit": "{{doc-apihelp-param|query+imageinfo|limit}}",
"apihelp-query+imageinfo-param-start": "{{doc-apihelp-param|query+imageinfo|start}}",
"apihelp-query+imageinfo-param-end": "{{doc-apihelp-param|query+imageinfo|end}}",
"apihelp-query+imageinfo-param-extmetadatamultilang": "{{doc-apihelp-param|query+imageinfo|extmetadatamultilang}}",
"apihelp-query+imageinfo-param-extmetadatafilter": "{{doc-apihelp-param|query+imageinfo|extmetadatafilter}}",
"apihelp-query+imageinfo-param-urlparam": "{{doc-apihelp-param|query+imageinfo|urlparam}}",
+ "apihelp-query+imageinfo-param-badfilecontexttitle": "{{doc-apihelp-param|query+imageinfo|badfilecontexttitle}}",
"apihelp-query+imageinfo-param-localonly": "{{doc-apihelp-param|query+imageinfo|localonly}}",
"apihelp-query+imageinfo-example-simple": "{{doc-apihelp-example|query+imageinfo}}",
"apihelp-query+imageinfo-example-dated": "{{doc-apihelp-example|query+imageinfo}}",
*
* Locks on resource keys can either be shared or exclusive.
*
- * Implementations must keep track of what is locked by this proccess
+ * Implementations must keep track of what is locked by this process
* in-memory and support nested locking calls (using reference counting).
* At least LOCK_UW and LOCK_EX must be implemented. LOCK_SH can be a no-op.
* Locks should either be non-blocking or have low wait timeouts.
/**
* Get the base 36 SHA-1 of a string, padded to 31 digits.
* Before hashing, the path will be prefixed with the domain ID.
- * This should be used interally for lock key or file names.
+ * This should be used internally for lock key or file names.
*
* @param string $path
* @return string
/**
* Get the base 16 SHA-1 of a string, padded to 31 digits.
* Before hashing, the path will be prefixed with the domain ID.
- * This should be used interally for lock key or file names.
+ * This should be used internally for lock key or file names.
*
* @param string $path
* @return string
],
];
- $form = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
+ HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
->setWrapperLegendMsg( 'sp-contributions-search' )
->setSubmitTextMsg( 'sp-contributions-submit' )
// prevent setting subpage and 'target' parameter at the same time
],
];
- $form = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
+ HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
->setWrapperLegendMsg( 'mimesearch' )
->setSubmitTextMsg( 'ilsubmit' )
->setAction( $this->getPageTitle()->getLocalURL() )
unset( $formDescriptor['hidepatrolled'] );
}
- $form = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
+ HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
->setWrapperLegendMsg( 'newimages-legend' )
->setSubmitTextMsg( 'ilsubmit' )
->setMethod( 'get' )
} else {
n = +value;
return !isNaN( n ) && isFinite( n ) &&
- // eslint-disable-next-line no-bitwise
- ( n | 0 ) === n &&
+ Math.floor( n ) === n &&
n >= pi.min && n <= pi.apiSandboxMax;
}
} );
"PhanTypeMissingReturn",
// approximate error count: 5
"PhanTypeNonVarPassByRef",
- // approximate error count: 3
- "PhanTypeVoidAssignment",
// approximate error count: 27
"PhanUndeclaredConstant",
// approximate error count: 185