-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(PLATFORM-10832): remove dead code to fix reflection exception #10
base: master
Are you sure you want to change the base?
Conversation
$parser->mPPNodeCount += $dataParser->mPPNodeCount; | ||
} | ||
); | ||
} | ||
} | ||
} | ||
return $this->dataFrames[$sourcePage]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be double-checked: Based on REL1_39 code
usingdata/src/UsingDataHooks.php
Lines 60 to 92 in ee99692
private function getDataFrame( $sourcePage, $title, &$parser, $frame ) { | |
global $wgHooks; | |
if ( !isset( $this->dataFrames[$sourcePage] ) ) { | |
$this->dataFrames[$sourcePage] = new UsingDataPPFrameDOM( $frame, $sourcePage ); | |
if ( $sourcePage != '' | |
&& ( $sourcePage != $parser->getTitle()->getPrefixedText() ) | |
|| $parser->getOptions()->getIsSectionPreview() ) { | |
[ $text, $fTitle ] = $parser->fetchTemplateAndTitle( $title ); | |
if ( is_object( $fTitle ) && $fTitle->getPrefixedText() != $sourcePage ) { | |
$this->dataFrames[$fTitle->getPrefixedText()] = $this->dataFrames[$sourcePage]; | |
} | |
if ( is_string( $text ) && $text != '' ) { | |
$this->searchingForData = true; | |
$clearStateHooks = $wgHooks['ParserClearState']; | |
// Other extensions tend to assume the hook is only called by wgParser and reset internal state | |
$wgHooks['ParserClearState'] = []; | |
$subParser = clone $parser; | |
$subParser->preprocess( $text, $fTitle, clone $parser->getOptions() ); | |
// We might've blocked access to templates while preprocessing; should not be cached | |
$subParser->clearState(); | |
if ( $parser->getOutput()->hasText() ) { | |
$subParser->getOutput()->setText( $parser->getOutput()->getText() ); | |
} | |
$wgHooks['ParserClearState'] = empty( $wgHooks['ParserClearState'] ) | |
? $clearStateHooks | |
: array_merge( $clearStateHooks, $wgHooks['ParserClearState'] ); | |
$parser->mPPNodeCount += $subParser->mPPNodeCount; | |
$this->searchingForData = false; | |
} | |
} | |
} | |
return $this->dataFrames[$sourcePage]; | |
} |
Basically, this part could be removed https://github.com/Wikia/usingdata/blob/ee996924d65b057abce474d4b03e56f74ea0f977/src/UsingDataHooks.php#L71C5-L88C6
// This flag is restored at the end
$this->searchingForData = true;
// Preserve ParserClearState hook handlers to be restored at the end
$clearStateHooks = $wgHooks['ParserClearState'];
// Other extensions tend to assume the hook is only called by wgParser and reset internal state
// Disable ParserClearState hook
$wgHooks['ParserClearState'] = [];
// Cloning original parser state
$subParser = clone $parser;
// We are working on clone and parameters are not passed as reference. No side-effects except some hooks being called. Hooks registered in UsingData doesn't preserve it's state outside affected parser
$subParser->preprocess( $text, $fTitle, clone $parser->getOptions() );
// We might've blocked access to templates while preprocessing; should not be cached
// Clearing state will set internal `mPPNodeCount` to `0`
$subParser->clearState();
if ( $parser->getOutput()->hasText() ) {
// $subParser is not used after that assignment
$subParser->getOutput()->setText( $parser->getOutput()->getText() );
}
// Restore original ParserClearState hook handlers
$wgHooks['ParserClearState'] = empty( $wgHooks['ParserClearState'] )
? $clearStateHooks
: array_merge( $clearStateHooks, $wgHooks['ParserClearState'] );
// When calling $subParser->clearState(); mPPNodeCount is set to 0
$parser->mPPNodeCount += $subParser->mPPNodeCount;
// Restore flag value
$this->searchingForData = false;
https://fandom.atlassian.net/browse/PLATFORM-10832