r89899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89898‎ | r89899 | r89900 >
Date:23:02, 11 June 2011
Author:robin
Status:ok
Tags:
Comment:
* Ability to choose which test wiki for RandomByTest
* Small fixes for ViewUserLang
* Validate prefix in recent changes (if invalid, show all recent changes)
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/TestWikiRC.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php
@@ -13,7 +13,7 @@
1414 'path' => __FILE__,
1515 'name' => 'Wikimedia Incubator',
1616 'author' => 'SPQRobin',
17 - 'version' => '3.1.0',
 17+ 'version' => '3.1.1',
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator',
1919 'descriptionmsg' => 'wminc-desc',
2020 );
Index: trunk/extensions/WikimediaIncubator/SpecialRandomByTest.php
@@ -7,11 +7,15 @@
88 class SpecialRandomByTest extends RandomPage
99 {
1010 public function __construct() {
11 - global $wgUser, $wmincPref, $wmincProjectSite;
12 - if( IncubatorTest::isContentProject() ) {
 11+ global $wgUser, $wgRequest, $wmincPref, $wmincProjectSite;
 12+ $target = $wgRequest->getVal( 'testwiki' );
 13+ $target = IncubatorTest::analyzePrefix( $target );
 14+ $project = ( isset( $target['project'] ) ? $target['project'] : '' );
 15+ $lang = ( isset( $target['lang'] ) ? $target['lang'] : '' );
 16+ if( IncubatorTest::isContentProject() || ($project && $lang) ) {
1317 $dbr = wfGetDB( DB_SLAVE );
1418 $this->extra[] = 'page_title' .
15 - $dbr->buildLike( IncubatorTest::displayPrefix() . '/', $dbr->anyString() );
 19+ $dbr->buildLike( IncubatorTest::displayPrefix( $project, $lang ) . '/', $dbr->anyString() );
1620 } elseif($wgUser->getOption($wmincPref . '-project') == $wmincProjectSite['short'] ) {
1721 global $wgVersion;
1822 // only works above MW 1.17
Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
@@ -70,12 +70,15 @@
7171 global $wgOut, $wmincPref, $wmincProjectSite, $wgUser;
7272 $sk = $wgUser->getSkin();
7373 $user = User::newFromName( $target );
 74+ $name = $user->getName();
 75+ $id = $user->getId();
7476 $langNames = Language::getLanguageNames();
75 - if ( $user == null || $user->getId() == 0 ) {
 77+ if ( $user == null || $id == 0 ) {
7678 // show error if a user with that name does not exist
7779 $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
7880 } else {
7981 $userproject = $user->getOption( $wmincPref . '-project' );
 82+ $userproject = ($userproject ? $userproject : 'none');
8083 $usercode = $user->getOption( $wmincPref . '-code' );
8184 $prefix = IncubatorTest::displayPrefix( $userproject, $usercode );
8285 if ( IncubatorTest::isContentProject( $userproject ) ) {
@@ -85,11 +88,10 @@
8689 } else {
8790 $testwiki = wfMsgHtml( 'wminc-testwiki-none' );
8891 }
89 - $name = $user->getName();
9092 $wgOut->addHtml(
9193 Xml::openElement( 'ul' ) .
9294 '<li>' . wfMsgHtml( 'username' ) . ' ' .
93 - $sk->userLink( $name, $name ) . $sk->userToolLinks( $name, $name ) . '</li>' .
 95+ $sk->userLink( $id, $name ) . $sk->userToolLinks( $id, $name, true ) . '</li>' .
9496 '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
9597 ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
9698 '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -104,7 +104,7 @@
105105 */
106106 static function validatePrefix( $title, $onlyprefix = false ) {
107107 $data = self::analyzePrefix( $title, $onlyprefix );
108 - if( isset( $data['error'] ) ) { return true; }
 108+ if( !isset( $data['error'] ) ) { return true; }
109109 return false;
110110 }
111111
@@ -252,7 +252,7 @@
253253 static function efLoadViewUserLangLink( $id, $nt, &$links ) {
254254 global $wgUser;
255255 if ( $wgUser->isAllowed( 'viewuserlang' ) ) {
256 - $user = wfUrlencode( $nt->getText() );
 256+ $user = $nt->getText();
257257 $links[] = $wgUser->getSkin()->link(
258258 SpecialPage::getTitleFor( 'ViewUserLang', $user ),
259259 wfMsgHtml( 'wminc-viewuserlang' )
Index: trunk/extensions/WikimediaIncubator/TestWikiRC.php
@@ -20,12 +20,14 @@
2121 // If project site is selected, display all changes except test wiki changes
2222 $dbr = wfGetDB( DB_SLAVE );
2323 $conds[] = 'rc_title NOT ' . $dbr->buildLike( 'W', $dbr->anyChar(), '/', $dbr->anyString() );
24 - } else {
 24+ } elseif( IncubatorTest::validatePrefix( $prefix, true ) ) {
2525 // Else, display changes to the selected test wiki in the appropriate namespaces
2626 $dbr = wfGetDB( DB_SLAVE );
2727 $conds['rc_namespace'] = $wmincTestWikiNamespaces;
2828 $conds[] = 'rc_title ' . $dbr->buildLike( $prefix . '/', $dbr->anyString() ) .
2929 ' OR rc_title = ' . $dbr->addQuotes( $prefix );
 30+ } else {
 31+ return true;
3032 }
3133 return true;
3234 }

Sign-offs

UserFlagDate
Nikerabbitinspected13:45, 20 July 2011

Status & tagging log