Page MenuHomePhabricator

Internal error when changing a user talk page
Closed, ResolvedPublic

Description

When trying to edit a user talk page I'm getting an error.
I've never actually run this on a Windows machine until now, so that might be part of the issue.

(I got a very similar error last night which I pasted here: http://pastebin.com/raw.php?i=mz5HGjMf )

Right offset consistency error.
Offset: 60
Expected:
Actual:
Backtrace:
#0 C:\xampp\htdocs\MediaWiki\Git\extensions\Echo\includes\DiscussionParser.php(133): EchoDiscussionParser::getMachineReadableDiff('== Test ==??Tes...', '== Test ==??Tes...')
#1 C:\xampp\htdocs\MediaWiki\Git\extensions\Echo\includes\DiscussionParser.php(16): EchoDiscussionParser::getChangeInterpretationForRevision(Object(Revision))
#2 C:\xampp\htdocs\MediaWiki\Git\extensions\Echo\Hooks.php(196): EchoDiscussionParser::generateEventsForRevision(Object(Revision))
#3 [internal function]: EchoHooks::onArticleSaved(Object(WikiPage), Object(User), '== Test ==??Tes...', '/* Test */ new ...', 0, NULL, NULL, 98, Object(Revision), Object(Status), false)
#4 C:\xampp\htdocs\MediaWiki\Git\core\includes\Hooks.php(253): call_user_func_array('EchoHooks::onAr...', Array)
#5 C:\xampp\htdocs\MediaWiki\Git\core\includes\GlobalFunctions.php(3811): Hooks::run('ArticleSaveComp...', Array)
#6 C:\xampp\htdocs\MediaWiki\Git\core\includes\content\ContentHandler.php(1081): wfRunHooks('ArticleSaveComp...', Array)
#7 C:\xampp\htdocs\MediaWiki\Git\core\includes\WikiPage.php(1898): ContentHandler::runLegacyHooks('ArticleSaveComp...', Array)
#8 [internal function]: WikiPage->doEditContent(Object(WikitextContent), '/* Test */ new ...', 98, false, NULL, 'text/x-wiki')
#9 C:\xampp\htdocs\MediaWiki\Git\core\includes\Article.php(1937): call_user_func_array(Array, Array)
#10 C:\xampp\htdocs\MediaWiki\Git\core\includes\EditPage.php(1608): Article->__call('doEditContent', Array)
#11 C:\xampp\htdocs\MediaWiki\Git\core\includes\EditPage.php(1608): Article->doEditContent(Object(WikitextContent), '/* Test */ new ...', 98, false, NULL, 'text/x-wiki')
#12 C:\xampp\htdocs\MediaWiki\Git\core\includes\EditPage.php(1115): EditPage->internalAttemptSave(Array, false)
#13 C:\xampp\htdocs\MediaWiki\Git\core\includes\EditPage.php(396): EditPage->attemptSave()
#14 C:\xampp\htdocs\MediaWiki\Git\core\includes\actions\EditAction.php(51): EditPage->edit()
#15 C:\xampp\htdocs\MediaWiki\Git\core\includes\actions\EditAction.php(71): EditAction->show()
#16 C:\xampp\htdocs\MediaWiki\Git\core\includes\Wiki.php(429): SubmitAction->show()
#17 C:\xampp\htdocs\MediaWiki\Git\core\includes\Wiki.php(305): MediaWiki->performAction(Object(Article), Object(Title))
#18 C:\xampp\htdocs\MediaWiki\Git\core\includes\Wiki.php(555): MediaWiki->performRequest()
#19 C:\xampp\htdocs\MediaWiki\Git\core\includes\Wiki.php(448): MediaWiki->main()
#20 C:\xampp\htdocs\MediaWiki\Git\core\index.php(59): MediaWiki->run()
#21 {main}


Version: unspecified
Severity: normal

Details

Reference
bz41689

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:06 AM
bzimport added a project: Notifications.
bzimport set Reference to bz41689.

It looks like "actual" always seem to begin with a space which is not in "expected"... Changing $added_line and $subtracted_line to substr with 2 instead of 1 appears to fix it. (subtracted_line to fix basically the same problem but with line removal)

This fix needs to be tested on other machines, I can't do so at the moment:

diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index d8694ea..0064135 100644

  • a/includes/DiscussionParser.php

+++ b/includes/DiscussionParser.php
@@ -481,7 +481,7 @@ abstract class EchoDiscussionParser {

        list( $right_pos ) = explode( ',', $rhs_pos );
        $change_run = false;
} elseif ( $line_type == '-' ) {
  • $subtracted_line = substr( $line, 1 );

+ $subtracted_line = substr( $line, 2 );

if ( trim( $subtracted_line ) === '' ) {
        ++$left_pos;

@@ -508,7 +508,7 @@ abstract class EchoDiscussionParser {

        }
        ++$left_pos;
} elseif ( $line_type == '+' ) {
  • $added_line = substr( $line, 1 );

+ $added_line = substr( $line, 2 );

if ( $change_run !== false && $changes[$change_run]['action'] == 'add' ) {
        $changes[$change_run]['content'] .= "\n" . $added_line;

bsitu wrote:

This change would cause the same error on linux machine. I am wondering if it has something to do with the diffutils in window machine.

Hm yep, confirmed that the patch makes the previously working machine break with a similar error. -.-

Was about to post a duplicate bug. I can help testing on Windows.

Increasing some priority as this prevents me from testing other bugs on Win.

Thanks Nischay! Since I'm on OSX, I can't help much here.

Dug through this today, the problem is actually only tangentially related to windows.

Basically the most likely thing on windows is the gnu diff is not installed. MediaWiki contains Diff and UnifiedDiffFormatter classes to perform the diff in pure php. The output of UnifiedDiffFormatter does not match the output of gnu diff on my linux box, specifically:

GNU diffutils 3.2:

@@ -1,4 +1,4 @@
line 1
-line 2
+line b
line 3
line 4

MediaWiki Internal Diff:

@@ -1,4 +1,4 @@

line 1
  • line 2

+ line b

line 3
line 4

I see two possible solutions, but not sure which is more appropriate:

  1. Update UnifiedDiffFormatter to match the output of GNU diffutils 3.2. I worry that wfDiff() which calls the formatter is used in a variety of places, could break other things

Really option 1 seems like the only appropriate solution, but if we dont want to change UnifiedDiffFormatter we can:

  1. apply some heuristics to assume that if the second character of every line is a space, that it came from UnifiedDiffFormatter in which case we would strip that line out before processing further. Thats a horrible hack

I can code up either solution, but need some guidence on which is appropriate

Also the temporary fix until we decide on the right solution is for anyone on windows is to install GNU diff ( see http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Windows#Diffutils ) for windows. I've tested on windows and as long as its using GNU diff windows works just fine.

Related URL: https://gerrit.wikimedia.org/r/61514 (Gerrit Change Ib83cacab41adfbdfa8e122c0494b266d4caefc83)