diff --git a/src/Parsoid/RefGroup.php b/src/Parsoid/RefGroup.php index 328ae7cd4..5e4bc80ca 100644 --- a/src/Parsoid/RefGroup.php +++ b/src/Parsoid/RefGroup.php @@ -84,11 +84,24 @@ class RefGroup { } $li->appendChild( $reftextSpan ); + // It seems counter-productive to go through hoops to not display all the errors considering that rendering + // only the first one is considered deprecated in the legacy code. However, displaying the same error + // multiple times for the same reference is also useless. + // Hence, we avoid displaying the same error multiple times, and keep count of multiple errors under this + // constraint; if we still display multiple errors where the legacy parser would only display one, we add + // the page to the cite-tracking-category-cite-diffing-error category. + $reported = []; + $errorCount = 0; foreach ( $ref->nodes as $node ) { foreach ( DOMDataUtils::getDataMw( $node )->errors ?? [] as $error ) { + if ( in_array( $error, $reported ) ) { + continue; + } + $reported[] = $error; + $errorCount++; $errorFragment = ErrorUtils::renderParsoidError( $extApi, $error->key, $error->params ); $li->appendChild( $errorFragment ); - if ( ErrorUtils::isDiffingError( $error->key ) ) { + if ( ErrorUtils::isDiffingError( $error->key ) || $errorCount > 1 ) { $extApi->addTrackingCategory( 'cite-tracking-category-cite-diffing-error' ); } } diff --git a/tests/parser/citeParserTests.txt b/tests/parser/citeParserTests.txt index 4d61bb300..dd856948f 100644 --- a/tests/parser/citeParserTests.txt +++ b/tests/parser/citeParserTests.txt @@ -2035,12 +2035,12 @@ BETA[NOTES 1] TWO[NOTES 1]
- +THREE[NOTES 1] FOUR[NOTES 2] FIVE[NOTES 2] SIX[1]
- +