Resolve linter test port-fixme

Implements mocking for the #tag parser function for ref tags.

The ref-in-ref linting cycles tests from 04aa4be can now be restored.

This shows that after I1b598bd359b900d1b89abf5d8105a5d131aea3d1, the
protection added in 04aa4be is no longer necessary, because we only lint
the content where it's defined.

Bug: T237463
Change-Id: I4059e32b9bea8cdc23d2112812c3f7e167e47399
This commit is contained in:
Arlo Breault 2022-04-29 15:13:09 -04:00
parent 18889348c9
commit 6d9afe15dd
2 changed files with 5 additions and 6 deletions

View file

@ -11,7 +11,6 @@ use Wikimedia\Parsoid\Ext\DOMDataUtils;
use Wikimedia\Parsoid\Ext\DOMUtils;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
use Wikimedia\Parsoid\Ext\WTUtils;
use Wikimedia\Parsoid\Utils\DOMCompat;
/**
@ -60,11 +59,6 @@ class Ref extends ExtensionTagHandler {
public function lintHandler(
ParsoidExtensionAPI $extApi, Element $ref, callable $defaultHandler
): ?Node {
// Don't lint the content of ref in ref, since it can lead to cycles
// using named refs
if ( WTUtils::fromExtensionContent( $ref, 'references' ) ) {
return $ref->nextSibling;
}
$dataMw = DOMDataUtils::getDataMw( $ref );
if ( is_string( $dataMw->body->html ?? null ) ) {
$fragment = $extApi->htmlToDom( $dataMw->body->html );

View file

@ -281,6 +281,11 @@ class References extends ExtensionTagHandler {
// This will be set below with `$ref->contentId = $contentId;`
}
} else {
// If we have !$ref, one might have been added in the call to
// processRefs, ie. a self-referential ref. We could try to look
// it up again, but Parsoid is choosing not to support that.
// Even worse would be if it tried to redefine itself!
if ( !$ref ) {
$ref = $refsData->add( $extApi, $groupName, $refName );
}