r94001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94000‎ | r94001 | r94002 >
Date:00:24, 6 August 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation!
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -242,7 +242,7 @@
243243
244244 /**
245245 * Boolean, controls output of large amounts of debug information.
246 - * @param $debug:
 246+ * @param $debug bool|null
247247 * - true to enable debugging
248248 * - false to disable debugging
249249 * - omitted or null to do nothing
@@ -290,6 +290,8 @@
291291 * code should use lastErrno() and lastError() to handle the
292292 * situation as appropriate.
293293 *
 294+ * @param $ignoreErrors
 295+ *
294296 * @return The previous value of the flag.
295297 */
296298 function ignoreErrors( $ignoreErrors = null ) {
@@ -331,8 +333,10 @@
332334 * Get properties passed down from the server info array of the load
333335 * balancer.
334336 *
335 - * @param $name The entry of the info array to get, or null to get the
 337+ * @param $name string The entry of the info array to get, or null to get the
336338 * whole array
 339+ *
 340+ * @return LoadBalancer|null
337341 */
338342 function getLBInfo( $name = null ) {
339343 if ( is_null( $name ) ) {
@@ -353,7 +357,6 @@
354358 *
355359 * @param $name
356360 * @param $value
357 - * @return void
358361 */
359362 function setLBInfo( $name, $value = null ) {
360363 if ( is_null( $value ) ) {
@@ -365,6 +368,8 @@
366369
367370 /**
368371 * Set lag time in seconds for a fake slave
 372+ *
 373+ * @param $lag int
369374 */
370375 function setFakeSlaveLag( $lag ) {
371376 $this->mFakeSlaveLag = $lag;
@@ -372,6 +377,8 @@
373378
374379 /**
375380 * Make this connection a fake master
 381+ *
 382+ * @param $enabled bool
376383 */
377384 function setFakeMaster( $enabled = true ) {
378385 $this->mFakeMaster = $enabled;
@@ -379,6 +386,8 @@
380387
381388 /**
382389 * Returns true if this database supports (and uses) cascading deletes
 390+ *
 391+ * @return bool
383392 */
384393 function cascadingDeletes() {
385394 return false;
@@ -386,6 +395,8 @@
387396
388397 /**
389398 * Returns true if this database supports (and uses) triggers (e.g. on the page table)
 399+ *
 400+ * @return bool
390401 */
391402 function cleanupTriggers() {
392403 return false;
@@ -394,6 +405,8 @@
395406 /**
396407 * Returns true if this database is strict about what can be put into an IP field.
397408 * Specifically, it uses a NULL value instead of an empty string.
 409+ *
 410+ * @return bool
398411 */
399412 function strictIPs() {
400413 return false;
@@ -401,6 +414,8 @@
402415
403416 /**
404417 * Returns true if this database uses timestamps rather than integers
 418+ *
 419+ * @return bool
405420 */
406421 function realTimestamps() {
407422 return false;
@@ -408,6 +423,8 @@
409424
410425 /**
411426 * Returns true if this database does an implicit sort when doing GROUP BY
 427+ *
 428+ * @return bool
412429 */
413430 function implicitGroupby() {
414431 return true;
@@ -424,6 +441,8 @@
425442 /**
426443 * Returns true if this database requires that SELECT DISTINCT queries require that all
427444 ORDER BY expressions occur in the SELECT list per the SQL92 standard
 445+ *
 446+ * @return bool
428447 */
429448 function standardSelectDistinct() {
430449 return true;
@@ -432,6 +451,8 @@
433452 /**
434453 * Returns true if this database can do a native search on IP columns
435454 * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32';
 455+ *
 456+ * @return bool
436457 */
437458 function searchableIPs() {
438459 return false;
@@ -439,6 +460,8 @@
440461
441462 /**
442463 * Returns true if this database can use functional indexes
 464+ *
 465+ * @return bool
443466 */
444467 function functionalIndexes() {
445468 return false;
@@ -452,7 +475,6 @@
453476 return $this->mLastQuery;
454477 }
455478
456 -
457479 /**
458480 * Returns true if the connection may have been used for write queries.
459481 * Should return true if unsure.
@@ -636,6 +658,9 @@
637659 set_error_handler( array( $this, 'connectionErrorHandler' ) );
638660 }
639661
 662+ /**
 663+ * @return bool|string
 664+ */
640665 protected function restoreErrorHandler() {
641666 restore_error_handler();
642667 if ( $this->htmlErrors !== false ) {
@@ -690,6 +715,8 @@
691716 * Determine whether a query writes to the DB.
692717 * Should return true if unsure.
693718 *
 719+ * @param $sql string
 720+ *
694721 * @return bool
695722 */
696723 function isWriteQuery( $sql ) {
@@ -861,6 +888,9 @@
862889 * database classes. The query wrapper functions (select() etc.) should be
863890 * used instead.
864891 *
 892+ * @param $sql string
 893+ * @param $func string
 894+ *
865895 * @return array
866896 */
867897 function prepare( $sql, $func = 'DatabaseBase::prepare' ) {
@@ -946,7 +976,6 @@
947977 *
948978 * @param $matches Array
949979 * @return String
950 - * @private
951980 */
952981 function fillPreparedArg( $matches ) {
953982 switch( $matches[1] ) {
@@ -986,6 +1015,12 @@
9871016 * This function exists for historical reasons, DatabaseBase::update() has a more standard
9881017 * calling convention and feature set
9891018 *
 1019+ * @param $table string
 1020+ * @param $var
 1021+ * @param $value
 1022+ * @param $cond
 1023+ * @param $fname string
 1024+ *
9901025 * @return bool
9911026 */
9921027 function set( $table, $var, $value, $cond, $fname = 'DatabaseBase::set' ) {
@@ -1418,7 +1453,9 @@
14191454 * Removes most variables from an SQL query and replaces them with X or N for numbers.
14201455 * It's only slightly flawed. Don't use for anything important.
14211456 *
1422 - * @param $sql String: A SQL Query
 1457+ * @param $sql String A SQL Query
 1458+ *
 1459+ * @return string
14231460 */
14241461 static function generalizeSQL( $sql ) {
14251462 # This does the same as the regexp below would do, but in such a way
@@ -1459,6 +1496,10 @@
14601497 * Usually throws a DBQueryError on failure
14611498 * If errors are explicitly ignored, returns NULL on failure
14621499 *
 1500+ * @param $table
 1501+ * @param $index
 1502+ * @param $fname string
 1503+ *
14631504 * @return bool|null
14641505 */
14651506 function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) {
@@ -1473,7 +1514,7 @@
14741515 /**
14751516 * Query whether a given table exists
14761517 *
1477 - * @string table
 1518+ * @param $table string
14781519 *
14791520 * @return bool
14801521 */
@@ -1662,7 +1703,7 @@
16631704 /**
16641705 * Makes an encoded list of strings from an array
16651706 * @param $a Array containing the data
1666 - * @param $mode:
 1707+ * @param $mode int Constant
16671708 * - LIST_COMMA: comma separated, no field names
16681709 * - LIST_AND: ANDed WHERE clause (without the WHERE). See
16691710 * the documentation for $conds in DatabaseBase::select().
@@ -1812,6 +1853,9 @@
18131854 * Change the current database
18141855 *
18151856 * @todo Explain what exactly will fail if this is not overridden.
 1857+ *
 1858+ * @param $db
 1859+ *
18161860 * @return bool Success or failure
18171861 */
18181862 function selectDB( $db ) {
@@ -1883,7 +1927,7 @@
18841928 }
18851929 $prefix = $this->mTablePrefix; # Default prefix
18861930
1887 - # A database name has been specified in input. We don't want any
 1931+ # A database name has been specified in input. We don't want any
18881932 # prefixes added.
18891933 if ( isset( $database ) ) {
18901934 $prefix = '';
@@ -1925,6 +1969,8 @@
19261970 * extract($dbr->tableNames('user','watchlist'));
19271971 * $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user
19281972 * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
 1973+ *
 1974+ * @return array
19291975 */
19301976 public function tableNames() {
19311977 $inArray = func_get_args();
@@ -1945,6 +1991,8 @@
19461992 * list( $user, $watchlist ) = $dbr->tableNamesN('user','watchlist');
19471993 * $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user
19481994 * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
 1995+ *
 1996+ * @return array
19491997 */
19501998 public function tableNamesN() {
19511999 $inArray = func_get_args();
@@ -1962,7 +2010,7 @@
19632011 * e.g. tableName AS newTableName
19642012 *
19652013 * @param $name string Table name, see tableName()
1966 - * @param $alias string Alias (optional)
 2014+ * @param $alias string|bool Alias (optional)
19672015 * @return string SQL name for aliased table. Will not alias a table to its own name
19682016 */
19692017 public function tableNameWithAlias( $name, $alias = false ) {
@@ -1994,9 +2042,9 @@
19952043 * Get the aliased table name clause for a FROM clause
19962044 * which might have a JOIN and/or USE INDEX clause
19972045 *
1998 - * @param $tables array( [alias] => table )
1999 - * @param $use_index array() Same as for select()
2000 - * @param $join_conds array() Same as for select()
 2046+ * @param $tables array ( [alias] => table )
 2047+ * @param $use_index array Same as for select()
 2048+ * @param $join_conds array Same as for select()
20012049 * @return string
20022050 */
20032051 protected function tableNamesWithUseIndexOrJOIN(
@@ -2099,6 +2147,8 @@
21002148 * Since MySQL is the odd one out here the double quotes are our generic
21012149 * and we implement backticks in DatabaseMysql.
21022150 *
 2151+ * @param $s string
 2152+ *
21032153 * @return string
21042154 */
21052155 public function addIdentifierQuotes( $s ) {
@@ -2123,6 +2173,8 @@
21242174 * was renamed to addIdentifierQuotes.
21252175 * @deprecated since 1.18 use addIdentifierQuotes
21262176 *
 2177+ * @param $s string
 2178+ *
21272179 * @return string
21282180 */
21292181 function quote_ident( $s ) {
@@ -2135,12 +2187,20 @@
21362188 * WARNING: you should almost never use this function directly,
21372189 * instead use buildLike() that escapes everything automatically
21382190 * @deprecated since 1.17, warnings in 1.17, removed in ???
 2191+ *
 2192+ * @param $s string
 2193+ *
 2194+ * @return string
21392195 */
21402196 public function escapeLike( $s ) {
21412197 wfDeprecated( __METHOD__ );
21422198 return $this->escapeLikeInternal( $s );
21432199 }
21442200
 2201+ /**
 2202+ * @param $s string
 2203+ * @return string
 2204+ */
21452205 protected function escapeLikeInternal( $s ) {
21462206 $s = str_replace( '\\', '\\\\', $s );
21472207 $s = $this->strencode( $s );
@@ -2193,7 +2253,7 @@
21942254 /**
21952255 * Returns a token for buildLike() that denotes a '%' to be used in a LIKE query
21962256 *
2197 - * @rerturn LikeMatch
 2257+ * @return LikeMatch
21982258 */
21992259 function anyString() {
22002260 return new LikeMatch( '%' );
@@ -2299,6 +2359,8 @@
23002360 * @param $table Table name
23012361 * @param $rows Rows to insert
23022362 * @param $fname Caller function name
 2363+ *
 2364+ * @return ResultWrapper
23032365 */
23042366 protected function nativeReplace( $table, $rows, $fname ) {
23052367 $table = $this->tableName( $table );
@@ -2365,6 +2427,11 @@
23662428
23672429 /**
23682430 * Returns the size of a text field, or -1 for "unlimited"
 2431+ *
 2432+ * @param $table string
 2433+ * @param $field string
 2434+ *
 2435+ * @return int
23692436 */
23702437 function textFieldSize( $table, $field ) {
23712438 $table = $this->tableName( $table );
@@ -2424,24 +2491,24 @@
24252492 * INSERT SELECT wrapper. Takes data from a SELECT query and inserts it
24262493 * into another table.
24272494 *
2428 - * @param $destTable The table name to insert into
2429 - * @param $srcTable May be either a table name, or an array of table names
 2495+ * @param $destTable string The table name to insert into
 2496+ * @param $srcTable string|array May be either a table name, or an array of table names
24302497 * to include in a join.
24312498 *
2432 - * @param $varMap must be an associative array of the form
 2499+ * @param $varMap array must be an associative array of the form
24332500 * array( 'dest1' => 'source1', ...). Source items may be literals
24342501 * rather than field names, but strings should be quoted with
24352502 * DatabaseBase::addQuotes()
24362503 *
2437 - * @param $conds Condition array. See $conds in DatabaseBase::select() for
 2504+ * @param $conds array Condition array. See $conds in DatabaseBase::select() for
24382505 * the details of the format of condition arrays. May be "*" to copy the
24392506 * whole table.
24402507 *
2441 - * @param $fname The function name of the caller, from __METHOD__
 2508+ * @param $fname string The function name of the caller, from __METHOD__
24422509 *
2443 - * @param $insertOptions Options for the INSERT part of the query, see
 2510+ * @param $insertOptions array Options for the INSERT part of the query, see
24442511 * DatabaseBase::insert() for details.
2445 - * @param $selectOptions Options for the SELECT part of the query, see
 2512+ * @param $selectOptions array Options for the SELECT part of the query, see
24462513 * DatabaseBase::select() for details.
24472514 *
24482515 * @return ResultWrapper
@@ -2495,9 +2562,9 @@
24962563 * The version provided by default works in MySQL and SQLite. It will very
24972564 * likely need to be overridden for most other DBMSes.
24982565 *
2499 - * @param $sql String: SQL query we will append the limit too
2500 - * @param $limit Integer: the SQL limit
2501 - * @param $offset Integer the SQL offset (default false)
 2566+ * @param $sql String SQL query we will append the limit too
 2567+ * @param $limit Integer the SQL limit
 2568+ * @param $offset Integer|false the SQL offset (default false)
25022569 *
25032570 * @return string
25042571 */
@@ -2511,6 +2578,11 @@
25122579 . "{$limit} ";
25132580 }
25142581
 2582+ /**
 2583+ * @param $sql
 2584+ * @param $num
 2585+ * @return string
 2586+ */
25152587 function limitResultForUpdate( $sql, $num ) {
25162588 return $this->limitResult( $sql, $num, 0 );
25172589 }
@@ -2610,6 +2682,8 @@
26112683 * Returns whatever the callback function returned on its successful,
26122684 * iteration, or false on error, for example if the retry limit was
26132685 * reached.
 2686+ *
 2687+ * @return bool
26142688 */
26152689 function deadlockLoop() {
26162690 $myFname = 'DatabaseBase::deadlockLoop';
@@ -2733,6 +2807,8 @@
27342808
27352809 /**
27362810 * End a transaction
 2811+ *
 2812+ * @param $fname string
27372813 */
27382814 function commit( $fname = 'DatabaseBase::commit' ) {
27392815 if ( $this->mTrxLevel ) {
@@ -2744,6 +2820,8 @@
27452821 /**
27462822 * Rollback a transaction.
27472823 * No-op on non-transactional databases.
 2824+ *
 2825+ * @param $fname string
27482826 */
27492827 function rollback( $fname = 'DatabaseBase::rollback' ) {
27502828 if ( $this->mTrxLevel ) {
@@ -2790,6 +2868,8 @@
27912869 * The result is unquoted, and needs to be passed through addQuotes()
27922870 * before it can be included in raw SQL.
27932871 *
 2872+ * @param $ts string|int
 2873+ *
27942874 * @return string
27952875 */
27962876 function timestamp( $ts = 0 ) {
@@ -2805,6 +2885,8 @@
28062886 * The result is unquoted, and needs to be passed through addQuotes()
28072887 * before it can be included in raw SQL.
28082888 *
 2889+ * @param $ts string|int
 2890+ *
28092891 * @return string
28102892 */
28112893 function timestampOrNull( $ts = null ) {
@@ -2825,6 +2907,10 @@
28262908 * a wrapper. Nowadays, raw database objects are never exposed to external
28272909 * callers, so this is unnecessary in external code. For compatibility with
28282910 * old code, ResultWrapper objects are passed through unaltered.
 2911+ *
 2912+ * @param $result bool|ResultWrapper
 2913+ *
 2914+ * @param bool|ResultWrapper
28292915 */
28302916 function resultObject( $result ) {
28312917 if ( empty( $result ) ) {
@@ -2841,6 +2927,11 @@
28422928
28432929 /**
28442930 * Return aggregated value alias
 2931+ *
 2932+ * @param $valuedata
 2933+ * @param $valuename string
 2934+ *
 2935+ * @return string
28452936 */
28462937 function aggregateValue ( $valuedata, $valuename = 'value' ) {
28472938 return $valuename;
@@ -2868,7 +2959,7 @@
28692960 /**
28702961 * Return the maximum number of items allowed in a list, or 0 for unlimited.
28712962 *
2872 - * return int
 2963+ * @return int
28732964 */
28742965 function maxListLen() {
28752966 return 0;

Status & tagging log