r70351 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70350‎ | r70351 | r70352 >
Date:19:23, 2 August 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Added some debugging (and custom debug wrapper) to hunt down bugs seen at userbase
Modified paths:
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/RenderJob.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/RenderJob.php
@@ -63,6 +63,7 @@
6464
6565 // Do the edit
6666 $article->doEdit( $text, $summary, $flags );
 67+ SpecialPageTranslation::superDebug( __METHOD__, 'edit', $user, $title, $flags );
6768
6869 // User hack
6970 $wgUser = $oldUser;
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -44,15 +44,14 @@
4545
4646 // Check permissions
4747 if ( $wgRequest->wasPosted() && !$this->user->matchEditToken( $wgRequest->getText( 'token' ) ) ) {
 48+ self::superDebug( __METHOD__, "token failure", $this->user );
4849 $wgOut->permissionRequired( 'pagetranslation' );
49 -
5050 return;
5151 }
5252
5353 // We are processing some specific page
5454 if ( !$title->exists() ) {
5555 $wgOut->addWikiMsg( 'tpt-nosuchpage', $title->getPrefixedText() );
56 -
5756 return;
5857 }
5958
@@ -65,7 +64,7 @@
6665 $params = array( 'user' => $wgUser->getName() );
6766 $logger->addEntry( 'unmark', $page->getTitle(), null, array( serialize( $params ) ) );
6867 $wgOut->addWikiMsg( 'tpt-unmarked', $title->getPrefixedText() );
69 -
 68+ self::superDebug( __METHOD__, "unmarked page", $this->user, $title );
7069 return;
7170 }
7271
@@ -84,7 +83,7 @@
8584 if ( $revision !== intval($title->getLatestRevID()) ) {
8685 // We do want to notify the reviewer if the underlying page changes during review
8786 $wgOut->addWikiMsg( 'tpt-oldrevision', $title->getPrefixedText(), $revision );
88 -
 87+ self::superDebug( __METHOD__, "revision mismatch while marking", $this->user, $title, $revision, intval($title->getLatestRevID()) );
8988 return;
9089 }
9190
@@ -113,6 +112,7 @@
114113 return;
115114 }
116115
 116+ self::superDebug( __METHOD__, "marking page", $this->user, $title, $revision );
117117 $this->showPage( $page, $sections );
118118 }
119119
@@ -443,6 +443,7 @@
444444 );
445445
446446 if ( !$status->isOK() ) {
 447+ self::superDebug( __METHOD__, 'edit-fail', $this->user, $page->getTitle(), $status );
447448 return array( 'tpt-edit-failed', $status->getWikiText() );
448449 }
449450
@@ -460,6 +461,8 @@
461462 $newrevision = $page->getTitle()->getLatestRevId();
462463 }
463464
 465+ self::superDebug( __METHOD__, 'latestrev', $page->getTitle(), $newrevision );
 466+
464467 $inserts = array();
465468 $changed = array();
466469
@@ -514,6 +517,7 @@
515518
516519 public function addFuzzyTags( $page, $changed ) {
517520 if ( !count( $changed ) ) {
 521+ self::superDebug( __METHOD__, 'nochanged', $page->getTitle() );
518522 return;
519523 }
520524
@@ -547,6 +551,7 @@
548552 }
549553
550554 if ( count( $inserts ) ) {
 555+ self::superDebug( __METHOD__, 'inserts', $inserts );
551556 $db->replace( 'revtag', array( 'rt_type_page_revision' ), $inserts, __METHOD__ );
552557 }
553558 }
@@ -556,16 +561,34 @@
557562 $jobs = array();
558563
559564 foreach ( $titles as $t ) {
 565+ self::superDebug( __METHOD__, 'renderjob', $t );
560566 $jobs[] = RenderJob::newJob( $t );
561567 }
562568
563569 if ( count( $jobs ) < 10 ) {
 570+ self::superDebug( __METHOD__, 'renderjob-immediate' );
564571 foreach ( $jobs as $j ) {
565572 $j->run();
566573 }
567574 } else {
568575 // Use the job queue
 576+ self::superDebug( __METHOD__, 'renderjob-delayed' );
569577 Job::batchInsert( $jobs );
570578 }
571579 }
 580+
 581+ public static function superDebug( $method, $msg /* varags */ ) {
 582+ $args = func_get_args();
 583+ $args = array_slice( $args, 2 );
 584+ foreach ( $args as &$arg ) {
 585+ if ( $arg instanceof User ) {
 586+ $arg = array( 'user' => $arg->getName(), 'id' => $arg->getId() );
 587+ } elseif ( $arg instanceof Title ) {
 588+ $arg = array( 'title' => $arg->getPrefixedText(), 'aid' => $arg->getArticleID() );
 589+ }
 590+ $arg = serialize( $arg );
 591+ }
 592+
 593+ wfDebugLog( 'pagetranslation', "$method: $msg [" . implode( " ", $args ) . "]\n" );
 594+ }
572595 }
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -64,6 +64,7 @@
6565 $groupKey = self::titleToGroup( $title );
6666 $group = MessageGroups::getGroup( $groupKey );
6767 if ( !$group instanceof WikiPageMessageGroup ) {
 68+ SpecialPageTranslation::superDebug( __METHOD__, 'not wp-group', $title, $user, $groupKey );
6869 return;
6970 }
7071
@@ -79,6 +80,7 @@
8081 list( , $code ) = TranslateUtils::figureMessage( $title->getDBkey() );
8182 global $wgTranslateDocumentationLanguageCode;
8283 if ( $code !== $wgTranslateDocumentationLanguageCode ) {
 84+ SpecialPageTranslation::superDebug( __METHOD__, 'ok', $title, $user );
8385 self::updateTranslationPage( $page, $code, $user, $flags, $summary );
8486 }
8587

Status & tagging log