r72132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72131‎ | r72132 | r72133 >
Date:18:09, 1 September 2010
Author:catrope
Status:ok
Tags:
Comment:
1.16wmf4: MFT r70632
Modified paths:
  • /branches/wmf/1.16wmf4/includes/UserRightsProxy.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/includes/UserRightsProxy.php
@@ -21,6 +21,7 @@
2222 $this->database = $database;
2323 $this->name = $name;
2424 $this->id = intval( $id );
 25+ $this->newOptions = array();
2526 }
2627
2728 /**
@@ -48,10 +49,11 @@
4950 *
5051 * @param $database String: database name
5152 * @param $id Integer: user ID
 53+ * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
5254 * @return String: user name or false if the user doesn't exist
5355 */
54 - public static function whoIs( $database, $id ) {
55 - $user = self::newFromId( $database, $id );
 56+ public static function whoIs( $database, $id, $ignoreInvalidDB = false ) {
 57+ $user = self::newFromId( $database, $id, $ignoreInvalidDB );
5658 if( $user ) {
5759 return $user->name;
5860 } else {
@@ -64,10 +66,11 @@
6567 *
6668 * @param $database String: database name
6769 * @param $id Integer: user ID
 70+ * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
6871 * @return UserRightsProxy or null if doesn't exist
6972 */
70 - public static function newFromId( $database, $id ) {
71 - return self::newFromLookup( $database, 'user_id', intval( $id ) );
 73+ public static function newFromId( $database, $id, $ignoreInvalidDB = false ) {
 74+ return self::newFromLookup( $database, 'user_id', intval( $id ), $ignoreInvalidDB );
7275 }
7376
7477 /**
@@ -75,14 +78,15 @@
7679 *
7780 * @param $database String: database name
7881 * @param $name String: user name
 82+ * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
7983 * @return UserRightsProxy or null if doesn't exist
8084 */
81 - public static function newFromName( $database, $name ) {
82 - return self::newFromLookup( $database, 'user_name', $name );
 85+ public static function newFromName( $database, $name, $ignoreInvalidDB = false ) {
 86+ return self::newFromLookup( $database, 'user_name', $name, $ignoreInvalidDB );
8387 }
8488
85 - private static function newFromLookup( $database, $field, $value ) {
86 - $db = self::getDB( $database );
 89+ private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
 90+ $db = self::getDB( $database, $ignoreInvalidDB );
8791 if( $db ) {
8892 $row = $db->selectRow( 'user',
8993 array( 'user_id', 'user_name' ),
@@ -102,9 +106,10 @@
103107 * This may be a new connection to another database for remote users.
104108 *
105109 * @param $database String
 110+ * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
106111 * @return DatabaseBase or null if invalid selection
107112 */
108 - public static function getDB( $database ) {
 113+ public static function getDB( $database, $ignoreInvalidDB = false ) {
109114 global $wgLocalDatabases, $wgDBname;
110115 if( self::validDatabase( $database ) ) {
111116 if( $database == $wgDBname ) {
@@ -182,6 +187,29 @@
183188 ),
184189 __METHOD__ );
185190 }
 191+
 192+ /**
 193+ * Replaces User::setOption()
 194+ */
 195+ public function setOption( $option, $value ) {
 196+ $this->newOptions[$option] = $value;
 197+ }
 198+
 199+ public function saveSettings() {
 200+ $rows = array();
 201+ foreach ( $this->newOptions as $option => $value ) {
 202+ $rows[] = array(
 203+ 'up_user' => $this->id,
 204+ 'up_property' => $option,
 205+ 'up_value' => $value,
 206+ );
 207+ }
 208+ $this->db->replace( 'user_properties',
 209+ array( array( 'up_user', 'up_property' ) ),
 210+ $rows, __METHOD__
 211+ );
 212+ $this->invalidateCache();
 213+ }
186214
187215 /**
188216 * Replaces User::touchUser()
Property changes on: branches/wmf/1.16wmf4/includes/UserRightsProxy.php
___________________________________________________________________
Added: svn:mergeinfo
189217 Merged /branches/sqlite/includes/UserRightsProxy.php:r58211-58321
190218 Merged /trunk/phase3/includes/UserRightsProxy.php:r63549,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,70632,71059,71098
191219 Merged /branches/wmf-deployment/includes/UserRightsProxy.php:r53381,60970
192220 Merged /branches/REL1_15/phase3/includes/UserRightsProxy.php:r51646

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70632Hack up UserRightsProxy to support setting preferences of remote users, neede...catrope16:08, 7 August 2010

Status & tagging log