- // Normalize name for cache
- $page = $title->getPrefixedDBkey();
-
- if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
- && !$parser->incrementExpensiveFunctionCount() ) {
- return null;
+ $parserOutput = $parser->getOutput();
+ if ( !$revision ) {
+ if (
+ !$parser->isCurrentRevisionOfTitleCached( $title ) &&
+ !$parser->incrementExpensiveFunctionCount()
+ ) {
+ return null; // not allowed
+ }
+ // Get the current revision, ignoring Parser::getRevisionId() being null/old
+ $revision = $parser->fetchCurrentRevisionOfTitle( $title );
+ // Register dependency in templatelinks
+ $parserOutput->addTemplate(
+ $title,
+ $revision ? $revision->getPage() : 0,
+ $revision ? $revision->getId() : 0
+ );