mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-25 03:08:59 +00:00
Deal with <references/> inside a <ref> in automatic references list
The Cite extension already had a recursion guard around the parsing of `<references/>`, to prevent another `<ref>` containing `<references/>` from producing a weirdly nested references list. When an explicit `<references/>` tag is not included in the page, or `<ref>` tags exist after the last explicit `<references/>`, the extension automatically adds a reference list at the end of the page, to make the references still displayed. This automatic references list creation was bypassing the recursion guard, causing the weirdly nested output *and* a PHP Notice from `mRefs[$group]` becoming undefined. This commit sets the recursion guard state during that automatic references list creation to prevent this. Bug: T182929 Change-Id: I87737dcf39a4fc15e119a1090a9c34d6b9633c21
This commit is contained in:
parent
580a008af7
commit
e86ffeba3a
|
@ -659,11 +659,12 @@ class Cite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Must only be called from references(). Use that to prevent recursion.
|
||||
*
|
||||
* @param string|null $str Raw content of the <references> tag.
|
||||
* @param string[] $argv
|
||||
* @param Parser $parser
|
||||
* @param string $group
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function guardedReferences(
|
||||
|
@ -751,7 +752,10 @@ class Cite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Make output to be returned from the references() function
|
||||
* Make output to be returned from the references() function.
|
||||
*
|
||||
* If called outside of references(), caller is responsible for ensuring
|
||||
* `mInReferences` is enabled before the call and disabled after call.
|
||||
*
|
||||
* @param string $group
|
||||
* @param bool $responsive
|
||||
|
@ -1222,7 +1226,9 @@ class Cite {
|
|||
continue;
|
||||
}
|
||||
if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
|
||||
$this->mInReferences = true;
|
||||
$s .= $this->referencesFormat( $group, $wgCiteResponsiveReferences );
|
||||
$this->mInReferences = false;
|
||||
} else {
|
||||
$s .= "\n<br />" .
|
||||
$this->error(
|
||||
|
|
Loading…
Reference in a new issue