mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Properly get timestamp position in DiscussionParser
The code was looking at the [0] element for the matched position of timestamps, while preg_match returns it in the [1] element. Bug: 53132 Change-Id: Ibfd3f2b86b007f28f73a137defb80276fb830d28 Follows-Up: I6c636b055bcd25760aee848aea71fe4044c7e1be
This commit is contained in:
parent
f6a1ce84a5
commit
17fa9cadde
|
@ -582,7 +582,7 @@ abstract class EchoDiscussionParser {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tsMatches[0][0];
|
return $tsMatches[0][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,13 +627,8 @@ abstract class EchoDiscussionParser {
|
||||||
|
|
||||||
foreach ( $lines as $line ) {
|
foreach ( $lines as $line ) {
|
||||||
++$lineNumber;
|
++$lineNumber;
|
||||||
$tsMatches = array();
|
$timestampPos = self::getTimestampPosition( $line );
|
||||||
if ( !preg_match(
|
if ( !$timestampPos ) {
|
||||||
"/$timestampRegex$endOfLine/mu",
|
|
||||||
$line,
|
|
||||||
$tsMatches,
|
|
||||||
PREG_OFFSET_CAPTURE
|
|
||||||
) ) {
|
|
||||||
// Ignore lines that don't finish with a timestamp
|
// Ignore lines that don't finish with a timestamp
|
||||||
// print "I\tNo timestamp\n";
|
// print "I\tNo timestamp\n";
|
||||||
// print "$line\n";
|
// print "$line\n";
|
||||||
|
@ -642,7 +637,7 @@ abstract class EchoDiscussionParser {
|
||||||
|
|
||||||
// Now that we know we have a timestamp, look for
|
// Now that we know we have a timestamp, look for
|
||||||
// the last user link on the line.
|
// the last user link on the line.
|
||||||
$userData = self::getUserFromLine( $line, $tsMatches[0][0] );
|
$userData = self::getUserFromLine( $line, $timestampPos );
|
||||||
if ( $userData === false ) {
|
if ( $userData === false ) {
|
||||||
// print "F\t$lineNumber\t$line\n";
|
// print "F\t$lineNumber\t$line\n";
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -46,6 +46,12 @@ TEXT
|
||||||
$this->assertEquals( 1, $match );
|
$this->assertEquals( 1, $match );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetTimestampPosition() {
|
||||||
|
$line = 'Hello World. '. self::getExemplarTimestamp();
|
||||||
|
$pos = EchoDiscussionParser::getTimestampPosition( $line );
|
||||||
|
$this->assertEquals( 13, $pos );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider signingDetectionData
|
* @dataProvider signingDetectionData
|
||||||
* FIXME some of the app logic is in the test...
|
* FIXME some of the app logic is in the test...
|
||||||
|
|
Loading…
Reference in a new issue