Merge "Include more information in missing parent placeholder"

This commit is contained in:
jenkins-bot 2024-01-05 11:50:06 +00:00 committed by Gerrit Code Review
commit 9b770fba99
3 changed files with 10 additions and 4 deletions

View file

@ -69,7 +69,7 @@ class ReferenceStack {
private const ACTION_INCREMENT = 'increment'; private const ACTION_INCREMENT = 'increment';
private const ACTION_NEW_FROM_PLACEHOLDER = 'new-from-placeholder'; private const ACTION_NEW_FROM_PLACEHOLDER = 'new-from-placeholder';
private const ACTION_NEW = 'new'; private const ACTION_NEW = 'new';
private const PARENT_REF_PLACEHOLDER = '__placeholder__'; public const PARENT_REF_PLACEHOLDER = '__placeholder__';
/** /**
* Leave a mark in the stack which matches an invalid ref tag. * Leave a mark in the stack which matches an invalid ref tag.
@ -194,6 +194,7 @@ class ReferenceStack {
} else { } else {
// Transfer my number to parent ref. // Transfer my number to parent ref.
$this->refs[$group][$extends] = [ $this->refs[$group][$extends] = [
'name' => $extends,
'number' => $ref['number'], 'number' => $ref['number'],
self::PARENT_REF_PLACEHOLDER => true, self::PARENT_REF_PLACEHOLDER => true,
]; ];
@ -380,6 +381,9 @@ class ReferenceStack {
} }
public function listDefinedRef( string $group, string $name, string $text ): void { public function listDefinedRef( string $group, string $name, string $text ): void {
if ( isset( $this->refs[$group][$name][self::PARENT_REF_PLACEHOLDER] ) ) {
unset( $this->refs[$group][$name][self::PARENT_REF_PLACEHOLDER] );
}
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;
} elseif ( $this->refs[$group][$name]['text'] !== $text ) { } elseif ( $this->refs[$group][$name]['text'] !== $text ) {

View file

@ -373,7 +373,7 @@ wgCiteBookReferencing=true
!! end !! end
!! test !! test
T236256 - Base and book reference in different groups T236256 - Base and book reference in different groups don't collide
!! config !! config
wgCiteBookReferencing=true wgCiteBookReferencing=true
!! wikitext !! wikitext
@ -397,7 +397,7 @@ wgCiteBookReferencing=true
!! end !! end
!! test !! test
T236256 - Extending in the unnamed default group T236256 - Extending in the unnamed default group doesn't collide with refs from other groups
!! config !! config
wgCiteBookReferencing=true wgCiteBookReferencing=true
!! wikitext !! wikitext
@ -420,7 +420,7 @@ wgCiteBookReferencing=true
!! end !! end
!! test !! test
T236256 - Base in the unnamed default group T236256 - Extends in named group doesn't conflict with default group
!! config !! config
wgCiteBookReferencing=true wgCiteBookReferencing=true
!! wikitext !! wikitext

View file

@ -436,6 +436,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
'extendsIndex' => 1, 'extendsIndex' => 1,
], ],
'b' => [ 'b' => [
'name' => 'b',
'number' => 1, 'number' => 1,
'__placeholder__' => true, '__placeholder__' => true,
] ]
@ -578,6 +579,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
'extendsIndex' => 1, 'extendsIndex' => 1,
], ],
'b' => [ 'b' => [
'name' => 'b',
'number' => 1, 'number' => 1,
'__placeholder__' => true, '__placeholder__' => true,
] ]