From: umherirrender Date: Fri, 25 May 2012 15:53:29 +0000 (+0200) Subject: user table: replace some '*' with explicit fields in selects X-Git-Tag: 1.31.0-rc.0~23505^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=2f190c47928fe98f2e0bbec6c7ccb204032d16c5;p=lhc%2Fweb%2Fwiklou.git user table: replace some '*' with explicit fields in selects It is good practice to select only fields, which are used later Change-Id: Iaaa252d594112894334a8ee9916007352d5bc4e7 --- diff --git a/includes/User.php b/includes/User.php index 5de4b2c5bb..84f02afcc7 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1028,7 +1028,7 @@ class User { } $dbr = wfGetDB( DB_MASTER ); - $s = $dbr->selectRow( 'user', '*', array( 'user_id' => $this->mId ), __METHOD__ ); + $s = $dbr->selectRow( 'user', self::selectFields(), array( 'user_id' => $this->mId ), __METHOD__ ); wfRunHooks( 'UserLoadFromDatabase', array( $this, &$s ) ); @@ -4018,7 +4018,7 @@ class User { $res = $dbr->select( 'user_properties', - '*', + array( 'up_property', 'up_value' ), array( 'up_user' => $this->getId() ), __METHOD__ ); @@ -4141,4 +4141,28 @@ class User { return $ret; } + + /** + * Return the list of user fields that should be selected to create + * a new user object. + * @return array + */ + public static function selectFields() { + return array( + 'user_id', + 'user_name', + 'user_real_name', + 'user_password', + 'user_newpassword', + 'user_newpass_time', + 'user_email', + 'user_touched', + 'user_token', + 'user_email_authenticated', + 'user_email_token', + 'user_email_token_expires', + 'user_registration', + 'user_editcount', + ); + } } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index a07ee7f890..83872a5701 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -107,7 +107,7 @@ class ApiQueryUsers extends ApiQueryBase { if ( count( $goodNames ) ) { $this->addTables( 'user' ); - $this->addFields( '*' ); + $this->addFields( User::selectFields() ); $this->addWhereFld( 'user_name', $goodNames ); if ( isset( $this->prop['groups'] ) || isset( $this->prop['rights'] ) ) { diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index f140546a47..51520c89a7 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -154,7 +154,7 @@ class SpecialPasswordReset extends FormSpecialPage { $method = 'email'; $res = wfGetDB( DB_SLAVE )->select( 'user', - '*', + User::selectFields(), array( 'user_email' => $data['Email'] ), __METHOD__ );