r95452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95451‎ | r95452 | r95453 >
Date:22:11, 24 August 2011
Author:reedy
Status:ok
Tags:
Comment:
More document

Few minor code improvements
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.hooks.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterView.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -335,18 +335,31 @@
336336 }
337337
338338 /** Convert shorteners */
 339+
 340+ /**
 341+ * @return bool
 342+ */
339343 public function toBool() {
340344 return self::castTypes( $this, self::DBool )->data;
341345 }
342346
 347+ /**
 348+ * @return string
 349+ */
343350 public function toString() {
344351 return self::castTypes( $this, self::DString )->data;
345352 }
346353
 354+ /**
 355+ * @return float
 356+ */
347357 public function toFloat() {
348358 return self::castTypes( $this, self::DFloat )->data;
349359 }
350360
 361+ /**
 362+ * @return int
 363+ */
351364 public function toInt() {
352365 return self::castTypes( $this, self::DInt )->data;
353366 }
@@ -557,7 +570,11 @@
558571
559572 /* Levels */
560573
561 - /** Handles unexpected characters after the expression */
 574+ /**
 575+ * Handles unexpected characters after the expression
 576+ *
 577+ * @param $result
 578+ */
562579 protected function doLevelEntry( &$result ) {
563580 $this->doLevelSemicolon( $result );
564581
@@ -566,7 +583,10 @@
567584 }
568585 }
569586
570 - /** Handles multiple expressions */
 587+ /**
 588+ * Handles multiple expressions
 589+ * @param $result
 590+ */
571591 protected function doLevelSemicolon( &$result ) {
572592 do {
573593 $this->move();
@@ -576,7 +596,11 @@
577597 } while ( $this->mCur->type == AFPToken::TStatementSeparator );
578598 }
579599
580 - /** Handles multiple expressions */
 600+ /**
 601+ * Handles multiple expressions
 602+ *
 603+ * @param $result
 604+ */
581605 protected function doLevelSet( &$result ) {
582606 if ( $this->mCur->type == AFPToken::TID ) {
583607 $varname = $this->mCur->value;
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php
@@ -18,6 +18,9 @@
1919
2020 abstract function show();
2121
 22+ /**
 23+ * @return bool
 24+ */
2225 function canEdit() {
2326 global $wgUser;
2427 static $canEdit = null;
@@ -29,6 +32,9 @@
3033 return $canEdit;
3134 }
3235
 36+ /**
 37+ * @return bool
 38+ */
3339 function canViewPrivate() {
3440 global $wgUser;
3541 static $canView = null;
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
@@ -77,6 +77,12 @@
7878 }
7979
8080 class AbuseFilterHistoryPager extends TablePager {
 81+
 82+ /**
 83+ * @param $filter
 84+ * @param $page Article
 85+ * @param $user User
 86+ */
8187 function __construct( $filter, $page, $user ) {
8288 $this->mFilter = $filter;
8389 $this->mPage = $page;
@@ -256,6 +262,8 @@
257263 /**
258264 * Title used for self-links. Override this if you want to be able to
259265 * use a title other than $wgTitle
 266+ *
 267+ * @return Title
260268 */
261269 function getTitle() {
262270 return $this->mPage->getTitle( 'history/' . $this->mFilter );
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -410,7 +410,13 @@
411411 return $result;
412412 }
413413
414 - /** Returns an associative array of filters which were tripped */
 414+ /**
 415+ * Returns an associative array of filters which were tripped
 416+ *
 417+ * @param $vars array
 418+ *
 419+ * @return array
 420+ */
415421 public static function checkAllFilters( $vars ) {
416422 // Fetch from the database.
417423 wfProfileIn( __METHOD__ );
@@ -548,7 +554,13 @@
549555 return array( $timeProfile, $condProfile );
550556 }
551557
552 - /** Utility function to decode global-$index to $index. Returns false if not global */
 558+ /**
 559+ * Utility function to decode global-$index to $index. Returns false if not global
 560+ *
 561+ * @param $filter string
 562+ *
 563+ * @return string|false
 564+ */
553565 public static function decodeGlobalName( $filter ) {
554566 if ( strpos( $filter, 'global-' ) == 0 ) {
555567 return substr( $filter, strlen( 'global-' ) );
@@ -628,7 +640,14 @@
629641 return $actionsByFilter;
630642 }
631643
632 - /** Returns an array [ list of actions taken by filter, error message to display, if any ] */
 644+ /**
 645+ * Returns an array [ list of actions taken by filter, error message to display, if any ]
 646+ *
 647+ * @param $filters array
 648+ * @param $title Title
 649+ * @param $vars array
 650+ * @return array
 651+ */
633652 public static function executeFilterActions( $filters, $title, $vars ) {
634653 wfProfileIn( __METHOD__ );
635654 static $blockingActions = array(
@@ -885,6 +904,11 @@
886905 /**
887906 * Store a var dump to External Storage or the text table
888907 * Some of this code is stolen from Revision::insertOn and friends
 908+ *
 909+ * @param $vars array
 910+ * @param $global bool
 911+ *
 912+ * @return int
889913 */
890914 public static function storeVarDump( $vars, $global = false ) {
891915 wfProfileIn( __METHOD__ );
@@ -946,6 +970,10 @@
947971 /**
948972 * Retrieve a var dump from External Storage or the text table
949973 * Some of this code is stolen from Revision::loadText et al
 974+ *
 975+ * @param $stored_dump
 976+ *
 977+ * @return object
950978 */
951979 public static function loadVarDump( $stored_dump ) {
952980 wfProfileIn( __METHOD__ );
@@ -1187,10 +1215,8 @@
11881216 break;
11891217 case 'site':
11901218 return 1;
1191 - break;
11921219 case 'page':
11931220 return $title->getPrefixedText();
1194 - break;
11951221 }
11961222
11971223 return $identifier;
@@ -1414,6 +1440,11 @@
14151441 /**
14161442 * Each version is expected to be an array( $row, $actions )
14171443 * Returns an array of fields that are different.
 1444+ *
 1445+ * @param $version_1
 1446+ * @param $version_2
 1447+ *
 1448+ * @return array
14181449 */
14191450 static function compareVersions( $version_1, $version_2 ) {
14201451 $compareFields = array(
Index: trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php
@@ -107,7 +107,15 @@
108108 $this->mParameters = $parameters;
109109 }
110110
111 - /** It's like Article::prepareTextForEdit, but not for editing (old wikitext usually) */
 111+ /**
 112+ * It's like Article::prepareTextForEdit, but not for editing (old wikitext usually)
 113+ *
 114+ *
 115+ * @param $wikitext String
 116+ * @param $article Article
 117+ *
 118+ * @return object
 119+ */
112120 function parseNonEditWikitext( $wikitext, $article ) {
113121 static $cache = array();
114122
@@ -121,7 +129,7 @@
122130 $edit = (object)array();
123131 $options = new ParserOptions;
124132 $options->setTidy( true );
125 - $edit->output = $wgParser->parse( $wikitext, $article->mTitle, $options );
 133+ $edit->output = $wgParser->parse( $wikitext, $article->getTitle(), $options );
126134 $cache[$cacheKey] = $edit;
127135
128136 return $edit;
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php
@@ -6,6 +6,14 @@
77 class AbuseFilterHooks {
88 // So far, all of the error message out-params for these hooks accept HTML.
99 // Hooray!
 10+
 11+ /**
 12+ * @param $editor
 13+ * @param $text
 14+ * @param $error
 15+ * @param $summary
 16+ * @return bool
 17+ */
1018 public static function onEditFilterMerged( $editor, $text, &$error, $summary ) {
1119 // Load vars
1220 $vars = new AbuseFilterVariableHolder;
@@ -198,11 +206,11 @@
199207 $wgExtPGNewFields[] = array( 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" );
200208 $wgExtPGNewFields[] = array( 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' );
201209 $wgExtPGNewFields[] = array( 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' );
202 -
 210+
203211 $wgExtPGNewFields[] = array( 'abuse_filter_log', 'afl_wiki', 'TEXT' );
204212 $wgExtPGNewFields[] = array( 'abuse_filter_log', 'afl_deleted', 'SMALLINT' );
205213 $wgExtPGAlteredFields[] = array( 'abuse_filter_log', 'afl_filter', 'TEXT' );
206 -
 214+
207215 $wgExtNewIndexes[] = array( 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" );
208216 }
209217 } else {

Sign-offs

UserFlagDate
Krinkleinspected22:13, 24 August 2011

Status & tagging log