From: Thiemo Kreuz Date: Tue, 26 Mar 2019 11:01:31 +0000 (+0100) Subject: rdbms: Fix incomplete doc for DatabaseMssql::tableName() X-Git-Tag: 1.34.0-rc.0~2340^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=376af797d56f4463326bfbd60914f8f75a41051e;p=lhc%2Fweb%2Fwiklou.git rdbms: Fix incomplete doc for DatabaseMssql::tableName() I'm also replacing a loop with an array_pad() call. When the count given to array_pad() is negative, the padding is done to the left instead of the right. This is exactly what the loop did before. I'm also adding the missing limit to the explode() call. Change-Id: I6737fcf6b60b822269b855f1405607be7fc23754 --- diff --git a/includes/libs/rdbms/database/DatabaseMssql.php b/includes/libs/rdbms/database/DatabaseMssql.php index ad5cf98f5c..57412c22f4 100644 --- a/includes/libs/rdbms/database/DatabaseMssql.php +++ b/includes/libs/rdbms/database/DatabaseMssql.php @@ -1328,8 +1328,9 @@ class DatabaseMssql extends Database { /** * @param string $name - * @param string $format - * @return string + * @param string $format One of "quoted" (default), "raw", or "split". + * @return string|array When the requested $format is "split", a list of database, schema, and + * table name is returned. Database and schema can be `false`. */ function tableName( $name, $format = 'quoted' ) { # Replace reserved words with better ones @@ -1344,18 +1345,17 @@ class DatabaseMssql extends Database { /** * call this instead of tableName() in the updater when renaming tables * @param string $name - * @param string $format One of quoted, raw, or split - * @return string + * @param string $format One of "quoted" (default), "raw", or "split". + * @return string|array When the requested $format is "split", a list of database, schema, and + * table name is returned. Database and schema can be `false`. + * @private */ function realTableName( $name, $format = 'quoted' ) { $table = parent::tableName( $name, $format ); if ( $format == 'split' ) { // Used internally, we want the schema split off from the table name and returned // as a list with 3 elements (database, schema, table) - $table = explode( '.', $table ); - while ( count( $table ) < 3 ) { - array_unshift( $table, false ); - } + return array_pad( explode( '.', $table, 3 ), -3, false ); } return $table; }