User:Catrope/Extension review/Incubator

INCUBATOR REVIEW /trunk/extensions/WikimediaIncubator @ r88357

Most important issues:
 * 1) Will break on the deployment branch because Linker::link isn't static there yet, and because it's being called in a broken way
 * 2) Will break for language codes longer than three letters or containing non-letter characters (e.g. nds-nl, zh-cn)
 * It is the current policy not to allow non-ISO 639 codes. I will change it if needed. (Btw, Language::isValidCode seems to return the value '11' for some reason). SPQRobin 16:37, 20 May 2011 (UTC)
 * OK, that's fine. Just make sure it's documented then. --Catrope 17:17, 20 May 2011 (UTC)
 * 1) Uses a broken way of adding a hidden input field to the user creation form, and will break other extensions using the same broken method (ConfirmAccount and ConfirmEdit)
 * 2) Some messages are added to the HTML unescaped. This is needed sometimes, but should be avoided when not needed.
 * 3) Not using proper query building everywhere.
 * 4) Some Incubator-specific things like project prefixes are configurable, but the config is ignored in favor of hardcoding about half the time,
 * 5) Code duplication in some places

General:
 * Coding style not followed everywhere. I'll run stylize

CreateAccountTestWiki.php:
 * AutoTestWiki functions are called statically through $wgHooks, so they should be declared as public static
 * (2) In AutoTestWiki::onUserCreateForm: /[a-z][a-z][a-z]?/ doesn't match language codes like nds-nl. Use Language::isValidCode
 * (3) To be nice to other extensions, AutoTestWiki::onUserCreateForm should append to the header instead of overwriting it
 * UsercreateTemplate has a convenience function for this called addInputItem. For example usage see TitleBlacklistHooks::addOverrideCheckbox
 * AutoTestWiki::onAddNewAccount should do the same validation as onUserCreateForm

IncubatorTest.php:
 * IncubatorTest::onGetPreferences
 * $wmincPrefProject and $wmincPrefNone aren't used anywhere and aren't declared in the extension setup file
 * (2) Max length 3 for language code preference doesn't make sense: there are longer language codes, e.g. nds-nl
 * The callback for the language code validation is wrongly capitalized (CodeValidation vs. codeValidation), although PHP doesn't seem to care
 * All functions in IncubatorTest are called statically, so they should be declared as static
 * IncubatorTest::isNormalPrefix isn't very nicely written: it should take the prefix as a parameter.
 * You can also use return is_array(...); instead of if ( in_array(...) ) { return true; } else { return false; }
 * IncubatorTest::displayPrefix: don't use == true, just use if ( self::isNormalPrefix )
 * (7) IncubatorTest::displayPrefixedTitle should take a Title object call $title->getPrefixedText to get a namespace:title string instead of reinventing the wheel
 * IncubatorTest::editPageCheckPrefix
 * (6) 'inc' is hardcoded, use $wmincProjectSite['short'] instead
 * (6) Set of namespaces is hardcoded, should probably be configurable
 * (2,6) Regex is hardcoded but inferred from stuff in $wmincProjects. Also uses three-letter language codes
 * Indentation in the if ( is_array(..) ) block is weird
 * if ( !$wgTitle->exists ) block and its elseif block are not indented
 * Use wfUrlencode instead of urlencode
 * efLoadViewUserLangLink
 * should also be a static function in a class
 * makeKnownLinkObj is deprecated, use link

SpecialViewUserLang.php:
 * SpecialViewUserLang::execute: instead of doing if ( $target ) { ... } else { ... } you can use $wgRequest->getText( 'target', $subpage );
 * SpecialViewUserLang::showInfo
 * Don't use == true
 * (1) Linker::link is the new style in trunk, but this doesn't work on the live site yet. Use $sk->link for now
 * (1) The parameter to link must be a Title object rather than a string
 * (7) The logic for building the string fed to link is duplicated from IncubatorTest::displayPrefix
 * (4) In the code paths where $testwiki is not set to the return value of link, it should be escaped with htmlspecialchars
 * (4) All of the wfMsg calls inside the $wgOut->addHTML call should be changed to call wfMsgHtml instead so those messages are escaped

TestWikiRC.php:
 * TestWikiRC::onRcQuery
 * (7) The logic for building $fullprefix is duplicated from IncubatorTest::displayPrefix
 * Use || instead of OR
 * (5) Use $dbr->buildLike to build the NOT LIKE query
 * What's up with the double percent signs?
 * rc_title NOT LIKE 'foo' OR 'bar' doesn't seem to work as intended. You seem to want rc_title NOT LIKE 'foo' AND rc_title NOT LIKE 'bar'
 * (5) Don't build your own IN(...) list with makeList, just use $conds['rc_namespace'] = $namespaces;
 * (6) Hardcoded set of namespaces appears again
 * TestWikiRC::onRcForm
 * (2) Max length for language codes set to 3 again
 * rc-testwiki-project and rc-testwiki-code seem to be loaded into $opts by onRcQuery, then taken out by onRcForm, but the latter doesn't use their values. What's going on here?