Merge "Move a bit of code out of Cite::guardedReferences"

This commit is contained in:
jenkins-bot 2023-12-14 02:10:06 +00:00 committed by Gerrit Code Review
commit bf53249893
3 changed files with 8 additions and 9 deletions

View file

@ -364,7 +364,9 @@ class Cite {
return null;
}
$ret = $this->guardedReferences( $parser, $text, $argv );
$status = $this->parseArguments( $argv, [ 'group', 'responsive' ] );
$this->inReferencesGroup = $status->getValue()['group'] ?? self::DEFAULT_GROUP;
$ret = $this->guardedReferences( $parser, $text, $status );
$this->inReferencesGroup = null;
return $ret;
@ -375,18 +377,16 @@ class Cite {
*
* @param Parser $parser
* @param ?string $text Raw, untrimmed wikitext content of the <references> tag, if any
* @param string[] $argv Arguments as given in <references >, already trimmed
* @param StatusValue $status with the arguments as given in <references >
*
* @return string HTML
*/
private function guardedReferences(
Parser $parser,
?string $text,
array $argv
StatusValue $status
): string {
$status = $this->parseArguments( $argv, [ 'group', 'responsive' ] );
[ 'group' => $group, 'responsive' => $responsive ] = $status->getValue();
$this->inReferencesGroup = $group ?? self::DEFAULT_GROUP;
$responsive = $status->getValue()['responsive'];
if ( $text !== null && trim( $text ) !== '' ) {
if ( preg_match( '{' . preg_quote( Parser::MARKER_PREFIX ) . '-(?i:references)-}', $text ) ) {

View file

@ -250,8 +250,6 @@ class ReferenceStack {
/**
* Partially undoes the effect of calls to stack()
*
* Called by guardedReferences()
*
* The option to define <ref> within <references> makes the
* behavior of <ref> context dependent. This is normally fine
* but certain operations (especially #tag) lead to out-of-order

View file

@ -372,6 +372,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
}
/**
* @covers ::references
* @covers ::guardedReferences
* @dataProvider provideGuardedReferences
*/
@ -409,7 +410,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
->with( $expectedRollbackCount )
->willReturn( [ [ 't', [] ] ] );
$output = $spy->guardedReferences( $parser, $text, $argv );
$output = $cite->references( $parser, $text, $argv );
$this->assertSame( $expectedOutput, $output );
}