r113182 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113181‎ | r113182 | r113183 >
Date:21:35, 6 March 2012
Author:ialex
Status:ok
Tags:
Comment:
Use common methods to make database requests (DatabaseBase::select() and DatabaseBase::selectRow()) instead of DatabaseBase::safeQuery()
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -163,15 +163,18 @@
164164 $globaluser = $dbr->tableName( 'globaluser' );
165165 $localuser = $dbr->tableName( 'localuser' );
166166
167 - $sql =
168 - "SELECT gu_id, lu_wiki, gu_salt, gu_password,gu_auth_token, " .
169 - "gu_locked,gu_hidden, gu_registration, gu_email, " .
170 - "gu_email_authenticated, gu_home_db " .
171 - "FROM $globaluser " .
172 - "LEFT OUTER JOIN $localuser ON gu_name=lu_name AND lu_wiki=? " .
173 - "WHERE gu_name=?";
174 - $result = $dbr->safeQuery( $sql, wfWikiID(), $this->mName );
175 - $row = $dbr->fetchObject( $result );
 167+ $row = $dbr->selectRow(
 168+ array( 'globaluser', 'localuser' ),
 169+ array(
 170+ 'gu_id', 'lu_wiki', 'gu_salt', 'gu_password', 'gu_auth_token',
 171+ 'gu_locked', 'gu_hidden', 'gu_registration', 'gu_email',
 172+ 'gu_email_authenticated', 'gu_home_db'
 173+ ),
 174+ array( 'gu_name' => $this->mName ),
 175+ __METHOD__,
 176+ array(),
 177+ array( 'localuser' => array( 'LEFT OUTER JOIN', array( 'gu_name=lu_name', 'lu_wiki' => wfWikiID() ) ) )
 178+ );
176179
177180 $this->loadFromRow( $row, true );
178181 $this->saveToCache();
@@ -1401,14 +1404,14 @@
14021405 function doListUnattached() {
14031406 $dbw = self::getCentralDB();
14041407
1405 - $sql = "
1406 - SELECT ln_wiki
1407 - FROM localnames
1408 - LEFT OUTER JOIN localuser
1409 - ON ln_wiki=lu_wiki AND ln_name=lu_name
1410 - WHERE ln_name=? AND lu_name IS NULL
1411 - ";
1412 - $result = $dbw->safeQuery( $sql, $this->mName );
 1408+ $result = $dbw->select(
 1409+ array( 'localnames', 'localuser' ),
 1410+ array( 'ln_wiki' ),
 1411+ array( 'ln_name' => $this->mName, 'lu_name IS NULL' ),
 1412+ __METHOD__,
 1413+ array(),
 1414+ array( 'localuser' => array( 'LEFT OUTER JOIN', array( 'ln_wiki=lu_wiki', 'ln_name=lu_name' ) ) )
 1415+ );
14131416
14141417 $dbs = array();
14151418 foreach ( $result as $row ) {

Status & tagging log