r90458 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90457‎ | r90458 | r90459 >
Date:12:09, 20 June 2011
Author:tstarling
Status:ok
Tags:
Comment:
Followup r90429:
* Reverted the public -> protected changes from r90429, except for doQuery() after a review of usage:
** resultObject() is used by lots of things in core and extensions.
** makeSelectOptions() is used by SMW, and if that's going to be public, the other two probably should be too, for consistency.
** doQuery() was used by several things, but mostly by mistake. It's been marked private since r21359 which is before almost all of them. I updated the callers to use query().

* Added "protected" to doQuery() declarations in other database classes.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMssql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -18,7 +18,7 @@
1919 return 'mysql';
2020 }
2121
22 - /*private*/ function doQuery( $sql ) {
 22+ protected function doQuery( $sql ) {
2323 if( $this->bufferResults() ) {
2424 $ret = mysql_query( $sql, $this->mConn );
2525 } else {
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -302,7 +302,7 @@
303303 return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
304304 }
305305
306 - function doQuery( $sql ) {
 306+ protected function doQuery( $sql ) {
307307 wfDebug( "SQL: [$sql]\n" );
308308 if ( !mb_check_encoding( $sql ) ) {
309309 throw new MWException( "SQL encoding is invalid\n$sql" );
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -246,7 +246,7 @@
247247 }
248248 }
249249
250 - function doQuery( $sql ) {
 250+ protected function doQuery( $sql ) {
251251 if ( function_exists( 'mb_convert_encoding' ) ) {
252252 $sql = mb_convert_encoding( $sql, 'UTF-8' );
253253 }
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -453,10 +453,8 @@
454454 * The DBMS-dependent part of query()
455455 * @param $sql String: SQL query.
456456 * @return object Result object for fetch functions or false on failure
457 - * @access private
458457 */
459 - /*private*/
460 - public function doQuery( $sql ) {
 458+ protected function doQuery( $sql ) {
461459 $this->applySchema();
462460
463461 // Needed to handle any UTF-8 encoding issues in the raw sql
Index: trunk/phase3/includes/db/Database.php
@@ -1044,7 +1044,7 @@
10451045 * @return Array
10461046 * @see DatabaseBase::select()
10471047 */
1048 - protected function makeSelectOptions( $options ) {
 1048+ function makeSelectOptions( $options ) {
10491049 $preLimitTail = $postLimitTail = '';
10501050 $startOpts = '';
10511051
@@ -1517,7 +1517,7 @@
15181518 * @param $options array
15191519 * @return string
15201520 */
1521 - protected function makeInsertOptions( $options ) {
 1521+ function makeInsertOptions( $options ) {
15221522 return implode( ' ', $options );
15231523 }
15241524
@@ -1602,7 +1602,7 @@
16031603 * @param $options Array: The options passed to DatabaseBase::update
16041604 * @return string
16051605 */
1606 - protected function makeUpdateOptions( $options ) {
 1606+ function makeUpdateOptions( $options ) {
16071607 if ( !is_array( $options ) ) {
16081608 $options = array( $options );
16091609 }
@@ -2758,10 +2758,15 @@
27592759 /**
27602760 * Take the result from a query, and wrap it in a ResultWrapper if
27612761 * necessary. Boolean values are passed through as is, to indicate success
2762 - * of write queries or failure. ResultWrapper objects are also passed
2763 - * through.
 2762+ * of write queries or failure.
 2763+ *
 2764+ * Once upon a time, DatabaseBase::query() returned a bare MySQL result
 2765+ * resource, and it was necessary to call this function to convert it to
 2766+ * a wrapper. Nowadays, raw database objects are never exposed to external
 2767+ * callers, so this is unnecessary in external code. For compatibility with
 2768+ * old code, ResultWrapper objects are passed through unaltered.
27642769 */
2765 - protected function resultObject( $result ) {
 2770+ function resultObject( $result ) {
27662771 if ( empty( $result ) ) {
27672772 return false;
27682773 } elseif ( $result instanceof ResultWrapper ) {
Index: trunk/phase3/includes/db/DatabaseMssql.php
@@ -117,7 +117,7 @@
118118 }
119119 }
120120
121 - function doQuery( $sql ) {
 121+ protected function doQuery( $sql ) {
122122 wfDebug( "SQL: [$sql]\n" );
123123 $this->offset = 0;
124124
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -213,7 +213,7 @@
214214 *
215215 * @return ResultWrapper
216216 */
217 - function doQuery( $sql ) {
 217+ protected function doQuery( $sql ) {
218218 $res = $this->mConn->query( $sql );
219219 if ( $res === false ) {
220220 return false;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r21359Documentation, mark public functions public, comment a presumably private fun...simetrical02:01, 19 April 2007
r90429In Database.php:...tstarling06:52, 20 June 2011

Status & tagging log