Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Boolean, controls output of large amounts of debug information. |
246 | | - * @param $debug: |
| 246 | + * @param $debug bool|null |
247 | 247 | * - true to enable debugging |
248 | 248 | * - false to disable debugging |
249 | 249 | * - omitted or null to do nothing |
— | — | @@ -290,6 +290,8 @@ |
291 | 291 | * code should use lastErrno() and lastError() to handle the |
292 | 292 | * situation as appropriate. |
293 | 293 | * |
| 294 | + * @param $ignoreErrors |
| 295 | + * |
294 | 296 | * @return The previous value of the flag. |
295 | 297 | */ |
296 | 298 | function ignoreErrors( $ignoreErrors = null ) { |
— | — | @@ -331,8 +333,10 @@ |
332 | 334 | * Get properties passed down from the server info array of the load |
333 | 335 | * balancer. |
334 | 336 | * |
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 |
336 | 338 | * whole array |
| 339 | + * |
| 340 | + * @return LoadBalancer|null |
337 | 341 | */ |
338 | 342 | function getLBInfo( $name = null ) { |
339 | 343 | if ( is_null( $name ) ) { |
— | — | @@ -353,7 +357,6 @@ |
354 | 358 | * |
355 | 359 | * @param $name |
356 | 360 | * @param $value |
357 | | - * @return void |
358 | 361 | */ |
359 | 362 | function setLBInfo( $name, $value = null ) { |
360 | 363 | if ( is_null( $value ) ) { |
— | — | @@ -365,6 +368,8 @@ |
366 | 369 | |
367 | 370 | /** |
368 | 371 | * Set lag time in seconds for a fake slave |
| 372 | + * |
| 373 | + * @param $lag int |
369 | 374 | */ |
370 | 375 | function setFakeSlaveLag( $lag ) { |
371 | 376 | $this->mFakeSlaveLag = $lag; |
— | — | @@ -372,6 +377,8 @@ |
373 | 378 | |
374 | 379 | /** |
375 | 380 | * Make this connection a fake master |
| 381 | + * |
| 382 | + * @param $enabled bool |
376 | 383 | */ |
377 | 384 | function setFakeMaster( $enabled = true ) { |
378 | 385 | $this->mFakeMaster = $enabled; |
— | — | @@ -379,6 +386,8 @@ |
380 | 387 | |
381 | 388 | /** |
382 | 389 | * Returns true if this database supports (and uses) cascading deletes |
| 390 | + * |
| 391 | + * @return bool |
383 | 392 | */ |
384 | 393 | function cascadingDeletes() { |
385 | 394 | return false; |
— | — | @@ -386,6 +395,8 @@ |
387 | 396 | |
388 | 397 | /** |
389 | 398 | * Returns true if this database supports (and uses) triggers (e.g. on the page table) |
| 399 | + * |
| 400 | + * @return bool |
390 | 401 | */ |
391 | 402 | function cleanupTriggers() { |
392 | 403 | return false; |
— | — | @@ -394,6 +405,8 @@ |
395 | 406 | /** |
396 | 407 | * Returns true if this database is strict about what can be put into an IP field. |
397 | 408 | * Specifically, it uses a NULL value instead of an empty string. |
| 409 | + * |
| 410 | + * @return bool |
398 | 411 | */ |
399 | 412 | function strictIPs() { |
400 | 413 | return false; |
— | — | @@ -401,6 +414,8 @@ |
402 | 415 | |
403 | 416 | /** |
404 | 417 | * Returns true if this database uses timestamps rather than integers |
| 418 | + * |
| 419 | + * @return bool |
405 | 420 | */ |
406 | 421 | function realTimestamps() { |
407 | 422 | return false; |
— | — | @@ -408,6 +423,8 @@ |
409 | 424 | |
410 | 425 | /** |
411 | 426 | * Returns true if this database does an implicit sort when doing GROUP BY |
| 427 | + * |
| 428 | + * @return bool |
412 | 429 | */ |
413 | 430 | function implicitGroupby() { |
414 | 431 | return true; |
— | — | @@ -424,6 +441,8 @@ |
425 | 442 | /** |
426 | 443 | * Returns true if this database requires that SELECT DISTINCT queries require that all |
427 | 444 | ORDER BY expressions occur in the SELECT list per the SQL92 standard |
| 445 | + * |
| 446 | + * @return bool |
428 | 447 | */ |
429 | 448 | function standardSelectDistinct() { |
430 | 449 | return true; |
— | — | @@ -432,6 +451,8 @@ |
433 | 452 | /** |
434 | 453 | * Returns true if this database can do a native search on IP columns |
435 | 454 | * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32'; |
| 455 | + * |
| 456 | + * @return bool |
436 | 457 | */ |
437 | 458 | function searchableIPs() { |
438 | 459 | return false; |
— | — | @@ -439,6 +460,8 @@ |
440 | 461 | |
441 | 462 | /** |
442 | 463 | * Returns true if this database can use functional indexes |
| 464 | + * |
| 465 | + * @return bool |
443 | 466 | */ |
444 | 467 | function functionalIndexes() { |
445 | 468 | return false; |
— | — | @@ -452,7 +475,6 @@ |
453 | 476 | return $this->mLastQuery; |
454 | 477 | } |
455 | 478 | |
456 | | - |
457 | 479 | /** |
458 | 480 | * Returns true if the connection may have been used for write queries. |
459 | 481 | * Should return true if unsure. |
— | — | @@ -636,6 +658,9 @@ |
637 | 659 | set_error_handler( array( $this, 'connectionErrorHandler' ) ); |
638 | 660 | } |
639 | 661 | |
| 662 | + /** |
| 663 | + * @return bool|string |
| 664 | + */ |
640 | 665 | protected function restoreErrorHandler() { |
641 | 666 | restore_error_handler(); |
642 | 667 | if ( $this->htmlErrors !== false ) { |
— | — | @@ -690,6 +715,8 @@ |
691 | 716 | * Determine whether a query writes to the DB. |
692 | 717 | * Should return true if unsure. |
693 | 718 | * |
| 719 | + * @param $sql string |
| 720 | + * |
694 | 721 | * @return bool |
695 | 722 | */ |
696 | 723 | function isWriteQuery( $sql ) { |
— | — | @@ -861,6 +888,9 @@ |
862 | 889 | * database classes. The query wrapper functions (select() etc.) should be |
863 | 890 | * used instead. |
864 | 891 | * |
| 892 | + * @param $sql string |
| 893 | + * @param $func string |
| 894 | + * |
865 | 895 | * @return array |
866 | 896 | */ |
867 | 897 | function prepare( $sql, $func = 'DatabaseBase::prepare' ) { |
— | — | @@ -946,7 +976,6 @@ |
947 | 977 | * |
948 | 978 | * @param $matches Array |
949 | 979 | * @return String |
950 | | - * @private |
951 | 980 | */ |
952 | 981 | function fillPreparedArg( $matches ) { |
953 | 982 | switch( $matches[1] ) { |
— | — | @@ -986,6 +1015,12 @@ |
987 | 1016 | * This function exists for historical reasons, DatabaseBase::update() has a more standard |
988 | 1017 | * calling convention and feature set |
989 | 1018 | * |
| 1019 | + * @param $table string |
| 1020 | + * @param $var |
| 1021 | + * @param $value |
| 1022 | + * @param $cond |
| 1023 | + * @param $fname string |
| 1024 | + * |
990 | 1025 | * @return bool |
991 | 1026 | */ |
992 | 1027 | function set( $table, $var, $value, $cond, $fname = 'DatabaseBase::set' ) { |
— | — | @@ -1418,7 +1453,9 @@ |
1419 | 1454 | * Removes most variables from an SQL query and replaces them with X or N for numbers. |
1420 | 1455 | * It's only slightly flawed. Don't use for anything important. |
1421 | 1456 | * |
1422 | | - * @param $sql String: A SQL Query |
| 1457 | + * @param $sql String A SQL Query |
| 1458 | + * |
| 1459 | + * @return string |
1423 | 1460 | */ |
1424 | 1461 | static function generalizeSQL( $sql ) { |
1425 | 1462 | # This does the same as the regexp below would do, but in such a way |
— | — | @@ -1459,6 +1496,10 @@ |
1460 | 1497 | * Usually throws a DBQueryError on failure |
1461 | 1498 | * If errors are explicitly ignored, returns NULL on failure |
1462 | 1499 | * |
| 1500 | + * @param $table |
| 1501 | + * @param $index |
| 1502 | + * @param $fname string |
| 1503 | + * |
1463 | 1504 | * @return bool|null |
1464 | 1505 | */ |
1465 | 1506 | function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) { |
— | — | @@ -1473,7 +1514,7 @@ |
1474 | 1515 | /** |
1475 | 1516 | * Query whether a given table exists |
1476 | 1517 | * |
1477 | | - * @string table |
| 1518 | + * @param $table string |
1478 | 1519 | * |
1479 | 1520 | * @return bool |
1480 | 1521 | */ |
— | — | @@ -1662,7 +1703,7 @@ |
1663 | 1704 | /** |
1664 | 1705 | * Makes an encoded list of strings from an array |
1665 | 1706 | * @param $a Array containing the data |
1666 | | - * @param $mode: |
| 1707 | + * @param $mode int Constant |
1667 | 1708 | * - LIST_COMMA: comma separated, no field names |
1668 | 1709 | * - LIST_AND: ANDed WHERE clause (without the WHERE). See |
1669 | 1710 | * the documentation for $conds in DatabaseBase::select(). |
— | — | @@ -1812,6 +1853,9 @@ |
1813 | 1854 | * Change the current database |
1814 | 1855 | * |
1815 | 1856 | * @todo Explain what exactly will fail if this is not overridden. |
| 1857 | + * |
| 1858 | + * @param $db |
| 1859 | + * |
1816 | 1860 | * @return bool Success or failure |
1817 | 1861 | */ |
1818 | 1862 | function selectDB( $db ) { |
— | — | @@ -1883,7 +1927,7 @@ |
1884 | 1928 | } |
1885 | 1929 | $prefix = $this->mTablePrefix; # Default prefix |
1886 | 1930 | |
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 |
1888 | 1932 | # prefixes added. |
1889 | 1933 | if ( isset( $database ) ) { |
1890 | 1934 | $prefix = ''; |
— | — | @@ -1925,6 +1969,8 @@ |
1926 | 1970 | * extract($dbr->tableNames('user','watchlist')); |
1927 | 1971 | * $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user |
1928 | 1972 | * WHERE wl_user=user_id AND wl_user=$nameWithQuotes"; |
| 1973 | + * |
| 1974 | + * @return array |
1929 | 1975 | */ |
1930 | 1976 | public function tableNames() { |
1931 | 1977 | $inArray = func_get_args(); |
— | — | @@ -1945,6 +1991,8 @@ |
1946 | 1992 | * list( $user, $watchlist ) = $dbr->tableNamesN('user','watchlist'); |
1947 | 1993 | * $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user |
1948 | 1994 | * WHERE wl_user=user_id AND wl_user=$nameWithQuotes"; |
| 1995 | + * |
| 1996 | + * @return array |
1949 | 1997 | */ |
1950 | 1998 | public function tableNamesN() { |
1951 | 1999 | $inArray = func_get_args(); |
— | — | @@ -1962,7 +2010,7 @@ |
1963 | 2011 | * e.g. tableName AS newTableName |
1964 | 2012 | * |
1965 | 2013 | * @param $name string Table name, see tableName() |
1966 | | - * @param $alias string Alias (optional) |
| 2014 | + * @param $alias string|bool Alias (optional) |
1967 | 2015 | * @return string SQL name for aliased table. Will not alias a table to its own name |
1968 | 2016 | */ |
1969 | 2017 | public function tableNameWithAlias( $name, $alias = false ) { |
— | — | @@ -1994,9 +2042,9 @@ |
1995 | 2043 | * Get the aliased table name clause for a FROM clause |
1996 | 2044 | * which might have a JOIN and/or USE INDEX clause |
1997 | 2045 | * |
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() |
2001 | 2049 | * @return string |
2002 | 2050 | */ |
2003 | 2051 | protected function tableNamesWithUseIndexOrJOIN( |
— | — | @@ -2099,6 +2147,8 @@ |
2100 | 2148 | * Since MySQL is the odd one out here the double quotes are our generic |
2101 | 2149 | * and we implement backticks in DatabaseMysql. |
2102 | 2150 | * |
| 2151 | + * @param $s string |
| 2152 | + * |
2103 | 2153 | * @return string |
2104 | 2154 | */ |
2105 | 2155 | public function addIdentifierQuotes( $s ) { |
— | — | @@ -2123,6 +2173,8 @@ |
2124 | 2174 | * was renamed to addIdentifierQuotes. |
2125 | 2175 | * @deprecated since 1.18 use addIdentifierQuotes |
2126 | 2176 | * |
| 2177 | + * @param $s string |
| 2178 | + * |
2127 | 2179 | * @return string |
2128 | 2180 | */ |
2129 | 2181 | function quote_ident( $s ) { |
— | — | @@ -2135,12 +2187,20 @@ |
2136 | 2188 | * WARNING: you should almost never use this function directly, |
2137 | 2189 | * instead use buildLike() that escapes everything automatically |
2138 | 2190 | * @deprecated since 1.17, warnings in 1.17, removed in ??? |
| 2191 | + * |
| 2192 | + * @param $s string |
| 2193 | + * |
| 2194 | + * @return string |
2139 | 2195 | */ |
2140 | 2196 | public function escapeLike( $s ) { |
2141 | 2197 | wfDeprecated( __METHOD__ ); |
2142 | 2198 | return $this->escapeLikeInternal( $s ); |
2143 | 2199 | } |
2144 | 2200 | |
| 2201 | + /** |
| 2202 | + * @param $s string |
| 2203 | + * @return string |
| 2204 | + */ |
2145 | 2205 | protected function escapeLikeInternal( $s ) { |
2146 | 2206 | $s = str_replace( '\\', '\\\\', $s ); |
2147 | 2207 | $s = $this->strencode( $s ); |
— | — | @@ -2193,7 +2253,7 @@ |
2194 | 2254 | /** |
2195 | 2255 | * Returns a token for buildLike() that denotes a '%' to be used in a LIKE query |
2196 | 2256 | * |
2197 | | - * @rerturn LikeMatch |
| 2257 | + * @return LikeMatch |
2198 | 2258 | */ |
2199 | 2259 | function anyString() { |
2200 | 2260 | return new LikeMatch( '%' ); |
— | — | @@ -2299,6 +2359,8 @@ |
2300 | 2360 | * @param $table Table name |
2301 | 2361 | * @param $rows Rows to insert |
2302 | 2362 | * @param $fname Caller function name |
| 2363 | + * |
| 2364 | + * @return ResultWrapper |
2303 | 2365 | */ |
2304 | 2366 | protected function nativeReplace( $table, $rows, $fname ) { |
2305 | 2367 | $table = $this->tableName( $table ); |
— | — | @@ -2365,6 +2427,11 @@ |
2366 | 2428 | |
2367 | 2429 | /** |
2368 | 2430 | * Returns the size of a text field, or -1 for "unlimited" |
| 2431 | + * |
| 2432 | + * @param $table string |
| 2433 | + * @param $field string |
| 2434 | + * |
| 2435 | + * @return int |
2369 | 2436 | */ |
2370 | 2437 | function textFieldSize( $table, $field ) { |
2371 | 2438 | $table = $this->tableName( $table ); |
— | — | @@ -2424,24 +2491,24 @@ |
2425 | 2492 | * INSERT SELECT wrapper. Takes data from a SELECT query and inserts it |
2426 | 2493 | * into another table. |
2427 | 2494 | * |
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 |
2430 | 2497 | * to include in a join. |
2431 | 2498 | * |
2432 | | - * @param $varMap must be an associative array of the form |
| 2499 | + * @param $varMap array must be an associative array of the form |
2433 | 2500 | * array( 'dest1' => 'source1', ...). Source items may be literals |
2434 | 2501 | * rather than field names, but strings should be quoted with |
2435 | 2502 | * DatabaseBase::addQuotes() |
2436 | 2503 | * |
2437 | | - * @param $conds Condition array. See $conds in DatabaseBase::select() for |
| 2504 | + * @param $conds array Condition array. See $conds in DatabaseBase::select() for |
2438 | 2505 | * the details of the format of condition arrays. May be "*" to copy the |
2439 | 2506 | * whole table. |
2440 | 2507 | * |
2441 | | - * @param $fname The function name of the caller, from __METHOD__ |
| 2508 | + * @param $fname string The function name of the caller, from __METHOD__ |
2442 | 2509 | * |
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 |
2444 | 2511 | * 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 |
2446 | 2513 | * DatabaseBase::select() for details. |
2447 | 2514 | * |
2448 | 2515 | * @return ResultWrapper |
— | — | @@ -2495,9 +2562,9 @@ |
2496 | 2563 | * The version provided by default works in MySQL and SQLite. It will very |
2497 | 2564 | * likely need to be overridden for most other DBMSes. |
2498 | 2565 | * |
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) |
2502 | 2569 | * |
2503 | 2570 | * @return string |
2504 | 2571 | */ |
— | — | @@ -2511,6 +2578,11 @@ |
2512 | 2579 | . "{$limit} "; |
2513 | 2580 | } |
2514 | 2581 | |
| 2582 | + /** |
| 2583 | + * @param $sql |
| 2584 | + * @param $num |
| 2585 | + * @return string |
| 2586 | + */ |
2515 | 2587 | function limitResultForUpdate( $sql, $num ) { |
2516 | 2588 | return $this->limitResult( $sql, $num, 0 ); |
2517 | 2589 | } |
— | — | @@ -2610,6 +2682,8 @@ |
2611 | 2683 | * Returns whatever the callback function returned on its successful, |
2612 | 2684 | * iteration, or false on error, for example if the retry limit was |
2613 | 2685 | * reached. |
| 2686 | + * |
| 2687 | + * @return bool |
2614 | 2688 | */ |
2615 | 2689 | function deadlockLoop() { |
2616 | 2690 | $myFname = 'DatabaseBase::deadlockLoop'; |
— | — | @@ -2733,6 +2807,8 @@ |
2734 | 2808 | |
2735 | 2809 | /** |
2736 | 2810 | * End a transaction |
| 2811 | + * |
| 2812 | + * @param $fname string |
2737 | 2813 | */ |
2738 | 2814 | function commit( $fname = 'DatabaseBase::commit' ) { |
2739 | 2815 | if ( $this->mTrxLevel ) { |
— | — | @@ -2744,6 +2820,8 @@ |
2745 | 2821 | /** |
2746 | 2822 | * Rollback a transaction. |
2747 | 2823 | * No-op on non-transactional databases. |
| 2824 | + * |
| 2825 | + * @param $fname string |
2748 | 2826 | */ |
2749 | 2827 | function rollback( $fname = 'DatabaseBase::rollback' ) { |
2750 | 2828 | if ( $this->mTrxLevel ) { |
— | — | @@ -2790,6 +2868,8 @@ |
2791 | 2869 | * The result is unquoted, and needs to be passed through addQuotes() |
2792 | 2870 | * before it can be included in raw SQL. |
2793 | 2871 | * |
| 2872 | + * @param $ts string|int |
| 2873 | + * |
2794 | 2874 | * @return string |
2795 | 2875 | */ |
2796 | 2876 | function timestamp( $ts = 0 ) { |
— | — | @@ -2805,6 +2885,8 @@ |
2806 | 2886 | * The result is unquoted, and needs to be passed through addQuotes() |
2807 | 2887 | * before it can be included in raw SQL. |
2808 | 2888 | * |
| 2889 | + * @param $ts string|int |
| 2890 | + * |
2809 | 2891 | * @return string |
2810 | 2892 | */ |
2811 | 2893 | function timestampOrNull( $ts = null ) { |
— | — | @@ -2825,6 +2907,10 @@ |
2826 | 2908 | * a wrapper. Nowadays, raw database objects are never exposed to external |
2827 | 2909 | * callers, so this is unnecessary in external code. For compatibility with |
2828 | 2910 | * old code, ResultWrapper objects are passed through unaltered. |
| 2911 | + * |
| 2912 | + * @param $result bool|ResultWrapper |
| 2913 | + * |
| 2914 | + * @param bool|ResultWrapper |
2829 | 2915 | */ |
2830 | 2916 | function resultObject( $result ) { |
2831 | 2917 | if ( empty( $result ) ) { |
— | — | @@ -2841,6 +2927,11 @@ |
2842 | 2928 | |
2843 | 2929 | /** |
2844 | 2930 | * Return aggregated value alias |
| 2931 | + * |
| 2932 | + * @param $valuedata |
| 2933 | + * @param $valuename string |
| 2934 | + * |
| 2935 | + * @return string |
2845 | 2936 | */ |
2846 | 2937 | function aggregateValue ( $valuedata, $valuename = 'value' ) { |
2847 | 2938 | return $valuename; |
— | — | @@ -2868,7 +2959,7 @@ |
2869 | 2960 | /** |
2870 | 2961 | * Return the maximum number of items allowed in a list, or 0 for unlimited. |
2871 | 2962 | * |
2872 | | - * return int |
| 2963 | + * @return int |
2873 | 2964 | */ |
2874 | 2965 | function maxListLen() { |
2875 | 2966 | return 0; |