Skip to content

Commit

Permalink
Ensure ParserOutput::getTimeProfile() is valid for all ContentHandlers
Browse files Browse the repository at this point in the history
ContentHandler::getParserOutput() calls
ParserOutput::resetParseStartTime() before invoking
ContentHandler::fillParserOutput(), and then calling
ParserOutput::recordTimeProfile() on the value that returns.  This
assumes that ::fillParserOutput() mutates the ParserOutput which it is
given, instead of creating a new ParserOutput.  If you create a new
ParserOutput, you are responsible for calling ::resetParseStartTime()
on it at an appropriate point.  The various content handlers in core
respect this (poorly documented) contract, but the wikibase
ContentHandlers did not.

Bug: T376433
Change-Id: I6bba35cea2e7213fd48e5f8d25e0543695b11263
  • Loading branch information
cscott committed Oct 4, 2024
1 parent dd41a92 commit 3bfe5bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions repo/includes/Content/EntityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,8 @@ protected function fillParserOutput(
*/
protected function getParserOutputForRedirect( EntityContent $content, bool $generateHtml ) {
$parserOutput = new ParserOutput();
$parserOutput->resetParseStartTime();

$target = $content->getRedirectTarget();

// Make sure to include the redirect link in pagelinks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function getParserOutput(
$entity = $entityRevision->getEntity();

$parserOutput = new ParserOutput();
$parserOutput->resetParseStartTime();

$updaterCollection = new EntityParserOutputDataUpdaterCollection( $parserOutput, $this->dataUpdaters );
$updaterCollection->updateParserOutput( $entity );
Expand Down

0 comments on commit 3bfe5bd

Please sign in to comment.