Merge "Document type of LogEntry::isPatrollable property"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 14 Dec 2016 19:30:11 +0000 (19:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 14 Dec 2016 19:30:11 +0000 (19:30 +0000)
includes/GlobalFunctions.php
includes/api/ApiQueryImageInfo.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
includes/libs/lockmanager/LockManager.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialMIMEsearch.php
includes/specials/SpecialNewimages.php
resources/src/mediawiki.special/mediawiki.special.apisandbox.js
tests/phan/config.php

index b3ccc56..f9f499a 100644 (file)
@@ -3518,7 +3518,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
        # Run the extension hook
        $bad = false;
        if ( !Hooks::run( 'BadImage', [ $name, &$bad ] ) ) {
-               return $bad;
+               return (bool)$bad;
        }
 
        $cache = ObjectCache::getLocalServerInstance( 'hash' );
index 0bbfad3..c9dae8d 100644 (file)
@@ -58,6 +58,15 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        '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] );
@@ -95,13 +104,16 @@ class ApiQueryImageInfo extends ApiQueryBase {
 
                        $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 ) ],
@@ -128,10 +140,14 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        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
@@ -688,6 +704,9 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                ApiBase::PARAM_DFLT => '',
                                ApiBase::PARAM_TYPE => 'string',
                        ],
+                       'badfilecontexttitle' => [
+                               ApiBase::PARAM_TYPE => 'string',
+                       ],
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        ],
@@ -733,6 +752,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                '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 )
                );
index 240e167..b2f9446 100644 (file)
        "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.",
index 2a1c913..57cd43f 100644 (file)
        "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}}",
index bee34dc..c629e7d 100644 (file)
@@ -34,7 +34,7 @@ use Wikimedia\WaitConditionLoop;
  *
  * 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.
@@ -170,7 +170,7 @@ abstract class LockManager {
        /**
         * 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
@@ -182,7 +182,7 @@ abstract class LockManager {
        /**
         * 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
index 2936754..5c8b3a6 100644 (file)
@@ -206,7 +206,7 @@ class DeletedContributionsPage extends SpecialPage {
                        ],
                ];
 
-               $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
index c61609d..d8a468f 100644 (file)
@@ -119,7 +119,7 @@ class MIMEsearchPage extends QueryPage {
                        ],
                ];
 
-               $form = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
+               HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
                        ->setWrapperLegendMsg( 'mimesearch' )
                        ->setSubmitTextMsg( 'ilsubmit' )
                        ->setAction( $this->getPageTitle()->getLocalURL() )
index 077a5d2..9e3a750 100644 (file)
@@ -108,7 +108,7 @@ class SpecialNewFiles extends IncludableSpecialPage {
                        unset( $formDescriptor['hidepatrolled'] );
                }
 
-               $form = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
+               HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
                        ->setWrapperLegendMsg( 'newimages-legend' )
                        ->setSubmitTextMsg( 'ilsubmit' )
                        ->setMethod( 'get' )
index 60155fd..43321fe 100644 (file)
                                                } 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;
                                                }
                                        } );
index dc6bb89..6d1407b 100644 (file)
@@ -341,8 +341,6 @@ return [
                "PhanTypeMissingReturn",
                // approximate error count: 5
                "PhanTypeNonVarPassByRef",
-               // approximate error count: 3
-               "PhanTypeVoidAssignment",
                // approximate error count: 27
                "PhanUndeclaredConstant",
                // approximate error count: 185