23 private const MAX_NUM_LINKS = 100;
37 private $page =
false;
49 $this->dbProvider = $dbProvider;
50 $this->repoGroup = $repoGroup;
51 $this->pageLookup = $pageLookup;
58 if ( $this->page === false ) {
59 $this->page = $this->pageLookup->getExistingPageByText(
71 public function run( $title ) {
72 $page = $this->getPage();
80 if ( !$this->
getAuthority()->authorizeRead(
'read', $page ) ) {
88 $results = $this->getDbResults( $page->getId() );
89 if ( count( $results ) > self::MAX_NUM_LINKS ) {
92 ->plaintextParams( $title )
93 ->numParams( self::MAX_NUM_LINKS ),
97 $response = $this->processDbResults( $results );
105 private function getDbResults(
int $pageId ) {
106 return $this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder()
108 ->from(
'imagelinks' )
109 ->where( [
'il_from' => $pageId ] )
111 ->limit( self::MAX_NUM_LINKS + 1 )
112 ->caller( __METHOD__ )->fetchFieldValues();
119 private function processDbResults( $results ) {
123 $findTitles = array_map(
static function ( $title ) use ( $performer ) {
126 'private' => $performer,
130 $files = $this->repoGroup->findFiles( $findTitles );
131 [ $maxWidth, $maxHeight ] = self::getImageLimitsFromOption(
137 'maxWidth' => $maxWidth,
138 'maxHeight' => $maxHeight,
142 foreach ( $files as
$file ) {
143 $response[] = $this->getFileInfo(
$file, $performer, $transforms );
160 self::PARAM_SOURCE =>
'path',
172 $page = $this->getPage();
178 return '"' . $page->getLatest() .
'@' .
wfTimestamp( TS_MW, $page->getTouched() ) .
'"';
186 $page = $this->getPage();
187 return $page ? $page->getTouched() :
null;
194 return (
bool)$this->getPage();
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
Prioritized list of file repositories.
Service for looking up information about wiki pages.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.