25use InvalidArgumentException;
29use Psr\Log\LoggerInterface;
30use Psr\Log\NullLogger;
35use Wikimedia\Assert\Assert;
122 $this->saveParseLogger =
new NullLogger();
125 throw new InvalidArgumentException(
126 'User must be specified when setting audience to FOR_THIS_USER'
170 $withHtml = $hints[
'generate-html'] ??
true;
172 if ( !$this->revisionOutput
173 || ( $withHtml && !$this->revisionOutput->hasText() )
175 $output = call_user_func( $this->combineOutput, $this, $hints );
177 Assert::postcondition(
179 'Callback did not return a ParserOutput object!'
182 $this->revisionOutput =
$output;
199 $withHtml = $hints[
'generate-html'] ??
true;
201 if ( !isset( $this->slotsOutput[ $role ] )
202 || ( $withHtml && !$this->slotsOutput[ $role ]->hasText() )
204 $content = $this->revision->getContent( $role, $this->audience, $this->forUser );
208 'Access to the content has been suppressed for this audience'
213 if ( $withHtml && !
$output->hasText() ) {
214 throw new LogicException(
215 'HTML generation was requested, but '
217 .
'::getParserOutput() returns a ParserOutput with no text set.'
222 $this->
options->registerWatcher(
null );
225 $this->slotsOutput[ $role ] =
$output;
228 return $this->slotsOutput[$role];
240 $this->revision->getId(),
256 if (
$rev->getId() === $this->revision->getId() ) {
260 if ( $this->revision->getId() ) {
261 throw new LogicException(
'RenderedRevision already has a revision with ID '
262 . $this->revision->getId(),
', can\'t update to revision with ID ' .
$rev->getId() );
265 if ( !$this->revision->getSlots()->hasSameContent(
$rev->getSlots() ) ) {
266 throw new LogicException(
'Cannot update to a revision with different content!' );
282 if ( $this->revisionOutput ) {
284 $this->revisionOutput =
null;
287 $this->saveParseLogger->debug( __METHOD__ .
": no prepared revision output...\n" );
290 foreach ( $this->slotsOutput as $role =>
$output ) {
292 unset( $this->slotsOutput[$role] );
333 if ( $this->revision->isReadyForInsertion() || !$this->revision->getId() ) {
335 $oldCallback = $this->
options->getCurrentRevisionCallback();
336 $this->
options->setCurrentRevisionCallback(
337 function ( Title $parserTitle,
$parser =
false ) use ( $title, $oldCallback ) {
338 if ( $title->equals( $parserTitle ) ) {
339 $legacyRevision = new Revision( $this->revision );
340 return $legacyRevision;
342 return call_user_func( $oldCallback, $parserTitle, $parser );
357 $method = __METHOD__;
359 if (
$out->getFlag(
'vary-revision' ) ) {
363 $this->saveParseLogger->info(
364 "$method: Prepared output has vary-revision...\n"
367 } elseif (
$out->getFlag(
'vary-revision-id' )
368 && $actualRevId !==
false
369 && ( $actualRevId ===
true ||
$out->getSpeculativeRevIdUsed() !== $actualRevId )
371 $this->saveParseLogger->info(
372 "$method: Prepared output has vary-revision-id with wrong ID...\n"
384 wfDebug(
"$method: Keeping prepared output...\n" );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Set options of the Parser.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Base interface for content objects.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))