mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Consolidate adding ref errors at references insertion
Change-Id: I01ce55989fb7b822320c63ddad19c2edf7e03bf9
This commit is contained in:
parent
02fb17d102
commit
1dda4cdc8a
|
@ -369,20 +369,30 @@ class References extends ExtensionTagHandler {
|
|||
$group = $dp->group ?? '';
|
||||
$refGroup = $refsData->getRefGroup( $group );
|
||||
|
||||
// Iterate through the named ref list for refs without content and
|
||||
// back-patch typeof and data-mw error information into named ref
|
||||
// instances without content
|
||||
// FIXME: This doesn't update the refs found while processEmbeddedRefs
|
||||
// and processRefsInReferences
|
||||
// Iterate through the ref list to back-patch typeof and data-mw error
|
||||
// information into ref for errors only known at time of references
|
||||
// insertion.
|
||||
// FIXME(T266356): This doesn't update the refs found while
|
||||
// processEmbeddedRefs, processRefsInReferences, and
|
||||
// extractRefFromNode's ref-in-ref
|
||||
if ( $refGroup ) {
|
||||
$autoGeneratedWithGroup = ( $autoGenerated && $group !== '' );
|
||||
foreach ( $refGroup->indexByName as $ref ) {
|
||||
if ( $ref->contentId === null ) {
|
||||
if ( $autoGeneratedWithGroup || $ref->contentId === null ) {
|
||||
foreach ( $ref->nodes as $linkBack ) {
|
||||
DOMUtils::addTypeOf( $linkBack, 'mw:Error' );
|
||||
$dmw = DOMDataUtils::getDataMw( $linkBack );
|
||||
// TODO: Since this error is being placed on the ref,
|
||||
// the key should arguably be "cite_error_ref_no_text"
|
||||
$errs = [ [ 'key' => 'cite_error_references_no_text' ] ];
|
||||
$errs = [];
|
||||
// Mark all refs that are part of a group that is autogenerated
|
||||
if ( $autoGeneratedWithGroup ) {
|
||||
$errs[] = [ 'key' => 'cite_error_group_refs_without_references' ];
|
||||
}
|
||||
// Mark all refs that are named without content
|
||||
if ( $ref->contentId === null ) {
|
||||
// TODO: Since this error is being placed on the ref,
|
||||
// the key should arguably be "cite_error_ref_no_text"
|
||||
$errs[] = [ 'key' => 'cite_error_references_no_text' ];
|
||||
}
|
||||
if ( is_array( $dmw->errors ?? null ) ) {
|
||||
$errs = array_merge( $dmw->errors, $errs );
|
||||
}
|
||||
|
@ -458,21 +468,6 @@ 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,
|
||||
|
|
|
@ -20,6 +20,8 @@ class ReferencesData {
|
|||
private $refGroups = [];
|
||||
|
||||
/**
|
||||
* FIXME(T266356): Need a solution for embedded content too
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $inEmbeddedContent = [ false ];
|
||||
|
|
Loading…
Reference in a new issue