Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\LinkedData\EntityDataRequestHandler Class Reference

Request handler implementing a linked data interface for Wikibase entities. More...

Public Member Functions

 __construct (EntityDataUriManager $uriManager, HtmlCacheUpdater $htmlCacheUpdater, EntityIdParser $entityIdParser, EntityRevisionLookup $entityRevisionLookup, EntityRedirectLookup $entityRedirectLookup, EntityDataSerializationService $serializationService, EntityDataFormatProvider $entityDataFormatProvider, LoggerInterface $logger, array $entityTypesWithoutRdfOutput, $defaultFormat, $maxAge, $useCdn, $frameOptionsHeader, SubEntityTypesMapper $subEntityTypesMap)
 
 canHandleRequest ( $doc, WebRequest $request)
 Checks whether the request is complete, i.e.
 
 handleRequest ( $doc, WebRequest $request, OutputPage $output)
 Main method for handling requests.
 
 getCanonicalFormat ( $format)
 Returns the canonical format name for the given format.
 
 purgeWebCache (EntityId $id, int $revision)
 Purges the entity data identified by the doc parameter from any HTTP caches.
 
 httpContentNegotiation (WebRequest $request, OutputPage $output, EntityId $id, $revision=0)
 Applies HTTP content negotiation.
 
 outputData (WebRequest $request, EntityId $requestId, int $requestRevision, WebResponse $response, string $data, string $contentType, string $lastModified)
 Output the entity data and set the appropriate HTTP response headers.
 

Private Member Functions

 getEntityRevision (EntityId $id, $revision, $allowRedirects=false)
 Loads the requested Entity.
 
 validateRedirectability (EntityId $id, EntityId $redirectTargetId)
 
 getIncomingRedirects (EntityId $id)
 Loads incoming redirects referring to the given entity ID.
 

Private Attributes

const MINIMUM_MAX_AGE = 0
 Allowed smallest and biggest number of seconds for the "max-age=..." and "s-maxage=..." cache control parameters.
 
const MAXIMUM_MAX_AGE = 2678400
 
 $serializationService
 
 $uriManager
 
 $entityIdParser
 
 $entityRevisionLookup
 
 $entityRedirectLookup
 
 $entityDataFormatProvider
 
 $htmlCacheUpdater
 
 $logger
 
 $defaultFormat
 
 $maxAge
 
 $useCdn
 
 $frameOptionsHeader
 
 $entityTypesWithoutRdfOutput
 
 $subEntityTypesMap
 

Detailed Description

Request handler implementing a linked data interface for Wikibase entities.

Author
Daniel Kinzler
Thomas Pellissier Tanon
Anja Jentzsch < anja..nosp@m.jent.nosp@m.zsch@.nosp@m.wiki.nosp@m.media.nosp@m..de >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::__construct ( EntityDataUriManager $uriManager,
HtmlCacheUpdater $htmlCacheUpdater,
EntityIdParser $entityIdParser,
EntityRevisionLookup $entityRevisionLookup,
EntityRedirectLookup $entityRedirectLookup,
EntityDataSerializationService $serializationService,
EntityDataFormatProvider $entityDataFormatProvider,
LoggerInterface $logger,
array $entityTypesWithoutRdfOutput,
$defaultFormat,
$maxAge,
$useCdn,
$frameOptionsHeader,
SubEntityTypesMapper $subEntityTypesMap )
Parameters
EntityDataUriManager$uriManager
HtmlCacheUpdater$htmlCacheUpdater
EntityIdParser$entityIdParser
EntityRevisionLookup$entityRevisionLookup
EntityRedirectLookup$entityRedirectLookup
EntityDataSerializationService$serializationService
EntityDataFormatProvider$entityDataFormatProvider
LoggerInterface$logger
string[]$entityTypesWithoutRdfOutput
string$defaultFormatThe format as a file extension or MIME type.
int$maxAgenumber of seconds to cache entity data
bool$useCdndo we have web caches configured?
string | null$frameOptionsHeaderfor X-Frame-Options
SubEntityTypesMapper$subEntityTypesMap

Member Function Documentation

◆ canHandleRequest()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::canHandleRequest ( $doc,
WebRequest $request )

Checks whether the request is complete, i.e.

whether it contains all information needed to reply with entity data.

This does not check whether the request is valid and will actually produce a successful response.

Parameters
string | null$docDocument name, e.g. Q5 or Q5.json or Q5:33.xml
WebRequest$request
Returns
bool

◆ getCanonicalFormat()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::getCanonicalFormat ( $format)

Returns the canonical format name for the given format.

Parameters
string$format
Returns
string
Exceptions
HttpErrorcode 415 if the format is not supported.

◆ getEntityRevision()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::getEntityRevision ( EntityId $id,
$revision,
$allowRedirects = false )
private

Loads the requested Entity.

Redirects are resolved if no specific revision is requested or they are explicitly allowed by $allowRedirects.

Parameters
EntityId$id
int$revisionThe revision ID (use 0 for the current revision).
bool$allowRedirectsCan we fetch redirects when revision is set?
Returns
array list( EntityRevision, RedirectRevision|null )
Exceptions
HttpError

◆ getIncomingRedirects()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::getIncomingRedirects ( EntityId $id)
private

Loads incoming redirects referring to the given entity ID.

Parameters
EntityId$id
Returns
EntityId[]
Exceptions
HttpError

◆ handleRequest()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::handleRequest ( $doc,
WebRequest $request,
OutputPage $output )

Main method for handling requests.

Parameters
string$docDocument name, e.g. Q5 or Q5.json or Q5:33.xml
WebRequest$requestThe request parameters. Known parameters are:
  • id: the entity ID
  • format: the format
  • oldid|revision: the revision ID
  • action=purge: to purge cached data from (web) caches
OutputPage$output
Note
Instead of an output page, a WebResponse could be sufficient, but redirect logic is currently implemented in OutputPage.
Exceptions
HttpError

◆ httpContentNegotiation()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::httpContentNegotiation ( WebRequest $request,
OutputPage $output,
EntityId $id,
$revision = 0 )

Applies HTTP content negotiation.

If the negotiation is successful, this method will set the appropriate redirect in the OutputPage object and return. Otherwise, an HttpError is thrown.

Parameters
WebRequest$request
OutputPage$output
EntityId$idThe ID of the entity to show
int$revisionThe desired revision
Exceptions
HttpError

◆ outputData()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::outputData ( WebRequest $request,
EntityId $requestId,
int $requestRevision,
WebResponse $response,
string $data,
string $contentType,
string $lastModified )

Output the entity data and set the appropriate HTTP response headers.

Parameters
WebRequest$request
EntityId$requestIdthe original entity ID of the request
int$requestRevisionthe original revision ID of the request (0 for latest)
WebResponse$response
string$datathe data to output
string$contentTypethe data's mime type
string$lastModified

◆ purgeWebCache()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::purgeWebCache ( EntityId $id,
int $revision )

Purges the entity data identified by the doc parameter from any HTTP caches.

Does nothing if $wgUseCdn is not set.

Parameters
EntityId$idThe entity ID for which to purge all data.
int$revisionThe revision ID (0 for current/unspecified)

◆ validateRedirectability()

Wikibase\Repo\LinkedData\EntityDataRequestHandler::validateRedirectability ( EntityId $id,
EntityId $redirectTargetId )
private

Member Data Documentation

◆ $defaultFormat

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$defaultFormat
private

◆ $entityDataFormatProvider

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$entityDataFormatProvider
private

◆ $entityIdParser

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$entityIdParser
private

◆ $entityRedirectLookup

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$entityRedirectLookup
private

◆ $entityRevisionLookup

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$entityRevisionLookup
private

◆ $entityTypesWithoutRdfOutput

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$entityTypesWithoutRdfOutput
private

◆ $frameOptionsHeader

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$frameOptionsHeader
private

◆ $htmlCacheUpdater

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$htmlCacheUpdater
private

◆ $logger

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$logger
private

◆ $maxAge

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$maxAge
private

◆ $serializationService

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$serializationService
private

◆ $subEntityTypesMap

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$subEntityTypesMap
private

◆ $uriManager

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$uriManager
private

◆ $useCdn

Wikibase\Repo\LinkedData\EntityDataRequestHandler::$useCdn
private

◆ MAXIMUM_MAX_AGE

const Wikibase\Repo\LinkedData\EntityDataRequestHandler::MAXIMUM_MAX_AGE = 2678400
private

◆ MINIMUM_MAX_AGE

const Wikibase\Repo\LinkedData\EntityDataRequestHandler::MINIMUM_MAX_AGE = 0
private

Allowed smallest and biggest number of seconds for the "max-age=..." and "s-maxage=..." cache control parameters.

Todo
Hard maximum could be configurable somehow.

The documentation for this class was generated from the following file: