mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 09:43:30 +00:00
Reindent CommentParser::findTimestamp()
Something terrible has happened to this function… It seems that I have
brutalized it when rebasing 092cfd6075
.
Change-Id: I12d75c69d15645112563a7bc345209b23b54cb3e
This commit is contained in:
parent
b681eec8e4
commit
7cd370615f
|
@ -604,41 +604,41 @@ class CommentParser {
|
|||
* @return array|null Match data
|
||||
*/
|
||||
public function findTimestamp( DOMText $node, string $timestampRegex ) : ?array {
|
||||
$nodeText = '';
|
||||
$nodeText = '';
|
||||
|
||||
while ( $node ) {
|
||||
$nodeText .= $node->nodeValue;
|
||||
while ( $node ) {
|
||||
$nodeText .= $node->nodeValue;
|
||||
|
||||
// In Parsoid HTML, entities are represented as a 'mw:Entity' node, rather than normal HTML
|
||||
// entities. On Arabic Wikipedia, the "UTC" timezone name contains some non-breaking spaces,
|
||||
// which apparently are often turned into entities by buggy editing tools. To handle
|
||||
// this, we must piece together the text, so that our regexp can match those timestamps.
|
||||
if (
|
||||
// In Parsoid HTML, entities are represented as a 'mw:Entity' node, rather than normal HTML
|
||||
// entities. On Arabic Wikipedia, the "UTC" timezone name contains some non-breaking spaces,
|
||||
// which apparently are often turned into entities by buggy editing tools. To handle
|
||||
// this, we must piece together the text, so that our regexp can match those timestamps.
|
||||
if (
|
||||
( $nextSibling = $node->nextSibling ) &&
|
||||
$nextSibling instanceof DOMElement &&
|
||||
$nextSibling->getAttribute( 'typeof' ) === 'mw:Entity'
|
||||
) {
|
||||
) {
|
||||
$nodeText .= $nextSibling->firstChild->nodeValue;
|
||||
|
||||
// If the entity is followed by more text, do this again
|
||||
if (
|
||||
// If the entity is followed by more text, do this again
|
||||
if (
|
||||
$nextSibling->nextSibling &&
|
||||
$nextSibling->nextSibling instanceof DOMText
|
||||
) {
|
||||
) {
|
||||
$node = $nextSibling->nextSibling;
|
||||
} else {
|
||||
$node = null;
|
||||
}
|
||||
} else {
|
||||
$node = null;
|
||||
}
|
||||
} else {
|
||||
$node = null;
|
||||
}
|
||||
}
|
||||
|
||||
$matchData = null;
|
||||
// Allows us to mimic match.index in #getComments
|
||||
if ( preg_match( $timestampRegex, $nodeText, $matchData, PREG_OFFSET_CAPTURE ) ) {
|
||||
$matchData = null;
|
||||
// Allows us to mimic match.index in #getComments
|
||||
if ( preg_match( $timestampRegex, $nodeText, $matchData, PREG_OFFSET_CAPTURE ) ) {
|
||||
return $matchData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue