use Html;
use InvalidArgumentException;
-use MediaWiki\Storage\RevisionRecord;
use ParserOptions;
use ParserOutput;
use Psr\Log\LoggerInterface;
$this->saveParseLogger = new NullLogger();
}
+ /**
+ * @param LoggerInterface $saveParseLogger
+ */
+ public function setLogger( LoggerInterface $saveParseLogger ) {
+ $this->saveParseLogger = $saveParseLogger;
+ }
+
/**
* @param RevisionRecord $rev
* @param ParserOptions|null $options
* - 'audience' the audience to use for content access. Default is
* RevisionRecord::FOR_PUBLIC if $forUser is not set, RevisionRecord::FOR_THIS_USER
* if $forUser is set. Can be set to RevisionRecord::RAW to disable audience checks.
+ * - 'known-revision-output' a combined ParserOutput for the revision, perhaps from
+ * some cache. the caller is responsible for ensuring that the ParserOutput indeed
+ * matched the $rev and $options. This mechanism is intended as a temporary stop-gap,
+ * for the time until caches have been changed to store RenderedRevision states instead
+ * of ParserOutput objects.
*
* @return RenderedRevision|null The rendered revision, or null if the audience checks fails.
*/
$renderedRevision->setSaveParseLogger( $this->saveParseLogger );
+ if ( isset( $hints['known-revision-output'] ) ) {
+ $renderedRevision->setRevisionParserOutput( $hints['known-revision-output'] );
+ }
+
return $renderedRevision;
}
$withHtml = $hints['generate-html'] ?? true;
// short circuit if there is only the main slot
- if ( array_keys( $slots ) === [ 'main' ] ) {
- return $rrev->getSlotParserOutput( 'main' );
+ if ( array_keys( $slots ) === [ SlotRecord::MAIN ] ) {
+ return $rrev->getSlotParserOutput( SlotRecord::MAIN );
}
// TODO: put fancy layout logic here, see T200915.
// move main slot to front
- if ( isset( $slots['main'] ) ) {
- $slots = [ 'main' => $slots['main'] ] + $slots;
+ if ( isset( $slots[SlotRecord::MAIN] ) ) {
+ $slots = [ SlotRecord::MAIN => $slots[SlotRecord::MAIN] ] + $slots;
}
$combinedOutput = new ParserOutput( null );