BadFile keeps a "bad file list", not a "blacklist"
Bug: T254646 Change-Id: I23c76f42d451b8d22f178efd6a3edbc822617831
This commit is contained in:
parent
9a9872e221
commit
a2d1bf79c3
1 changed files with 10 additions and 10 deletions
|
|
@ -11,8 +11,8 @@ use RepoGroup;
|
|||
use TitleParser;
|
||||
|
||||
class BadFileLookup {
|
||||
/** @var callable Returns contents of blacklist (see comment for isBadFile()) */
|
||||
private $blacklistCallback;
|
||||
/** @var callable Returns contents of bad file list (see comment for isBadFile()) */
|
||||
private $listCallback;
|
||||
|
||||
/** @var BagOStuff Cache of parsed bad image list */
|
||||
private $cache;
|
||||
|
|
@ -23,7 +23,7 @@ class BadFileLookup {
|
|||
/** @var TitleParser */
|
||||
private $titleParser;
|
||||
|
||||
/** @var array|null Parsed blacklist */
|
||||
/** @var array|null Parsed bad file list */
|
||||
private $badFiles;
|
||||
|
||||
/** @var HookRunner */
|
||||
|
|
@ -32,20 +32,20 @@ class BadFileLookup {
|
|||
/**
|
||||
* Do not call directly. Use MediaWikiServices.
|
||||
*
|
||||
* @param callable $blacklistCallback Callback that returns wikitext of a file blacklist
|
||||
* @param BagOStuff $cache For caching parsed versions of the blacklist
|
||||
* @param callable $listCallback Callback that returns wikitext of a bad file list
|
||||
* @param BagOStuff $cache For caching parsed versions of the bad file list
|
||||
* @param RepoGroup $repoGroup
|
||||
* @param TitleParser $titleParser
|
||||
* @param HookContainer $hookContainer
|
||||
*/
|
||||
public function __construct(
|
||||
callable $blacklistCallback,
|
||||
callable $listCallback,
|
||||
BagOStuff $cache,
|
||||
RepoGroup $repoGroup,
|
||||
TitleParser $titleParser,
|
||||
HookContainer $hookContainer
|
||||
) {
|
||||
$this->blacklistCallback = $blacklistCallback;
|
||||
$this->listCallback = $listCallback;
|
||||
$this->cache = $cache;
|
||||
$this->repoGroup = $repoGroup;
|
||||
$this->titleParser = $titleParser;
|
||||
|
|
@ -83,15 +83,15 @@ class BadFileLookup {
|
|||
|
||||
if ( $this->badFiles === null ) {
|
||||
// Not used before in this request, try the cache
|
||||
$blacklist = ( $this->blacklistCallback )();
|
||||
$key = $this->cache->makeKey( 'bad-image-list', sha1( $blacklist ) );
|
||||
$list = ( $this->listCallback )();
|
||||
$key = $this->cache->makeKey( 'bad-image-list', sha1( $list ) );
|
||||
$this->badFiles = $this->cache->get( $key ) ?: null;
|
||||
}
|
||||
|
||||
if ( $this->badFiles === null ) {
|
||||
// Cache miss, build the list now
|
||||
$this->badFiles = [];
|
||||
$lines = explode( "\n", $blacklist );
|
||||
$lines = explode( "\n", $list );
|
||||
foreach ( $lines as $line ) {
|
||||
// List items only
|
||||
if ( substr( $line, 0, 1 ) !== '*' ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue