r101161 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101160‎ | r101161 | r101162 >
Date:18:11, 28 October 2011
Author:reedy
Status:resolved
Tags:
Comment:
More documentation updates
Modified paths:
  • /trunk/phase3/includes/DeferredUpdates.php (modified) (history)
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/cache/HTMLCacheUpdate.php (modified) (history)
  • /trunk/phase3/includes/context/ContextSource.php (modified) (history)
  • /trunk/phase3/maintenance/importDump.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importDump.php
@@ -117,6 +117,10 @@
118118 $this->error( "Unknown namespace text / index specified: $namespace", true );
119119 }
120120
 121+ /**
 122+ * @param $obj Title|Revision
 123+ * @return bool
 124+ */
121125 private function skippedNamespace( $obj ) {
122126 if ( $obj instanceof Title ) {
123127 $ns = $obj->getNamespace();
@@ -135,6 +139,10 @@
136140 $this->pageCount++;
137141 }
138142
 143+ /**
 144+ * @param $rev Revision
 145+ * @return mixed
 146+ */
139147 function handleRevision( $rev ) {
140148 $title = $rev->getTitle();
141149 if ( !$title ) {
@@ -161,7 +169,7 @@
162170 function handleUpload( $revision ) {
163171 if ( $this->uploads ) {
164172 if ( $this->skippedNamespace( $revision ) ) {
165 - return ;
 173+ return;
166174 }
167175 $this->uploadCount++;
168176 // $this->report();
@@ -223,11 +231,9 @@
224232 function importFromFile( $filename ) {
225233 if ( preg_match( '/\.gz$/', $filename ) ) {
226234 $filename = 'compress.zlib://' . $filename;
227 - }
228 - elseif ( preg_match( '/\.bz2$/', $filename ) ) {
 235+ } elseif ( preg_match( '/\.bz2$/', $filename ) ) {
229236 $filename = 'compress.bzip2://' . $filename;
230 - }
231 - elseif ( preg_match( '/\.7z$/', $filename ) ) {
 237+ } elseif ( preg_match( '/\.7z$/', $filename ) ) {
232238 $filename = 'mediawiki.compress.7z://' . $filename;
233239 }
234240
Index: trunk/phase3/includes/LocalisationCache.php
@@ -40,6 +40,8 @@
4141
4242 /**
4343 * The persistent store object. An instance of LCStore.
 44+ *
 45+ * @var LCStore
4446 */
4547 var $store;
4648
@@ -132,6 +134,8 @@
133135 */
134136 static public $preloadedKeys = array( 'dateFormats', 'namespaceNames' );
135137
 138+ var $mergeableKeys = array();
 139+
136140 /**
137141 * Constructor.
138142 * For constructor parameters, see the documentation in DefaultSettings.php
@@ -180,6 +184,8 @@
181185 /**
182186 * Returns true if the given key is mergeable, that is, if it is an associative
183187 * array which can be merged through a fallback sequence.
 188+ * @param $key
 189+ * @return bool
184190 */
185191 public function isMergeableKey( $key ) {
186192 if ( !isset( $this->mergeableKeys ) ) {
@@ -199,6 +205,9 @@
200206 *
201207 * Warning: this may be slow for split items (messages), since it will
202208 * need to fetch all of the subitems from the cache individually.
 209+ * @param $code
 210+ * @param $key
 211+ * @return string
203212 */
204213 public function getItem( $code, $key ) {
205214 if ( !isset( $this->loadedItems[$code][$key] ) ) {
@@ -216,6 +225,10 @@
217226
218227 /**
219228 * Get a subitem, for instance a single message for a given language.
 229+ * @param $code
 230+ * @param $key
 231+ * @param $subkey
 232+ * @return null
220233 */
221234 public function getSubitem( $code, $key, $subkey ) {
222235 if ( !isset( $this->loadedSubitems[$code][$key][$subkey] )
@@ -241,6 +254,9 @@
242255 *
243256 * Will return null if the item is not found, or false if the item is not an
244257 * array.
 258+ * @param $code
 259+ * @param $key
 260+ * @return bool|null|string
245261 */
246262 public function getSubitemList( $code, $key ) {
247263 if ( in_array( $key, self::$splitKeys ) ) {
@@ -257,6 +273,8 @@
258274
259275 /**
260276 * Load an item into the cache.
 277+ * @param $code
 278+ * @param $key
261279 */
262280 protected function loadItem( $code, $key ) {
263281 if ( !isset( $this->initialisedLangs[$code] ) ) {
@@ -290,6 +308,10 @@
291309
292310 /**
293311 * Load a subitem into the cache
 312+ * @param $code
 313+ * @param $key
 314+ * @param $subkey
 315+ * @return
294316 */
295317 protected function loadSubitem( $code, $key, $subkey ) {
296318 if ( !in_array( $key, self::$splitKeys ) ) {
@@ -350,6 +372,7 @@
351373
352374 /**
353375 * Initialise a language in this object. Rebuild the cache if necessary.
 376+ * @param $code
354377 */
355378 protected function initLanguage( $code ) {
356379 if ( isset( $this->initialisedLangs[$code] ) ) {
@@ -406,6 +429,8 @@
407430 /**
408431 * Create a fallback from one language to another, without creating a
409432 * complete persistent cache.
 433+ * @param $primaryCode
 434+ * @param $fallbackCode
410435 */
411436 public function initShallowFallback( $primaryCode, $fallbackCode ) {
412437 $this->data[$primaryCode] =& $this->data[$fallbackCode];
@@ -416,6 +441,9 @@
417442
418443 /**
419444 * Read a PHP file containing localisation data.
 445+ * @param $_fileName
 446+ * @param $_fileType
 447+ * @return array
420448 */
421449 protected function readPHPFile( $_fileName, $_fileType ) {
422450 // Disable APC caching
@@ -437,6 +465,9 @@
438466 /**
439467 * Merge two localisation values, a primary and a fallback, overwriting the
440468 * primary value in place.
 469+ * @param $key
 470+ * @param $value
 471+ * @param $fallbackValue
441472 */
442473 protected function mergeItem( $key, &$value, $fallbackValue ) {
443474 if ( !is_null( $value ) ) {
@@ -464,6 +495,10 @@
465496 }
466497 }
467498
 499+ /**
 500+ * @param $value
 501+ * @param $fallbackValue
 502+ */
468503 protected function mergeMagicWords( &$value, $fallbackValue ) {
469504 foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
470505 if ( !isset( $value[$magicName] ) ) {
@@ -485,6 +520,11 @@
486521 *
487522 * Returns true if any data from the extension array was used, false
488523 * otherwise.
 524+ * @param $codeSequence
 525+ * @param $key
 526+ * @param $value
 527+ * @param $fallbackValue
 528+ * @return bool
489529 */
490530 protected function mergeExtensionItem( $codeSequence, $key, &$value, $fallbackValue ) {
491531 $used = false;
@@ -501,6 +541,7 @@
502542 /**
503543 * Load localisation data for a given language for both core and extensions
504544 * and save it to the persistent cache store and the process cache
 545+ * @param $code
505546 */
506547 public function recache( $code ) {
507548 global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
@@ -688,6 +729,8 @@
689730 *
690731 * The preload item will be loaded automatically, improving performance
691732 * for the commonly-requested items it contains.
 733+ * @param $data
 734+ * @return array
692735 */
693736 protected function buildPreload( $data ) {
694737 $preload = array( 'messages' => array() );
@@ -710,6 +753,7 @@
711754 /**
712755 * Unload the data for a given language from the object cache.
713756 * Reduces memory usage.
 757+ * @param $code
714758 */
715759 public function unload( $code ) {
716760 unset( $this->data[$code] );
@@ -781,6 +825,8 @@
782826 /**
783827 * Set a key to a given value. startWrite() must be called before this
784828 * is called, and finishWrite() must be called afterwards.
 829+ * @param $key
 830+ * @param $value
785831 */
786832 function set( $key, $value );
787833 }
@@ -792,7 +838,12 @@
793839 class LCStore_DB implements LCStore {
794840 var $currentLang;
795841 var $writesDone = false;
796 - var $dbw, $batch;
 842+
 843+ /**
 844+ * @var DatabaseBase
 845+ */
 846+ var $dbw;
 847+ var $batch;
797848 var $readOnly = false;
798849
799850 public function get( $code, $key ) {
@@ -999,6 +1050,11 @@
10001051 */
10011052 var $maxLoadedLangs = 10;
10021053
 1054+ /**
 1055+ * @param $fileName
 1056+ * @param $fileType
 1057+ * @return array|mixed
 1058+ */
10031059 protected function readPHPFile( $fileName, $fileType ) {
10041060 $serialize = $fileType === 'core';
10051061 if ( !isset( $this->fileCache[$fileName][$fileType] ) ) {
@@ -1020,18 +1076,32 @@
10211077 }
10221078 }
10231079
 1080+ /**
 1081+ * @param $code
 1082+ * @param $key
 1083+ * @return string
 1084+ */
10241085 public function getItem( $code, $key ) {
10251086 unset( $this->mruLangs[$code] );
10261087 $this->mruLangs[$code] = true;
10271088 return parent::getItem( $code, $key );
10281089 }
10291090
 1091+ /**
 1092+ * @param $code
 1093+ * @param $key
 1094+ * @param $subkey
 1095+ * @return
 1096+ */
10301097 public function getSubitem( $code, $key, $subkey ) {
10311098 unset( $this->mruLangs[$code] );
10321099 $this->mruLangs[$code] = true;
10331100 return parent::getSubitem( $code, $key, $subkey );
10341101 }
10351102
 1103+ /**
 1104+ * @param $code
 1105+ */
10361106 public function recache( $code ) {
10371107 parent::recache( $code );
10381108 unset( $this->mruLangs[$code] );
@@ -1039,6 +1109,9 @@
10401110 $this->trimCache();
10411111 }
10421112
 1113+ /**
 1114+ * @param $code
 1115+ */
10431116 public function unload( $code ) {
10441117 unset( $this->mruLangs[$code] );
10451118 parent::unload( $code );
Index: trunk/phase3/includes/DeferredUpdates.php
@@ -35,6 +35,8 @@
3636 * HTMLCacheUpdates are the most common deferred update people use. This
3737 * is a shortcut method for that.
3838 * @see HTMLCacheUpdate::__construct()
 39+ * @param $title
 40+ * @param $table
3941 */
4042 public static function addHTMLCacheUpdate( $title, $table ) {
4143 self::addUpdate( new HTMLCacheUpdate( $title, $table ) );
Index: trunk/phase3/includes/context/ContextSource.php
@@ -35,9 +35,9 @@
3636 private $context;
3737
3838 /**
39 - * Get the IContextSource object
 39+ * Get the RequestContext object
4040 *
41 - * @return IContextSource
 41+ * @return RequestContext
4242 */
4343 public function getContext() {
4444 if ( $this->context === null ) {
Index: trunk/phase3/includes/LogEventsList.php
@@ -726,7 +726,7 @@
727727 /**
728728 * SQL clause to skip forbidden log types for this user
729729 *
730 - * @param $db Database
 730+ * @param $db DatabaseBase
731731 * @param $audience string, public/user
732732 * @return Mixed: string or false
733733 */
Index: trunk/phase3/includes/WebRequest.php
@@ -1259,15 +1259,26 @@
12601260 $this->headers[$name] = $val;
12611261 }
12621262
 1263+ /**
 1264+ * @param $key
 1265+ * @return mixed
 1266+ */
12631267 public function getSessionData( $key ) {
12641268 if( isset( $this->session[$key] ) )
12651269 return $this->session[$key];
12661270 }
12671271
 1272+ /**
 1273+ * @param $key
 1274+ * @param $data
 1275+ */
12681276 public function setSessionData( $key, $data ) {
12691277 $this->session[$key] = $data;
12701278 }
12711279
 1280+ /**
 1281+ * @return array|Mixed|null
 1282+ */
12721283 public function getSessionArray() {
12731284 return $this->session;
12741285 }
Index: trunk/phase3/includes/cache/HTMLCacheUpdate.php
@@ -32,6 +32,12 @@
3333 public $mTable, $mPrefix, $mStart, $mEnd;
3434 public $mRowsPerJob, $mRowsPerQuery;
3535
 36+ /**
 37+ * @param $titleTo
 38+ * @param $table
 39+ * @param $start bool
 40+ * @param $end bool
 41+ */
3642 function __construct( $titleTo, $table, $start = false, $end = false ) {
3743 global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
3844
@@ -50,7 +56,6 @@
5157 return;
5258 }
5359
54 -
5560 # Get an estimate of the number of rows from the BacklinkCache
5661 $numRows = $this->mCache->getNumLinks( $this->mTable );
5762 if ( $numRows > $this->mRowsPerJob * 2 ) {
@@ -138,6 +143,9 @@
139144 Job::batchInsert( $jobs );
140145 }
141146
 147+ /**
 148+ * @return mixed
 149+ */
142150 protected function insertJobs() {
143151 $batches = $this->mCache->partition( $this->mTable, $this->mRowsPerJob );
144152 if ( !$batches ) {
@@ -157,6 +165,7 @@
158166
159167 /**
160168 * Invalidate an array (or iterator) of Title objects, right now
 169+ * @param $titleArray array
161170 */
162171 protected function invalidateTitles( $titleArray ) {
163172 global $wgUseFileCache, $wgUseSquid;

Follow-up revisions

RevisionCommit summaryAuthorDate
r101177Followup r101161 having array() doesn't work so well with isset, changing to ...reedy19:17, 28 October 2011

Status & tagging log