mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-28 10:11:45 +00:00
Merge "Fix placeholder headings causing exceptions in getTranscludedFrom()"
This commit is contained in:
commit
f189c985da
|
@ -518,10 +518,11 @@ class CommentUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ImmutableRange $range
|
* @param ImmutableRange $range (must not be collapsed)
|
||||||
* @return Node
|
* @return Node
|
||||||
*/
|
*/
|
||||||
public static function getRangeFirstNode( ImmutableRange $range ): Node {
|
public static function getRangeFirstNode( ImmutableRange $range ): Node {
|
||||||
|
Assert::precondition( !$range->collapsed, 'Range is not collapsed' );
|
||||||
// PHP bug: childNodes can be null
|
// PHP bug: childNodes can be null
|
||||||
return $range->startContainer->childNodes && $range->startContainer->childNodes->length ?
|
return $range->startContainer->childNodes && $range->startContainer->childNodes->length ?
|
||||||
$range->startContainer->childNodes[ $range->startOffset ] :
|
$range->startContainer->childNodes[ $range->startOffset ] :
|
||||||
|
@ -529,10 +530,11 @@ class CommentUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ImmutableRange $range
|
* @param ImmutableRange $range (must not be collapsed)
|
||||||
* @return Node
|
* @return Node
|
||||||
*/
|
*/
|
||||||
public static function getRangeLastNode( ImmutableRange $range ): Node {
|
public static function getRangeLastNode( ImmutableRange $range ): Node {
|
||||||
|
Assert::precondition( !$range->collapsed, 'Range is not collapsed' );
|
||||||
// PHP bug: childNodes can be null
|
// PHP bug: childNodes can be null
|
||||||
return $range->endContainer->childNodes && $range->endContainer->childNodes->length ?
|
return $range->endContainer->childNodes && $range->endContainer->childNodes->length ?
|
||||||
$range->endContainer->childNodes[ $range->endOffset - 1 ] :
|
$range->endContainer->childNodes[ $range->endOffset - 1 ] :
|
||||||
|
|
|
@ -97,4 +97,15 @@ class HeadingItem extends ThreadItem {
|
||||||
$this->getName() !== 'h-'
|
$this->getName() !== 'h-'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTranscludedFrom() {
|
||||||
|
// Placeholder headings break the usual logic, because their ranges are collapsed
|
||||||
|
if ( $this->isPlaceholderHeading() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return parent::getTranscludedFrom();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue