mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Refs in group with no <references group="xxx" />
* Generating error message in data-mw in affected refs * Cite test validates correctness of adding error to afflicted refs * Autogenerated references aren't considered erroneous (the extension to the legacy parser also generates them) and are not suppressed when serializing because apparently that's the behaviour Parsoid clients want. However, in this patch we're marking up autogenerated references *with group attributes* as errors (the legacy extension doesn't generate them at all) and are choosing to suppress them when serializing since we considered them an error while parsing and don't want them to persist in the content. Bug: T51538 Change-Id: Ia651b10449dc41c2cb439b33a361e8c8e482f502
This commit is contained in:
parent
b5b3475d28
commit
02fb17d102
|
@ -81,7 +81,7 @@ class References extends ExtensionTagHandler {
|
|||
] );
|
||||
$dataMw = (object)[
|
||||
'name' => 'references',
|
||||
'attrs' => new stdClass,
|
||||
'attrs' => new stdClass
|
||||
];
|
||||
// Dont emit empty keys
|
||||
if ( $refsOpts['group'] ) {
|
||||
|
@ -458,6 +458,21 @@ class References extends ExtensionTagHandler {
|
|||
): void {
|
||||
$doc = $node->ownerDocument;
|
||||
foreach ( $refsData->getRefGroups() as $groupName => $refsGroup ) {
|
||||
if ( $groupName !== "" ) {
|
||||
// Mark all refs that are part of a group that is missing <references group='...' />
|
||||
foreach ( $refsGroup->indexByName as $ref ) {
|
||||
foreach ( $ref->nodes as $linkBack ) {
|
||||
DOMUtils::addTypeOf( $linkBack, 'mw:Error' );
|
||||
$dmw = DOMDataUtils::getDataMw( $linkBack );
|
||||
$errs = [ [ 'key' => 'cite_error_group_refs_without_references' ] ];
|
||||
if ( is_array( $dmw->errors ?? null ) ) {
|
||||
$errs = array_merge( $dmw->errors, $errs );
|
||||
}
|
||||
$dmw->errors = $errs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$domFragment = $doc->createDocumentFragment();
|
||||
$frag = self::createReferences(
|
||||
$extApi,
|
||||
|
@ -643,7 +658,8 @@ class References extends ExtensionTagHandler {
|
|||
ParsoidExtensionAPI $extApi, DOMElement $node, bool $wrapperUnmodified
|
||||
) {
|
||||
$dataMw = DOMDataUtils::getDataMw( $node );
|
||||
if ( !empty( $dataMw->autoGenerated ) && $extApi->rtTestMode() ) {
|
||||
if ( !empty( $dataMw->autoGenerated ) && ( ( $dataMw->attrs->group ?? '' ) !== ''
|
||||
|| $extApi->rtTestMode() ) ) {
|
||||
// Eliminate auto-inserted <references /> noise in rt-testing
|
||||
return '';
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue