Ori.livneh has submitted this change and it was merged.
Change subject: (bug 32368) Handle cloned parsers
......................................................................
(bug 32368) Handle cloned parsers
If the parser is cloned, we need to clone our data object and
reassociate the hooks. Otherwise references may be lost when the clone
has ParserClearState called.
Change-Id: Ic1d75850e8d610ea890e34c38d062a358fd55178
Depends-On: Ieec65c908d71e89b9a66f83b9a626f842aadacbb
---
M Cite_body.php
1 file changed, 21 insertions(+), 0 deletions(-)
Approvals:
Ori.livneh: Verified; Looks good to me, approved
diff --git a/Cite_body.php b/Cite_body.php
index 6b91ddc..e2fa2f2 100644
--- a/Cite_body.php
+++ b/Cite_body.php
@@ -1058,6 +1058,26 @@
}
/**
+ * Gets run when the parser is cloned.
+ *
+ * @param $parser Parser
+ *
+ * @return bool
+ */
+ function cloneState( $parser ) {
+ if ( $parser->extCite !== $this ) {
+ return $parser->extCite->cloneState( $parser );
+ }
+
+ $parser->extCite = clone $this;
+ $parser->setHook( 'ref' , array( $parser->extCite, 'ref' ) );
+ $parser->setHook( 'references' , array( $parser->extCite,
'references' ) );
+ $parser->extCite->clearState( $parser );
+
+ return true;
+ }
+
+ /**
* Called at the end of page processing to append an error if refs were
* used without a references tag.
*
@@ -1124,6 +1144,7 @@
if ( !Cite::$hooksInstalled ) {
$wgHooks['ParserClearState'][] = array(
$parser->extCite, 'clearState' );
+ $wgHooks['ParserCloned'][] = array( $parser->extCite,
'cloneState' );
$wgHooks['ParserAfterParse'][] = array(
$parser->extCite, 'checkRefsNoReferences', true );
$wgHooks['ParserBeforeTidy'][] = array(
$parser->extCite, 'checkRefsNoReferences', false );
$wgHooks['InlineEditorPartialAfterParse'][] = array(
$parser->extCite, 'checkAnyCalls' );
--
To view, visit https://gerrit.wikimedia.org/r/33508
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1d75850e8d610ea890e34c38d062a358fd55178
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Platonides <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits