15 private $listCallback;
42 callable $listCallback,
48 $this->listCallback = $listCallback;
49 $this->cache = $cache;
50 $this->repoGroup = $repoGroup;
51 $this->titleParser = $titleParser;
52 $this->hookRunner =
new HookRunner( $hookContainer );
80 if ( !$this->hookRunner->onBadImage(
$name, $bad ) ) {
84 if ( $this->badFiles ===
null ) {
85 $list = ( $this->listCallback )();
86 $key = $this->cache->makeKey(
'bad-image-list', sha1( $list ) );
87 $this->badFiles = $this->cache->getWithSetCallback(
90 function () use ( $list ) {
91 return $this->buildBadFilesList( $list );
96 return isset( $this->badFiles[
$name] ) && ( !$contextTitle ||
97 !isset( $this->badFiles[
$name][$contextTitle->getNamespace()][$contextTitle->getDBkey()] ) );
104 private function buildBadFilesList(
string $list ): array {
106 $lines = explode(
"\n", $list );
107 foreach (
$lines as $line ) {
109 if ( substr( $line, 0, 1 ) !==
'*' ) {
116 if ( !preg_match_all(
'/\[\[:?(.*?)\]\]/', $line, $m ) ) {
122 foreach ( $m[1] as $i => $titleText ) {
124 $title = $this->titleParser->parseTitle( $titleText );
125 }
catch ( MalformedTitleException $e ) {
129 $fileDBkey =
$title->getDBkey();
131 $exceptions[
$title->getNamespace()][
$title->getDBkey()] =
true;
135 if ( $fileDBkey !==
null ) {
136 $ret[$fileDBkey] = $exceptions;
146 class_alias( BadFileLookup::class,
'MediaWiki\\BadFileLookup' );
Class representing a cache/ephemeral data store.
Title string false $title
string null $name
The name of a file from its title object.
isBadFile( $name, LinkTarget $contextTitle=null)
Determine if a file exists on the 'bad image list'.
__construct(callable $listCallback, BagOStuff $cache, RepoGroup $repoGroup, TitleParser $titleParser, HookContainer $hookContainer)
Do not call directly.
Prioritized list of file repositories.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!file_exists( $CREDITS)) $lines