Clarify when content is missing in cite

Change-Id: Icbf195059ddae410944ecdcaf02cbfff7f962bf2
This commit is contained in:
Arlo Breault 2020-06-23 10:40:31 -04:00
parent faaf81140d
commit e911944c5f

View file

@ -144,18 +144,17 @@ class References extends ExtensionTagHandler {
// Add ref-index linkback
$linkBack = $doc->createElement( 'sup' );
// Check for missing name and content and generate error code
$hasMissingNameAndContent = ( $refName === '' &&
( !empty( $cDp->empty ) || trim( $refDmw->body->extsrc ) === '' ) );
// Check for missing content
$missingContent = ( !empty( $cDp->empty ) || trim( $refDmw->body->extsrc ) === '' );
// FIXME: Lot of useless work for an edge case
if ( !empty( $cDp->empty ) ) {
// Discard wrapper if there was no input wikitext
$contentId = null;
// Check for missing name and content to generate error code
$hasMissingNameAndContent = ( $refName === '' ) && $missingContent;
if ( $missingContent ) {
if ( !empty( $cDp->selfClose ) ) {
unset( $refDmw->body );
} else {
$refDmw->body = (object)[ 'html' => '' ];
$refDmw->body = (object)[ 'html' => $refDmw->body->extsrc ];
}
} else {
// If there are multiple <ref>s with the same name, but different content,
@ -246,7 +245,7 @@ class References extends ExtensionTagHandler {
}
// Keep the first content to compare multiple <ref>s with the same name.
if ( !$ref->contentId ) {
if ( $ref->contentId === null && !$missingContent ) {
$ref->contentId = $contentId;
$ref->dir = strtolower( $refDmw->attrs->dir ?? '' );
}