diff --git a/src/ReferenceStack.php b/src/ReferenceStack.php index dd45326ab..ae697b5b3 100644 --- a/src/ReferenceStack.php +++ b/src/ReferenceStack.php @@ -181,7 +181,7 @@ class ReferenceStack { unset( $ref['number'] ); $ref = array_merge( $ref, $this->refs[$group][$name] ); $this->refs[$group][$name] =& $ref; - $action = 'new'; + $action = 'new-from-placeholder'; } elseif ( !isset( $this->refs[$group][$name] ) ) { // Valid key with first occurrence $this->refs[$group][$name] = &$ref; @@ -346,6 +346,10 @@ class ReferenceStack { } // TODO: else, don't we need to decrement groupRefSequence? break; + case 'new-from-placeholder': + $this->refs[$group][$lookup]['__placeholder__'] = true; + unset( $this->refs[$group][$lookup]['count'] ); + break; case 'assign': # Rollback assignment of text to pre-existing elements. $this->refs[$group][$lookup]['text'] = null; diff --git a/tests/parser/bookReferencing.txt b/tests/parser/bookReferencing.txt index 94a23ac96..f04fd3699 100644 --- a/tests/parser/bookReferencing.txt +++ b/tests/parser/bookReferencing.txt @@ -570,7 +570,6 @@ wgCiteBookReferencing=true !! end -# TODO: Should behave the same as above! !! test T239810: Extending a that doesn't appear in the text, but in {{#tag:references}} !! config @@ -584,11 +583,11 @@ wgCiteBookReferencing=true

[1.1]

    +
  1. Book
    1. Page 2
    2. -
-

Cite error: <ref> tag with name "a" defined in <references> is not used in prior text. -

+ + !! end # TODO: This should be invalid, there's no way to know that `footwo` should be subnumbered in a one-pass parse. @@ -622,7 +621,6 @@ wgCiteBookReferencing=true BAR page 7 - {{#tag:references| book name }} diff --git a/tests/phpunit/unit/ReferenceStackTest.php b/tests/phpunit/unit/ReferenceStackTest.php index ec61b27d9..822eada5e 100644 --- a/tests/phpunit/unit/ReferenceStackTest.php +++ b/tests/phpunit/unit/ReferenceStackTest.php @@ -502,7 +502,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase { ], [ [ 'new', 1, 'foo', 'a', 'b', 'text-a', [] ], - [ 'new', 2, 'foo', 'b', null, 'text-b', [] ], + [ 'new-from-placeholder', 2, 'foo', 'b', null, 'text-b', [] ], ] ], 'Named extends after parent' => [ @@ -644,7 +644,7 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase { ], [ [ 'new', 1, 'foo', null, 'b', 'text-a', [] ], - [ 'new', 2, 'foo', 'b', null, 'text-b', [] ], + [ 'new-from-placeholder', 2, 'foo', 'b', null, 'text-b', [] ], ] ], 'Anonymous extends after parent' => [