mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Move a bit of code out of Cite::guardedReferences"
This commit is contained in:
commit
bf53249893
12
src/Cite.php
12
src/Cite.php
|
@ -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 ) ) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue