15 private $listCallback;
42 callable $listCallback,
48 $this->listCallback = $listCallback;
50 $this->repoGroup = $repoGroup;
51 $this->titleParser = $titleParser;
52 $this->hookRunner =
new HookRunner( $hookContainer );
71 $file = $this->repoGroup->findFile( $name );
75 $name =
$file->getTitle()->getDBkey();
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 );
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 );
129 $fileDBkey =
$title->getDBkey();
131 $exceptions[
$title->getNamespace()][
$title->getDBkey()] =
true;
135 if ( $fileDBkey !==
null ) {
136 $ret[$fileDBkey] = $exceptions;
Class representing a cache/ephemeral data store.
Prioritized list of file repositories.
A title parser service for MediaWiki.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!file_exists( $CREDITS)) $lines