r56493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56492‎ | r56493 | r56494 >
Date:07:06, 17 September 2009
Author:siebrand
Status:deferred
Tags:
Comment:
Revert r56465: spewing notices
PHP Notice: Undefined variable: this in /var/www/w/extensions/Translate/TranslateEditAddons.php on line 443
PHP Notice: Undefined variable: this in /var/www/w/extensions/Translate/TranslateEditAddons.php on line 563
Modified paths:
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -288,14 +288,13 @@
289289 $en = $group->getMessage( $key, 'en' );
290290 $xx = $group->getMessage( $key, $code );
291291
 292+
292293 // Set-up the content area contents properly and not randomly as in
293294 // MediaWiki core. $translation is also used for checks later on. Also
294295 // add the fuzzy string if necessary.
295296 $translation = TranslateUtils::getMessageContent( $key, $code, $nsMain );
296 - $isfuzzy = false;
297297 if ( $translation !== null ) {
298 - $isfuzzy = self::isFuzzy( $object->mTitle );
299 - if ( !self::hasFuzzyString( $translation) && $isfuzzy ) {
 298+ if ( !self::hasFuzzyString( $translation) && self::isFuzzy( $object->mTitle ) ) {
300299 $translation = TRANSLATE_FUZZY . $translation;
301300 }
302301 } else {
@@ -403,11 +402,8 @@
404403 }
405404 }
406405
407 - // Diff of current version of original, and its version before last edit of translation, if any
408406 global $wgEnablePageTranslation;
409 - $showdiff1 = ( $wgEnablePageTranslation && $group instanceof WikiPageMessageGroup );
410 - $showdiff2 = ( $isfuzzy );
411 - if ( $showdiff1 ) {
 407+ if ( $wgEnablePageTranslation && $group instanceof WikiPageMessageGroup ) {
412408 // TODO: encapsulate somewhere
413409 $page = TranslatablePage::newFromTitle( $group->title );
414410 $rev = $page->getTransRev( "$key/$code" );
@@ -421,76 +417,23 @@
422418 $oldtext = $section->getTextForTrans();
423419 }
424420 }
 421+
425422 foreach ( $page->getParse()->getSectionsForSave() as $section ) {
426423 if ( $group->title->getPrefixedDBKey() .'/'. $section->id === $key ) {
427424 $newtext = $section->getTextForTrans();
428425 }
429426 }
430 - }
431 - else
432 - {
433 - }
434 - } elseif ( $showdiff2 ) {
435 - $newtext = $en; // FIXME: this should be sufficient, but this seems to come from the MessagesEnphp file instead of most recent the data base record, which is wrong.
436 - $en_title = Title::makeTitle( $nsMain, $key . '/en' ); // workaround
437 - $revision = Revision::newFromTitle($en_title); // workaround
438 - $newtext = $revision->getText(); // workaround
439 - $oldtext = FALSE;
440 - // find timestamp of last revision of the current page before it was fuzzied.
441 - $rev = $object->getBaseRevision()->getId();
442 - if ( $rev )
443 - {
444 - $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
445 - $dbr = wfGetDB( DB_SLAVE );
446 - $pid = $dbr->selectField( 'revision', 'rev_page', array( 'rev_id' => $rev ), $fname );
447 - if ( $pid )
448 - {
449 - $not_fuzzy = TranslateEditAddons::findLastRevisionByTag( $rev, 'fuzzy', FALSE );
450 - if ( $not_fuzzy )
451 - {
452 - $rev_en = $dbr->selectRow(
453 - array ( 'revision', 'page'),
454 - 'rev_id',
455 - array(
456 - 'page_namespace' => $nsMain,
457 - 'page_title' => $key . '/en',
458 - 'rev_page = page_id',
459 - 'rev_timestamp < '.$not_fuzzy->rev_timestamp
460 - ),
461 - $fname,
462 - array(
463 - 'ORDER BY' => 'rev_timestamp DESC',
464 - 'LIMIT' => 1
465 - )
466 - );
467 - if ( $rev_en )
468 - {
469 - $rev_en = $rev_en->rev_id;
470 - }
471 - if ( $rev_en )
472 - {
473 - $revision = Revision::newFromId($rev_en);
474 - $oldtext = $revision->getText();
475427
476 - // FIXME: Own header messages for this case
477 - // FIXME: Links to the revision pages
478 - // FIXME: Previous and next links
479 - // FIXME: Allow switching to HTMLdiff
480 - }
481 - }
 428+ if ( $oldtext !== $newtext ) {
 429+ wfLoadExtensionMessages( 'PageTranslation' );
 430+ $diff = new DifferenceEngine;
 431+ $diff->setText( $oldtext, $newtext );
 432+ $diff->setReducedLineNumbers();
 433+ $boxes[] = $diff->getDiff( wfMsgHtml('tpt-diff-old'), wfMsgHtml('tpt-diff-new') );
 434+ $diff->showDiffStyle();
482435 }
483436 }
484437 }
485 - if ( ( $showdiff1 || $showdiff2 ) && ( $oldtext !== $newtext ) && ( $oldtext !== FALSE ) ) {
486 - wfLoadExtensionMessages( 'PageTranslation' );
487 - $diff = new DifferenceEngine;
488 - if ( $showdiff1 )
489 - $diff->setReducedLineNumbers();
490 - $diff->setText( $oldtext, $newtext );
491 - $diff->showDiffStyle();
492 - $boxes[] = $diff->getDiff( wfMsgHtml('tpt-diff-old'), wfMsgHtml('tpt-diff-new') );
493 - // FIXME: If there are versions in between say so.
494 - }
495438
496439 // Definition
497440 if ( $en !== null ) {
@@ -546,45 +489,6 @@
547490 return $res === $id;
548491 }
549492
550 - /**
551 - * Get last revision of a page (not) having a specific revision tag
552 - * @param $pageId page Id
553 - * @param $set TRUE: find youngest revison having the tag
554 - * FALSE: find youngest revison *not* having the tag
555 - * @param $rtt_name revision tag name to look for
556 - * @return FALSE: no such revision found
557 - * otherwise,
558 - * if $not is TRUE: object ( rev_id, rev_timestamp, NULL, NULL )
559 - * if $not is FALSE: object ( rev_id, rev_timestamp, rt_value, rt_revision )
560 - * TODO: move to a more appropriate place, maybe in core.
561 - * @author Purodha
562 - */
563 - public static function findLastRevisionByTag( $pageId, $rtt_name='fuzzy', $set=false ) {
564 - $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
565 - $dbr = wfGetDB( DB_SLAVE );
566 - $id = $dbr->selectField( 'revtag_type', 'rtt_id', array( 'rtt_name' => $rtt_name ), $fname );
567 - $tables = array( 'revision' , 'revtag' );
568 - $fields = array( 'rev_id', 'rev_timestamp', 'rt_value', 'rt_revision' );
569 - $conds = array(
570 - 'rev_page' => $pageId,
571 - );
572 - if ( $set )
573 - {
574 - $conds[ 'rt_page' ] = $pageId;
575 - $conds[ 'rt_type' ] = $id;
576 - }
577 - else
578 - {
579 - $conds[] = 'rt_page IS NULL';
580 - $conds[] = 'rt_type IS NULL';
581 - }
582 - $join_conds [ 'revtag' ] = array('LEFT JOIN', 'rev_id = rt_revision');
583 - $options['ORDER BY'] = 'rev_timestamp DESC';
584 - $options['LIMIT'] = 1;
585 - $res = $dbr->selectRow( $tables, $fields, $conds, $fname, $options, $join_conds );
586 - return $res;
587 - }
588 -
589493 public static function isMessageNamespace( Title $title ) {
590494 global $wgTranslateMessageNamespaces;;
591495 $namespace = $title->getNamespace();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56465Show diff of original English message when translation is fuzzied.purodha00:13, 17 September 2009

Status & tagging log