23 private const MAX_NUM_LINKS = 100;
26 private $loadBalancer;
37 private $page =
false;
49 $this->loadBalancer = $loadBalancer;
50 $this->repoGroup = $repoGroup;
51 $this->pageLookup = $pageLookup;
58 if ( $this->page === false ) {
59 $this->page = $this->pageLookup->getExistingPageByText(
72 $page = $this->getPage();
75 MessageValue::new(
'rest-nonexistent-title' )->plaintextParams(
$title ),
80 if ( !$this->
getAuthority()->authorizeRead(
'read', $page ) ) {
82 MessageValue::new(
'rest-permission-denied-title' )->plaintextParams(
$title ),
88 $results = $this->getDbResults( $page->getId() );
89 if ( count( $results ) > self::MAX_NUM_LINKS ) {
91 MessageValue::new(
'rest-media-too-many-links' )
92 ->plaintextParams(
$title )
93 ->numParams( self::MAX_NUM_LINKS ),
97 $response = $this->processDbResults( $results );
105 private function getDbResults(
int $pageId ) {
107 return $dbr->selectFieldValues(
110 [
'il_from' => $pageId ],
113 'ORDER BY' =>
'il_to',
114 'LIMIT' => self::MAX_NUM_LINKS + 1,
123 private function processDbResults( $results ) {
127 $findTitles = array_map(
static function (
$title ) use ( $performer ) {
130 'private' => $performer,
134 $files = $this->repoGroup->findFiles( $findTitles );
135 list( $maxWidth, $maxHeight ) = self::getImageLimitsFromOption(
141 'maxWidth' => $maxWidth,
142 'maxHeight' => $maxHeight,
146 foreach ( $files as
$file ) {
147 $response[] = $this->getFileInfo(
$file, $performer, $transforms );
164 self::PARAM_SOURCE =>
'path',
165 ParamValidator::PARAM_TYPE =>
'string',
166 ParamValidator::PARAM_REQUIRED =>
true,
176 $page = $this->getPage();
182 return '"' . $page->getLatest() .
'@' .
wfTimestamp( TS_MW, $page->getTouched() ) .
'"';
190 $page = $this->getPage();
195 return $page->getTouched();
202 return (
bool)$this->getPage();
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
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.