mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Remove one unnecessary LogicException from ReferenceStack
This exception was introduced very late in the patch I38c9929. It already caused trouble. This here is essentially a revert. It restores the previous behavior where this edge-case was silently ignored. The worst thing that can happen is that appendText() creates an incomplete entry in the $this->refs array, which will be rendered at the end. The user can see it then. As of now we are not aware of a code path where this would even be possible. Still this does make the code *more* robust by not making it explode, but give the user something they can work with. Bug: T243221 Change-Id: I2e2d29bbd557090981903fcc2ece8796fafa4aa4
This commit is contained in:
parent
8105f64740
commit
0fda08b25a
|
@ -409,7 +409,7 @@ class Cite {
|
||||||
*
|
*
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
* @param ?string $text Raw, untrimmed wikitext content of the <references> tag, if any
|
* @param ?string $text Raw, untrimmed wikitext content of the <references> tag, if any
|
||||||
* @param string[] $argv Arguments as given in <references name=…>, already trimmed
|
* @param string[] $argv Arguments as given in <references …>, already trimmed
|
||||||
*
|
*
|
||||||
* @return string|false False in case a <references> tag is not allowed in the current context
|
* @return string|false False in case a <references> tag is not allowed in the current context
|
||||||
*/
|
*/
|
||||||
|
@ -429,7 +429,7 @@ class Cite {
|
||||||
*
|
*
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
* @param ?string $text Raw, untrimmed wikitext content of the <references> tag, if any
|
* @param ?string $text Raw, untrimmed wikitext content of the <references> tag, if any
|
||||||
* @param string[] $argv Arguments as given in <references name=…>, already trimmed
|
* @param string[] $argv Arguments as given in <references …>, already trimmed
|
||||||
*
|
*
|
||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -424,10 +424,6 @@ class ReferenceStack {
|
||||||
* @param string $text
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public function appendText( string $group, string $name, string $text ) {
|
public function appendText( string $group, string $name, string $text ) {
|
||||||
if ( !isset( $this->refs[$group][$name] ) ) {
|
|
||||||
throw new LogicException( "Unknown ref \"$name\" in group \"$group\"" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $this->refs[$group][$name]['text'] ) ) {
|
if ( isset( $this->refs[$group][$name]['text'] ) ) {
|
||||||
$this->refs[$group][$name]['text'] .= $text;
|
$this->refs[$group][$name]['text'] .= $text;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1050,22 +1050,11 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
|
||||||
$this->assertSame( [], $stack->getGroupRefs( 'empty' ) );
|
$this->assertSame( [], $stack->getGroupRefs( 'empty' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::appendText
|
|
||||||
*/
|
|
||||||
public function testAppendText_failure() {
|
|
||||||
$stack = $this->newStack();
|
|
||||||
|
|
||||||
$this->expectException( LogicException::class );
|
|
||||||
$stack->appendText( 'group', 'name', 'the-text' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::appendText
|
* @covers ::appendText
|
||||||
*/
|
*/
|
||||||
public function testAppendText() {
|
public function testAppendText() {
|
||||||
$stack = $this->newStack();
|
$stack = $this->newStack();
|
||||||
$stack->refs = [ 'group' => [ 'name' => [] ] ];
|
|
||||||
|
|
||||||
$stack->appendText( 'group', 'name', 'set' );
|
$stack->appendText( 'group', 'name', 'set' );
|
||||||
$this->assertSame( [ 'text' => 'set' ], $stack->refs['group']['name'] );
|
$this->assertSame( [ 'text' => 'set' ], $stack->refs['group']['name'] );
|
||||||
|
|
Loading…
Reference in a new issue