Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -241,7 +241,7 @@ |
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | | - * Boolean, controls output of large amounts of debug information. |
| 245 | + * Boolean, controls output of large amounts of debug information. |
246 | 246 | * @param $debug: |
247 | 247 | * - true to enable debugging |
248 | 248 | * - false to disable debugging |
— | — | @@ -254,23 +254,25 @@ |
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | | - * Turns buffering of SQL result sets on (true) or off (false). Default is |
259 | | - * "on". |
| 258 | + * Turns buffering of SQL result sets on (true) or off (false). Default is |
| 259 | + * "on". |
260 | 260 | * |
261 | 261 | * Unbuffered queries are very troublesome in MySQL: |
262 | 262 | * |
263 | | - * - If another query is executed while the first query is being read |
| 263 | + * - If another query is executed while the first query is being read |
264 | 264 | * out, the first query is killed. This means you can't call normal |
265 | 265 | * MediaWiki functions while you are reading an unbuffered query result |
266 | 266 | * from a normal wfGetDB() connection. |
267 | 267 | * |
268 | | - * - Unbuffered queries cause the MySQL server to use large amounts of |
| 268 | + * - Unbuffered queries cause the MySQL server to use large amounts of |
269 | 269 | * memory and to hold broad locks which block other queries. |
270 | 270 | * |
271 | | - * If you want to limit client-side memory, it's almost always better to |
| 271 | + * If you want to limit client-side memory, it's almost always better to |
272 | 272 | * split up queries into batches using a LIMIT clause than to switch off |
273 | 273 | * buffering. |
274 | 274 | * |
| 275 | + * @param $buffer null|bool |
| 276 | + * |
275 | 277 | * @return The previous value of the flag |
276 | 278 | */ |
277 | 279 | function bufferResults( $buffer = null ) { |
— | — | @@ -297,7 +299,7 @@ |
298 | 300 | /** |
299 | 301 | * Gets or sets the current transaction level. |
300 | 302 | * |
301 | | - * Historically, transactions were allowed to be "nested". This is no |
| 303 | + * Historically, transactions were allowed to be "nested". This is no |
302 | 304 | * longer supported, so this function really only returns a boolean. |
303 | 305 | * |
304 | 306 | * @param $level An integer (0 or 1), or omitted to leave it unchanged. |
— | — | @@ -326,10 +328,10 @@ |
327 | 329 | } |
328 | 330 | |
329 | 331 | /** |
330 | | - * Get properties passed down from the server info array of the load |
| 332 | + * Get properties passed down from the server info array of the load |
331 | 333 | * balancer. |
332 | 334 | * |
333 | | - * @param $name The entry of the info array to get, or null to get the |
| 335 | + * @param $name The entry of the info array to get, or null to get the |
334 | 336 | * whole array |
335 | 337 | */ |
336 | 338 | function getLBInfo( $name = null ) { |
— | — | @@ -345,8 +347,8 @@ |
346 | 348 | } |
347 | 349 | |
348 | 350 | /** |
349 | | - * Set the LB info array, or a member of it. If called with one parameter, |
350 | | - * the LB info array is set to that parameter. If it is called with two |
| 351 | + * Set the LB info array, or a member of it. If called with one parameter, |
| 352 | + * the LB info array is set to that parameter. If it is called with two |
351 | 353 | * parameters, the member with the given name is set to the given value. |
352 | 354 | * |
353 | 355 | * @param $name |
— | — | @@ -695,14 +697,14 @@ |
696 | 698 | } |
697 | 699 | |
698 | 700 | /** |
699 | | - * Run an SQL query and return the result. Normally throws a DBQueryError |
| 701 | + * Run an SQL query and return the result. Normally throws a DBQueryError |
700 | 702 | * on failure. If errors are ignored, returns false instead. |
701 | 703 | * |
702 | | - * In new code, the query wrappers select(), insert(), update(), delete(), |
703 | | - * etc. should be used where possible, since they give much better DBMS |
| 704 | + * In new code, the query wrappers select(), insert(), update(), delete(), |
| 705 | + * etc. should be used where possible, since they give much better DBMS |
704 | 706 | * independence and automatically quote or validate user input in a variety |
705 | 707 | * of contexts. This function is generally only useful for queries which are |
706 | | - * explicitly DBMS-dependent and are unsupported by the query wrappers, such |
| 708 | + * explicitly DBMS-dependent and are unsupported by the query wrappers, such |
707 | 709 | * as CREATE TABLE. |
708 | 710 | * |
709 | 711 | * However, the query wrappers themselves should call this function. |
— | — | @@ -712,7 +714,7 @@ |
713 | 715 | * comment (you can use __METHOD__ or add some extra info) |
714 | 716 | * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors... |
715 | 717 | * maybe best to catch the exception instead? |
716 | | - * @return boolean|ResultWrapper. true for a successful write query, ResultWrapper object |
| 718 | + * @return boolean|ResultWrapper. true for a successful write query, ResultWrapper object |
717 | 719 | * for a successful read query, or false on failure if $tempIgnore set |
718 | 720 | * @throws DBQueryError Thrown when the database returns an error of any kind |
719 | 721 | */ |
— | — | @@ -821,7 +823,7 @@ |
822 | 824 | } |
823 | 825 | |
824 | 826 | /** |
825 | | - * Report a query error. Log the error, and if neither the object ignore |
| 827 | + * Report a query error. Log the error, and if neither the object ignore |
826 | 828 | * flag nor the $tempIgnore flag is set, throw a DBQueryError. |
827 | 829 | * |
828 | 830 | * @param $error String |
— | — | @@ -855,7 +857,7 @@ |
856 | 858 | * & = filename; reads the file and inserts as a blob |
857 | 859 | * (we don't use this though...) |
858 | 860 | * |
859 | | - * This function should not be used directly by new code outside of the |
| 861 | + * This function should not be used directly by new code outside of the |
860 | 862 | * database classes. The query wrapper functions (select() etc.) should be |
861 | 863 | * used instead. |
862 | 864 | * |
— | — | @@ -898,7 +900,7 @@ |
899 | 901 | * Prepare & execute an SQL statement, quoting and inserting arguments |
900 | 902 | * in the appropriate places. |
901 | 903 | * |
902 | | - * This function should not be used directly by new code outside of the |
| 904 | + * This function should not be used directly by new code outside of the |
903 | 905 | * database classes. The query wrapper functions (select() etc.) should be |
904 | 906 | * used instead. |
905 | 907 | * |
— | — | @@ -967,8 +969,8 @@ |
968 | 970 | } |
969 | 971 | |
970 | 972 | /** |
971 | | - * Free a result object returned by query() or select(). It's usually not |
972 | | - * necessary to call this, just use unset() or let the variable holding |
| 973 | + * Free a result object returned by query() or select(). It's usually not |
| 974 | + * necessary to call this, just use unset() or let the variable holding |
973 | 975 | * the result object go out of scope. |
974 | 976 | * |
975 | 977 | * @param $res Mixed: A SQL result |
— | — | @@ -997,22 +999,22 @@ |
998 | 1000 | /** |
999 | 1001 | * A SELECT wrapper which returns a single field from a single result row. |
1000 | 1002 | * |
1001 | | - * Usually throws a DBQueryError on failure. If errors are explicitly |
| 1003 | + * Usually throws a DBQueryError on failure. If errors are explicitly |
1002 | 1004 | * ignored, returns false on failure. |
1003 | 1005 | * |
1004 | 1006 | * If no result rows are returned from the query, false is returned. |
1005 | 1007 | * |
1006 | | - * @param $table Table name. See DatabaseBase::select() for details. |
1007 | | - * @param $var The field name to select. This must be a valid SQL |
| 1008 | + * @param $table string|array Table name. See DatabaseBase::select() for details. |
| 1009 | + * @param $var string The field name to select. This must be a valid SQL |
1008 | 1010 | * fragment: do not use unvalidated user input. |
1009 | | - * @param $cond The condition array. See DatabaseBase::select() for details. |
1010 | | - * @param $fname The function name of the caller. |
1011 | | - * @param $options The query options. See DatabaseBase::select() for details. |
| 1011 | + * @param $cond string|array The condition array. See DatabaseBase::select() for details. |
| 1012 | + * @param $fname string The function name of the caller. |
| 1013 | + * @param $options string|array The query options. See DatabaseBase::select() for details. |
1012 | 1014 | * |
1013 | 1015 | * @return The value from the field, or false on failure. |
1014 | 1016 | */ |
1015 | | - function selectField( $table, $var, $cond = '', $fname = 'DatabaseBase::selectField', |
1016 | | - $options = array() ) |
| 1017 | + function selectField( $table, $var, $cond = '', $fname = 'DatabaseBase::selectField', |
| 1018 | + $options = array() ) |
1017 | 1019 | { |
1018 | 1020 | if ( !is_array( $options ) ) { |
1019 | 1021 | $options = array( $options ); |
— | — | @@ -1037,7 +1039,7 @@ |
1038 | 1040 | |
1039 | 1041 | /** |
1040 | 1042 | * Returns an optional USE INDEX clause to go after the table, and a |
1041 | | - * string to go at the end of the query. |
| 1043 | + * string to go at the end of the query. |
1042 | 1044 | * |
1043 | 1045 | * @param $options Array: associative array of options to be turned into |
1044 | 1046 | * an SQL query, valid keys are listed in the function. |
— | — | @@ -1146,102 +1148,102 @@ |
1147 | 1149 | * @param $join_conds Array Join conditions |
1148 | 1150 | * |
1149 | 1151 | * |
1150 | | - * @b $table |
| 1152 | + * @param $table string|array |
1151 | 1153 | * |
1152 | | - * May be either an array of table names, or a single string holding a table |
1153 | | - * name. If an array is given, table aliases can be specified, for example: |
| 1154 | + * May be either an array of table names, or a single string holding a table |
| 1155 | + * name. If an array is given, table aliases can be specified, for example: |
1154 | 1156 | * |
1155 | 1157 | * array( 'a' => 'user' ) |
1156 | 1158 | * |
1157 | | - * This includes the user table in the query, with the alias "a" available |
| 1159 | + * This includes the user table in the query, with the alias "a" available |
1158 | 1160 | * for use in field names (e.g. a.user_name). |
1159 | 1161 | * |
1160 | | - * All of the table names given here are automatically run through |
1161 | | - * DatabaseBase::tableName(), which causes the table prefix (if any) to be |
| 1162 | + * All of the table names given here are automatically run through |
| 1163 | + * DatabaseBase::tableName(), which causes the table prefix (if any) to be |
1162 | 1164 | * added, and various other table name mappings to be performed. |
1163 | 1165 | * |
1164 | 1166 | * |
1165 | | - * @b $vars |
| 1167 | + * @param $vars string|array |
1166 | 1168 | * |
1167 | | - * May be either a field name or an array of field names. The field names |
1168 | | - * here are complete fragments of SQL, for direct inclusion into the SELECT |
| 1169 | + * May be either a field name or an array of field names. The field names |
| 1170 | + * here are complete fragments of SQL, for direct inclusion into the SELECT |
1169 | 1171 | * query. Expressions and aliases may be specified as in SQL, for example: |
1170 | 1172 | * |
1171 | 1173 | * array( 'MAX(rev_id) AS maxrev' ) |
1172 | | - * |
1173 | | - * If an expression is given, care must be taken to ensure that it is |
| 1174 | + * |
| 1175 | + * If an expression is given, care must be taken to ensure that it is |
1174 | 1176 | * DBMS-independent. |
1175 | 1177 | * |
1176 | 1178 | * |
1177 | | - * @b $conds |
| 1179 | + * @param $conds string|array |
1178 | 1180 | * |
1179 | | - * May be either a string containing a single condition, or an array of |
1180 | | - * conditions. If an array is given, the conditions constructed from each |
1181 | | - * element are combined with AND. |
| 1181 | + * May be either a string containing a single condition, or an array of |
| 1182 | + * conditions. If an array is given, the conditions constructed from each |
| 1183 | + * element are combined with AND. |
1182 | 1184 | * |
1183 | 1185 | * Array elements may take one of two forms: |
1184 | 1186 | * |
1185 | 1187 | * - Elements with a numeric key are interpreted as raw SQL fragments. |
1186 | | - * - Elements with a string key are interpreted as equality conditions, |
| 1188 | + * - Elements with a string key are interpreted as equality conditions, |
1187 | 1189 | * where the key is the field name. |
1188 | | - * - If the value of such an array element is a scalar (such as a |
1189 | | - * string), it will be treated as data and thus quoted appropriately. |
| 1190 | + * - If the value of such an array element is a scalar (such as a |
| 1191 | + * string), it will be treated as data and thus quoted appropriately. |
1190 | 1192 | * If it is null, an IS NULL clause will be added. |
1191 | | - * - If the value is an array, an IN(...) clause will be constructed, |
1192 | | - * such that the field name may match any of the elements in the |
| 1193 | + * - If the value is an array, an IN(...) clause will be constructed, |
| 1194 | + * such that the field name may match any of the elements in the |
1193 | 1195 | * array. The elements of the array will be quoted. |
1194 | | - * - If the field name ends with "!", this is taken as a flag which |
1195 | | - * inverts the comparison, allowing NOT IN clauses to be constructed, |
| 1196 | + * - If the field name ends with "!", this is taken as a flag which |
| 1197 | + * inverts the comparison, allowing NOT IN clauses to be constructed, |
1196 | 1198 | * for example: array( 'user_id!' => array( 1, 2, 3 ) ) |
1197 | 1199 | * |
1198 | | - * Note that expressions are often DBMS-dependent in their syntax. |
1199 | | - * DBMS-independent wrappers are provided for constructing several types of |
| 1200 | + * Note that expressions are often DBMS-dependent in their syntax. |
| 1201 | + * DBMS-independent wrappers are provided for constructing several types of |
1200 | 1202 | * expression commonly used in condition queries. See: |
1201 | 1203 | * - DatabaseBase::buildLike() |
1202 | 1204 | * - DatabaseBase::conditional() |
1203 | 1205 | * |
1204 | 1206 | * |
1205 | | - * @b $options |
| 1207 | + * @param $options string|array |
1206 | 1208 | * |
1207 | | - * Optional: Array of query options. Boolean options are specified by |
1208 | | - * including them in the array as a string value with a numeric key, for |
| 1209 | + * Optional: Array of query options. Boolean options are specified by |
| 1210 | + * including them in the array as a string value with a numeric key, for |
1209 | 1211 | * example: |
1210 | 1212 | * |
1211 | 1213 | * array( 'FOR UPDATE' ) |
1212 | 1214 | * |
1213 | 1215 | * The supported options are: |
1214 | 1216 | * |
1215 | | - * - OFFSET: Skip this many rows at the start of the result set. OFFSET |
| 1217 | + * - OFFSET: Skip this many rows at the start of the result set. OFFSET |
1216 | 1218 | * with LIMIT can theoretically be used for paging through a result set, |
1217 | | - * but this is discouraged in MediaWiki for performance reasons. |
| 1219 | + * but this is discouraged in MediaWiki for performance reasons. |
1218 | 1220 | * |
1219 | | - * - LIMIT: Integer: return at most this many rows. The rows are sorted |
| 1221 | + * - LIMIT: Integer: return at most this many rows. The rows are sorted |
1220 | 1222 | * and then the first rows are taken until the limit is reached. LIMIT |
1221 | 1223 | * is applied to a result set after OFFSET. |
1222 | 1224 | * |
1223 | | - * - FOR UPDATE: Boolean: lock the returned rows so that they can't be |
| 1225 | + * - FOR UPDATE: Boolean: lock the returned rows so that they can't be |
1224 | 1226 | * changed until the next COMMIT. |
1225 | 1227 | * |
1226 | 1228 | * - DISTINCT: Boolean: return only unique result rows. |
1227 | 1229 | * |
1228 | | - * - GROUP BY: May be either an SQL fragment string naming a field or |
| 1230 | + * - GROUP BY: May be either an SQL fragment string naming a field or |
1229 | 1231 | * expression to group by, or an array of such SQL fragments. |
1230 | 1232 | * |
1231 | | - * - HAVING: A string containing a HAVING clause. |
| 1233 | + * - HAVING: A string containing a HAVING clause. |
1232 | 1234 | * |
1233 | | - * - ORDER BY: May be either an SQL fragment giving a field name or |
| 1235 | + * - ORDER BY: May be either an SQL fragment giving a field name or |
1234 | 1236 | * expression to order by, or an array of such SQL fragments. |
1235 | 1237 | * |
1236 | | - * - USE INDEX: This may be either a string giving the index name to use |
1237 | | - * for the query, or an array. If it is an associative array, each key |
| 1238 | + * - USE INDEX: This may be either a string giving the index name to use |
| 1239 | + * for the query, or an array. If it is an associative array, each key |
1238 | 1240 | * gives the table name (or alias), each value gives the index name to |
1239 | | - * use for that table. All strings are SQL fragments and so should be |
| 1241 | + * use for that table. All strings are SQL fragments and so should be |
1240 | 1242 | * validated by the caller. |
1241 | 1243 | * |
1242 | | - * - EXPLAIN: In MySQL, this causes an EXPLAIN SELECT query to be run, |
| 1244 | + * - EXPLAIN: In MySQL, this causes an EXPLAIN SELECT query to be run, |
1243 | 1245 | * instead of SELECT. |
1244 | 1246 | * |
1245 | | - * And also the following boolean MySQL extensions, see the MySQL manual |
| 1247 | + * And also the following boolean MySQL extensions, see the MySQL manual |
1246 | 1248 | * for documentation: |
1247 | 1249 | * |
1248 | 1250 | * - LOCK IN SHARE MODE |
— | — | @@ -1255,27 +1257,26 @@ |
1256 | 1258 | * - SQL_NO_CACHE |
1257 | 1259 | * |
1258 | 1260 | * |
1259 | | - * @b $join_conds |
| 1261 | + * @param $join_conds string|array |
1260 | 1262 | * |
1261 | | - * Optional associative array of table-specific join conditions. In the |
1262 | | - * most common case, this is unnecessary, since the join condition can be |
| 1263 | + * Optional associative array of table-specific join conditions. In the |
| 1264 | + * most common case, this is unnecessary, since the join condition can be |
1263 | 1265 | * in $conds. However, it is useful for doing a LEFT JOIN. |
1264 | 1266 | * |
1265 | | - * The key of the array contains the table name or alias. The value is an |
1266 | | - * array with two elements, numbered 0 and 1. The first gives the type of |
1267 | | - * join, the second is an SQL fragment giving the join condition for that |
| 1267 | + * The key of the array contains the table name or alias. The value is an |
| 1268 | + * array with two elements, numbered 0 and 1. The first gives the type of |
| 1269 | + * join, the second is an SQL fragment giving the join condition for that |
1268 | 1270 | * table. For example: |
1269 | 1271 | * |
1270 | 1272 | * array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) |
1271 | 1273 | * |
1272 | 1274 | * @return ResultWrapper. If the query returned no rows, a ResultWrapper |
1273 | | - * with no rows in it will be returned. If there was a query error, a |
| 1275 | + * with no rows in it will be returned. If there was a query error, a |
1274 | 1276 | * DBQueryError exception will be thrown, except if the "ignore errors" |
1275 | 1277 | * option was set, in which case false will be returned. |
1276 | 1278 | */ |
1277 | | - function select( $table, $vars, $conds = '', $fname = 'DatabaseBase::select', |
1278 | | - $options = array(), $join_conds = array() ) |
1279 | | - { |
| 1279 | + function select( $table, $vars, $conds = '', $fname = 'DatabaseBase::select', |
| 1280 | + $options = array(), $join_conds = array() ) { |
1280 | 1281 | $sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds ); |
1281 | 1282 | |
1282 | 1283 | return $this->query( $sql, $fname ); |
— | — | @@ -1285,12 +1286,12 @@ |
1286 | 1287 | * The equivalent of DatabaseBase::select() except that the constructed SQL |
1287 | 1288 | * is returned, instead of being immediately executed. |
1288 | 1289 | * |
1289 | | - * @param $table Table name |
1290 | | - * @param $vars Field names |
1291 | | - * @param $conds Conditions |
1292 | | - * @param $fname Caller function name |
1293 | | - * @param $options Query options |
1294 | | - * @param $join_conds Join conditions |
| 1290 | + * @param $table string|array Table name |
| 1291 | + * @param $vars string|array Field names |
| 1292 | + * @param $conds string|array Conditions |
| 1293 | + * @param $fname string Caller function name |
| 1294 | + * @param $options string|array Query options |
| 1295 | + * @param $join_conds string|array Join conditions |
1295 | 1296 | * |
1296 | 1297 | * @return SQL query string. |
1297 | 1298 | * @see DatabaseBase::select() |
— | — | @@ -1348,20 +1349,20 @@ |
1349 | 1350 | |
1350 | 1351 | /** |
1351 | 1352 | * Single row SELECT wrapper. Equivalent to DatabaseBase::select(), except |
1352 | | - * that a single row object is returned. If the query returns no rows, |
| 1353 | + * that a single row object is returned. If the query returns no rows, |
1353 | 1354 | * false is returned. |
1354 | 1355 | * |
1355 | | - * @param $table Table name |
1356 | | - * @param $vars Field names |
1357 | | - * @param $conds Conditions |
1358 | | - * @param $fname Caller function name |
1359 | | - * @param $options Query options |
1360 | | - * @param $join_conds Join conditions |
| 1356 | + * @param $table string|array Table name |
| 1357 | + * @param $vars string|array Field names |
| 1358 | + * @param $conds|array Conditions |
| 1359 | + * @param $fname string Caller function name |
| 1360 | + * @param $options string|array Query options |
| 1361 | + * @param $join_conds array|string Join conditions |
1361 | 1362 | * |
1362 | | - * @return ResultWrapper or bool |
| 1363 | + * @return ResultWrapper|bool |
1363 | 1364 | */ |
1364 | | - function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow', |
1365 | | - $options = array(), $join_conds = array() ) |
| 1365 | + function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow', |
| 1366 | + $options = array(), $join_conds = array() ) |
1366 | 1367 | { |
1367 | 1368 | $options['LIMIT'] = 1; |
1368 | 1369 | $res = $this->select( $table, $vars, $conds, $fname, $options, $join_conds ); |
— | — | @@ -1382,13 +1383,13 @@ |
1383 | 1384 | /** |
1384 | 1385 | * Estimate rows in dataset. |
1385 | 1386 | * |
1386 | | - * MySQL allows you to estimate the number of rows that would be returned |
| 1387 | + * MySQL allows you to estimate the number of rows that would be returned |
1387 | 1388 | * by a SELECT query, using EXPLAIN SELECT. The estimate is provided using |
1388 | 1389 | * index cardinality statistics, and is notoriously inaccurate, especially |
1389 | 1390 | * when large numbers of rows have recently been added or deleted. |
1390 | 1391 | * |
1391 | 1392 | * For DBMSs that don't support fast result size estimation, this function |
1392 | | - * will actually perform the SELECT COUNT(*). |
| 1393 | + * will actually perform the SELECT COUNT(*). |
1393 | 1394 | * |
1394 | 1395 | * Takes the same arguments as DatabaseBase::select(). |
1395 | 1396 | * |
— | — | @@ -1399,8 +1400,8 @@ |
1400 | 1401 | * @param $options Array: options for select |
1401 | 1402 | * @return Integer: row count |
1402 | 1403 | */ |
1403 | | - public function estimateRowCount( $table, $vars = '*', $conds = '', |
1404 | | - $fname = 'DatabaseBase::estimateRowCount', $options = array() ) |
| 1404 | + public function estimateRowCount( $table, $vars = '*', $conds = '', |
| 1405 | + $fname = 'DatabaseBase::estimateRowCount', $options = array() ) |
1405 | 1406 | { |
1406 | 1407 | $rows = 0; |
1407 | 1408 | $res = $this->select ( $table, 'COUNT(*) AS rowcount', $conds, $fname, $options ); |
— | — | @@ -1530,23 +1531,23 @@ |
1531 | 1532 | * $a may be either: |
1532 | 1533 | * |
1533 | 1534 | * - A single associative array. The array keys are the field names, and |
1534 | | - * the values are the values to insert. The values are treated as data |
1535 | | - * and will be quoted appropriately. If NULL is inserted, this will be |
| 1535 | + * the values are the values to insert. The values are treated as data |
| 1536 | + * and will be quoted appropriately. If NULL is inserted, this will be |
1536 | 1537 | * converted to a database NULL. |
1537 | | - * - An array with numeric keys, holding a list of associative arrays. |
| 1538 | + * - An array with numeric keys, holding a list of associative arrays. |
1538 | 1539 | * This causes a multi-row INSERT on DBMSs that support it. The keys in |
1539 | 1540 | * each subarray must be identical to each other, and in the same order. |
1540 | 1541 | * |
1541 | | - * Usually throws a DBQueryError on failure. If errors are explicitly ignored, |
| 1542 | + * Usually throws a DBQueryError on failure. If errors are explicitly ignored, |
1542 | 1543 | * returns success. |
1543 | 1544 | * |
1544 | | - * $options is an array of options, with boolean options encoded as values |
1545 | | - * with numeric keys, in the same style as $options in |
| 1545 | + * $options is an array of options, with boolean options encoded as values |
| 1546 | + * with numeric keys, in the same style as $options in |
1546 | 1547 | * DatabaseBase::select(). Supported options are: |
1547 | 1548 | * |
1548 | | - * - IGNORE: Boolean: if present, duplicate key errors are ignored, and |
1549 | | - * any rows which cause duplicate key errors are not inserted. It's |
1550 | | - * possible to determine how many rows were successfully inserted using |
| 1549 | + * - IGNORE: Boolean: if present, duplicate key errors are ignored, and |
| 1550 | + * any rows which cause duplicate key errors are not inserted. It's |
| 1551 | + * possible to determine how many rows were successfully inserted using |
1551 | 1552 | * DatabaseBase::affectedRows(). |
1552 | 1553 | * |
1553 | 1554 | * @param $table String Table name. This will be passed through |
— | — | @@ -1629,13 +1630,13 @@ |
1630 | 1631 | * @param $table String name of the table to UPDATE. This will be passed through |
1631 | 1632 | * DatabaseBase::tableName(). |
1632 | 1633 | * |
1633 | | - * @param $values Array: An array of values to SET. For each array element, |
| 1634 | + * @param $values Array: An array of values to SET. For each array element, |
1634 | 1635 | * the key gives the field name, and the value gives the data |
1635 | | - * to set that field to. The data will be quoted by |
| 1636 | + * to set that field to. The data will be quoted by |
1636 | 1637 | * DatabaseBase::addQuotes(). |
1637 | 1638 | * |
1638 | | - * @param $conds Array: An array of conditions (WHERE). See |
1639 | | - * DatabaseBase::select() for the details of the format of |
| 1639 | + * @param $conds Array: An array of conditions (WHERE). See |
| 1640 | + * DatabaseBase::select() for the details of the format of |
1640 | 1641 | * condition arrays. Use '*' to update all rows. |
1641 | 1642 | * |
1642 | 1643 | * @param $fname String: The function name of the caller (from __METHOD__), |
— | — | @@ -1663,7 +1664,7 @@ |
1664 | 1665 | * @param $a Array containing the data |
1665 | 1666 | * @param $mode: |
1666 | 1667 | * - LIST_COMMA: comma separated, no field names |
1667 | | - * - LIST_AND: ANDed WHERE clause (without the WHERE). See |
| 1668 | + * - LIST_AND: ANDed WHERE clause (without the WHERE). See |
1668 | 1669 | * the documentation for $conds in DatabaseBase::select(). |
1669 | 1670 | * - LIST_OR: ORed WHERE clause (without the WHERE) |
1670 | 1671 | * - LIST_SET: comma separated with field names, like a SET clause |
— | — | @@ -2219,19 +2220,19 @@ |
2220 | 2221 | * |
2221 | 2222 | * REPLACE is a very handy MySQL extension, which functions like an INSERT |
2222 | 2223 | * except that when there is a duplicate key error, the old row is deleted |
2223 | | - * and the new row is inserted in its place. |
| 2224 | + * and the new row is inserted in its place. |
2224 | 2225 | * |
2225 | | - * We simulate this with standard SQL with a DELETE followed by INSERT. To |
2226 | | - * perform the delete, we need to know what the unique indexes are so that |
| 2226 | + * We simulate this with standard SQL with a DELETE followed by INSERT. To |
| 2227 | + * perform the delete, we need to know what the unique indexes are so that |
2227 | 2228 | * we know how to find the conflicting rows. |
2228 | 2229 | * |
2229 | | - * It may be more efficient to leave off unique indexes which are unlikely |
2230 | | - * to collide. However if you do this, you run the risk of encountering |
| 2230 | + * It may be more efficient to leave off unique indexes which are unlikely |
| 2231 | + * to collide. However if you do this, you run the risk of encountering |
2231 | 2232 | * errors which wouldn't have occurred in MySQL. |
2232 | | - * |
2233 | | - * @param $rows Can be either a single row to insert, or multiple rows, |
| 2233 | + * |
| 2234 | + * @param $rows Can be either a single row to insert, or multiple rows, |
2234 | 2235 | * in the same format as for DatabaseBase::insert() |
2235 | | - * @param $uniqueIndexes is an array of indexes. Each element may be either |
| 2236 | + * @param $uniqueIndexes is an array of indexes. Each element may be either |
2236 | 2237 | * a field name or an array of field names |
2237 | 2238 | * |
2238 | 2239 | * @param $table String: The table to replace the row(s) in. |
— | — | @@ -2321,10 +2322,10 @@ |
2322 | 2323 | /** |
2323 | 2324 | * DELETE where the condition is a join. |
2324 | 2325 | * |
2325 | | - * MySQL overrides this to use a multi-table DELETE syntax, in other databases |
| 2326 | + * MySQL overrides this to use a multi-table DELETE syntax, in other databases |
2326 | 2327 | * we use sub-selects |
2327 | 2328 | * |
2328 | | - * For safety, an empty $conds will not delete everything. If you want to |
| 2329 | + * For safety, an empty $conds will not delete everything. If you want to |
2329 | 2330 | * delete all rows where the join condition matches, set $conds='*'. |
2330 | 2331 | * |
2331 | 2332 | * DO NOT put the join condition in $conds. |
— | — | @@ -2333,16 +2334,16 @@ |
2334 | 2335 | * @param $joinTable String: The other table. |
2335 | 2336 | * @param $delVar String: The variable to join on, in the first table. |
2336 | 2337 | * @param $joinVar String: The variable to join on, in the second table. |
2337 | | - * @param $conds Array: Condition array of field names mapped to variables, |
| 2338 | + * @param $conds Array: Condition array of field names mapped to variables, |
2338 | 2339 | * ANDed together in the WHERE clause |
2339 | | - * @param $fname String: Calling function name (use __METHOD__) for |
| 2340 | + * @param $fname String: Calling function name (use __METHOD__) for |
2340 | 2341 | * logs/profiling |
2341 | 2342 | */ |
2342 | | - function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, |
2343 | | - $fname = 'DatabaseBase::deleteJoin' ) |
| 2343 | + function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, |
| 2344 | + $fname = 'DatabaseBase::deleteJoin' ) |
2344 | 2345 | { |
2345 | 2346 | if ( !$conds ) { |
2346 | | - throw new DBUnexpectedError( $this, |
| 2347 | + throw new DBUnexpectedError( $this, |
2347 | 2348 | 'DatabaseBase::deleteJoin() called with empty $conds' ); |
2348 | 2349 | } |
2349 | 2350 | |
— | — | @@ -2382,7 +2383,7 @@ |
2383 | 2384 | * MySQL's LOW_PRIORITY. If no such feature exists, return an empty |
2384 | 2385 | * string and nothing bad should happen. |
2385 | 2386 | * |
2386 | | - * @return string Returns the text of the low priority option if it is |
| 2387 | + * @return string Returns the text of the low priority option if it is |
2387 | 2388 | * supported, or a blank string otherwise |
2388 | 2389 | */ |
2389 | 2390 | function lowPriorityOption() { |
— | — | @@ -2422,25 +2423,25 @@ |
2423 | 2424 | * @param $srcTable May be either a table name, or an array of table names |
2424 | 2425 | * to include in a join. |
2425 | 2426 | * |
2426 | | - * @param $varMap must be an associative array of the form |
2427 | | - * array( 'dest1' => 'source1', ...). Source items may be literals |
2428 | | - * rather than field names, but strings should be quoted with |
| 2427 | + * @param $varMap must be an associative array of the form |
| 2428 | + * array( 'dest1' => 'source1', ...). Source items may be literals |
| 2429 | + * rather than field names, but strings should be quoted with |
2429 | 2430 | * DatabaseBase::addQuotes() |
2430 | 2431 | * |
2431 | | - * @param $conds Condition array. See $conds in DatabaseBase::select() for |
2432 | | - * the details of the format of condition arrays. May be "*" to copy the |
| 2432 | + * @param $conds Condition array. See $conds in DatabaseBase::select() for |
| 2433 | + * the details of the format of condition arrays. May be "*" to copy the |
2433 | 2434 | * whole table. |
2434 | 2435 | * |
2435 | 2436 | * @param $fname The function name of the caller, from __METHOD__ |
2436 | 2437 | * |
2437 | | - * @param $insertOptions Options for the INSERT part of the query, see |
| 2438 | + * @param $insertOptions Options for the INSERT part of the query, see |
2438 | 2439 | * DatabaseBase::insert() for details. |
2439 | 2440 | * @param $selectOptions Options for the SELECT part of the query, see |
2440 | 2441 | * DatabaseBase::select() for details. |
2441 | 2442 | * |
2442 | 2443 | * @return ResultWrapper |
2443 | 2444 | */ |
2444 | | - function insertSelect( $destTable, $srcTable, $varMap, $conds, |
| 2445 | + function insertSelect( $destTable, $srcTable, $varMap, $conds, |
2445 | 2446 | $fname = 'DatabaseBase::insertSelect', |
2446 | 2447 | $insertOptions = array(), $selectOptions = array() ) |
2447 | 2448 | { |
— | — | @@ -2652,11 +2653,11 @@ |
2653 | 2654 | * Wait for the slave to catch up to a given master position. |
2654 | 2655 | * |
2655 | 2656 | * @param $pos DBMasterPos object |
2656 | | - * @param $timeout Integer: the maximum number of seconds to wait for |
| 2657 | + * @param $timeout Integer: the maximum number of seconds to wait for |
2657 | 2658 | * synchronisation |
2658 | 2659 | * |
2659 | 2660 | * @return An integer: zero if the slave was past that position already, |
2660 | | - * greater than zero if we waited for some period of time, less than |
| 2661 | + * greater than zero if we waited for some period of time, less than |
2661 | 2662 | * zero if we timed out. |
2662 | 2663 | */ |
2663 | 2664 | function masterPosWait( DBMasterPos $pos, $timeout ) { |
— | — | @@ -2760,10 +2761,10 @@ |
2761 | 2762 | * @param $fname String: calling function name |
2762 | 2763 | * @return Boolean: true if operation was successful |
2763 | 2764 | */ |
2764 | | - function duplicateTableStructure( $oldName, $newName, $temporary = false, |
2765 | | - $fname = 'DatabaseBase::duplicateTableStructure' ) |
| 2765 | + function duplicateTableStructure( $oldName, $newName, $temporary = false, |
| 2766 | + $fname = 'DatabaseBase::duplicateTableStructure' ) |
2766 | 2767 | { |
2767 | | - throw new MWException( |
| 2768 | + throw new MWException( |
2768 | 2769 | 'DatabaseBase::duplicateTableStructure is not implemented in descendant class' ); |
2769 | 2770 | } |
2770 | 2771 | |
— | — | @@ -2778,10 +2779,10 @@ |
2779 | 2780 | } |
2780 | 2781 | |
2781 | 2782 | /** |
2782 | | - * Convert a timestamp in one of the formats accepted by wfTimestamp() |
| 2783 | + * Convert a timestamp in one of the formats accepted by wfTimestamp() |
2783 | 2784 | * to the format used for inserting into timestamp fields in this DBMS. |
2784 | 2785 | * |
2785 | | - * The result is unquoted, and needs to be passed through addQuotes() |
| 2786 | + * The result is unquoted, and needs to be passed through addQuotes() |
2786 | 2787 | * before it can be included in raw SQL. |
2787 | 2788 | * |
2788 | 2789 | * @return string |
— | — | @@ -2791,12 +2792,12 @@ |
2792 | 2793 | } |
2793 | 2794 | |
2794 | 2795 | /** |
2795 | | - * Convert a timestamp in one of the formats accepted by wfTimestamp() |
2796 | | - * to the format used for inserting into timestamp fields in this DBMS. If |
2797 | | - * NULL is input, it is passed through, allowing NULL values to be inserted |
| 2796 | + * Convert a timestamp in one of the formats accepted by wfTimestamp() |
| 2797 | + * to the format used for inserting into timestamp fields in this DBMS. If |
| 2798 | + * NULL is input, it is passed through, allowing NULL values to be inserted |
2798 | 2799 | * into timestamp fields. |
2799 | 2800 | * |
2800 | | - * The result is unquoted, and needs to be passed through addQuotes() |
| 2801 | + * The result is unquoted, and needs to be passed through addQuotes() |
2801 | 2802 | * before it can be included in raw SQL. |
2802 | 2803 | * |
2803 | 2804 | * @return string |
— | — | @@ -2810,14 +2811,14 @@ |
2811 | 2812 | } |
2812 | 2813 | |
2813 | 2814 | /** |
2814 | | - * Take the result from a query, and wrap it in a ResultWrapper if |
2815 | | - * necessary. Boolean values are passed through as is, to indicate success |
2816 | | - * of write queries or failure. |
| 2815 | + * Take the result from a query, and wrap it in a ResultWrapper if |
| 2816 | + * necessary. Boolean values are passed through as is, to indicate success |
| 2817 | + * of write queries or failure. |
2817 | 2818 | * |
2818 | | - * Once upon a time, DatabaseBase::query() returned a bare MySQL result |
| 2819 | + * Once upon a time, DatabaseBase::query() returned a bare MySQL result |
2819 | 2820 | * resource, and it was necessary to call this function to convert it to |
2820 | 2821 | * a wrapper. Nowadays, raw database objects are never exposed to external |
2821 | | - * callers, so this is unnecessary in external code. For compatibility with |
| 2822 | + * callers, so this is unnecessary in external code. For compatibility with |
2822 | 2823 | * old code, ResultWrapper objects are passed through unaltered. |
2823 | 2824 | */ |
2824 | 2825 | function resultObject( $result ) { |
— | — | @@ -2869,10 +2870,10 @@ |
2870 | 2871 | } |
2871 | 2872 | |
2872 | 2873 | /** |
2873 | | - * Some DBMSs have a special format for inserting into blob fields, they |
2874 | | - * don't allow simple quoted strings to be inserted. To insert into such |
2875 | | - * a field, pass the data through this function before passing it to |
2876 | | - * DatabaseBase::insert(). |
| 2874 | + * Some DBMSs have a special format for inserting into blob fields, they |
| 2875 | + * don't allow simple quoted strings to be inserted. To insert into such |
| 2876 | + * a field, pass the data through this function before passing it to |
| 2877 | + * DatabaseBase::insert(). |
2877 | 2878 | */ |
2878 | 2879 | function encodeBlob( $b ) { |
2879 | 2880 | return $b; |
— | — | @@ -2880,7 +2881,7 @@ |
2881 | 2882 | |
2882 | 2883 | /** |
2883 | 2884 | * Some DBMSs return a special placeholder object representing blob fields |
2884 | | - * in result objects. Pass the object through this function to return the |
| 2885 | + * in result objects. Pass the object through this function to return the |
2885 | 2886 | * original string. |
2886 | 2887 | */ |
2887 | 2888 | function decodeBlob( $b ) { |
— | — | @@ -2900,13 +2901,13 @@ |
2901 | 2902 | /** |
2902 | 2903 | * Read and execute SQL commands from a file. |
2903 | 2904 | * |
2904 | | - * Returns true on success, error string or exception on failure (depending |
| 2905 | + * Returns true on success, error string or exception on failure (depending |
2905 | 2906 | * on object's error ignore settings). |
2906 | 2907 | * |
2907 | 2908 | * @param $filename String: File name to open |
2908 | 2909 | * @param $lineCallback Callback: Optional function called before reading each line |
2909 | 2910 | * @param $resultCallback Callback: Optional function called for each MySQL result |
2910 | | - * @param $fname String: Calling function name or false if name should be |
| 2911 | + * @param $fname String: Calling function name or false if name should be |
2911 | 2912 | * generated dynamically using $filename |
2912 | 2913 | */ |
2913 | 2914 | function sourceFile( $filename, $lineCallback = false, $resultCallback = false, $fname = false ) { |
— | — | @@ -2968,7 +2969,7 @@ |
2969 | 2970 | /** |
2970 | 2971 | * Read and execute commands from an open file handle. |
2971 | 2972 | * |
2972 | | - * Returns true on success, error string or exception on failure (depending |
| 2973 | + * Returns true on success, error string or exception on failure (depending |
2973 | 2974 | * on object's error ignore settings). |
2974 | 2975 | * |
2975 | 2976 | * @param $fp Resource: File handle |
— | — | @@ -2976,8 +2977,8 @@ |
2977 | 2978 | * @param $resultCallback Callback: Optional function called for each MySQL result |
2978 | 2979 | * @param $fname String: Calling function name |
2979 | 2980 | */ |
2980 | | - function sourceStream( $fp, $lineCallback = false, $resultCallback = false, |
2981 | | - $fname = 'DatabaseBase::sourceStream' ) |
| 2981 | + function sourceStream( $fp, $lineCallback = false, $resultCallback = false, |
| 2982 | + $fname = 'DatabaseBase::sourceStream' ) |
2982 | 2983 | { |
2983 | 2984 | $cmd = ""; |
2984 | 2985 | $done = false; |
— | — | @@ -3050,12 +3051,12 @@ |
3051 | 3052 | * |
3052 | 3053 | * Supports '{$var}' `{$var}` and / *$var* / (without the spaces) style variables. |
3053 | 3054 | * |
3054 | | - * - '{$var}' should be used for text and is passed through the database's |
| 3055 | + * - '{$var}' should be used for text and is passed through the database's |
3055 | 3056 | * addQuotes method. |
3056 | | - * - `{$var}` should be used for identifiers (eg: table and database names), |
3057 | | - * it is passed through the database's addIdentifierQuotes method which |
| 3057 | + * - `{$var}` should be used for identifiers (eg: table and database names), |
| 3058 | + * it is passed through the database's addIdentifierQuotes method which |
3058 | 3059 | * can be overridden if the database uses something other than backticks. |
3059 | | - * - / *$var* / is just encoded, besides traditional table prefix and |
| 3060 | + * - / *$var* / is just encoded, besides traditional table prefix and |
3060 | 3061 | * table options its use should be avoided. |
3061 | 3062 | * |
3062 | 3063 | * @param $ins String: SQL statement to replace variables in |
— | — | @@ -3076,6 +3077,10 @@ |
3077 | 3078 | |
3078 | 3079 | /** |
3079 | 3080 | * Replace variables in sourced SQL |
| 3081 | + * |
| 3082 | + * @param $ins string |
| 3083 | + * |
| 3084 | + * @return string |
3080 | 3085 | */ |
3081 | 3086 | protected function replaceVars( $ins ) { |
3082 | 3087 | $ins = $this->replaceSchemaVars( $ins ); |
— | — | @@ -3108,6 +3113,8 @@ |
3109 | 3114 | * |
3110 | 3115 | * Override this in derived classes to provide variables for tables.sql |
3111 | 3116 | * and SQL patch files. |
| 3117 | + * |
| 3118 | + * @return array |
3112 | 3119 | */ |
3113 | 3120 | protected function getDefaultSchemaVars() { |
3114 | 3121 | return array(); |
— | — | @@ -3115,7 +3122,10 @@ |
3116 | 3123 | |
3117 | 3124 | /** |
3118 | 3125 | * Table name callback |
3119 | | - * @private |
| 3126 | + * |
| 3127 | + * @param $matches array |
| 3128 | + * |
| 3129 | + * @return string |
3120 | 3130 | */ |
3121 | 3131 | protected function tableNameCallback( $matches ) { |
3122 | 3132 | return $this->tableName( $matches[1] ); |
— | — | @@ -3123,6 +3133,10 @@ |
3124 | 3134 | |
3125 | 3135 | /** |
3126 | 3136 | * Index name callback |
| 3137 | + * |
| 3138 | + * @param $matches array |
| 3139 | + * |
| 3140 | + * @return string |
3127 | 3141 | */ |
3128 | 3142 | protected function indexNameCallback( $matches ) { |
3129 | 3143 | return $this->indexName( $matches[1] ); |
— | — | @@ -3173,6 +3187,8 @@ |
3174 | 3188 | * @param $write Array of tables to lock for write access |
3175 | 3189 | * @param $method String name of caller |
3176 | 3190 | * @param $lowPriority bool Whether to indicate writes to be LOW PRIORITY |
| 3191 | + * |
| 3192 | + * @return bool |
3177 | 3193 | */ |
3178 | 3194 | public function lockTables( $read, $write, $method, $lowPriority = true ) { |
3179 | 3195 | return true; |
— | — | @@ -3182,6 +3198,8 @@ |
3183 | 3199 | * Unlock specific tables |
3184 | 3200 | * |
3185 | 3201 | * @param $method String the caller |
| 3202 | + * |
| 3203 | + * @return bool |
3186 | 3204 | */ |
3187 | 3205 | public function unlockTables( $method ) { |
3188 | 3206 | return true; |
— | — | @@ -3189,6 +3207,9 @@ |
3190 | 3208 | |
3191 | 3209 | /** |
3192 | 3210 | * Delete a table |
| 3211 | + * @param $tableName string |
| 3212 | + * @param $fName string |
| 3213 | + * @return bool|ResultWrapper |
3193 | 3214 | */ |
3194 | 3215 | public function dropTable( $tableName, $fName = 'DatabaseBase::dropTable' ) { |
3195 | 3216 | if( !$this->tableExists( $tableName ) ) { |
— | — | @@ -3242,7 +3263,7 @@ |
3243 | 3264 | * |
3244 | 3265 | * This is a MySQL-specific feature. |
3245 | 3266 | * |
3246 | | - * @param $value Mixed: true for allow, false for deny, or "default" to |
| 3267 | + * @param $value Mixed: true for allow, false for deny, or "default" to |
3247 | 3268 | * restore the initial value |
3248 | 3269 | */ |
3249 | 3270 | public function setBigSelects( $value = true ) { |