Rename fields of user_rights and user_groups table to tablename_columnname schema
authorJens Frank <jeluf@users.mediawiki.org>
Sun, 24 Oct 2004 09:21:53 +0000 (09:21 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sun, 24 Oct 2004 09:21:53 +0000 (09:21 +0000)
12 files changed:
includes/DefaultSettings.php
includes/Parser.php
includes/SpecialListadmins.php
includes/SpecialListusers.php
includes/SpecialMakesysop.php
includes/SpecialStatistics.php
includes/User.php
maintenance/archives/patch-rename-user_groups-and_rights.sql [new file with mode: 0644]
maintenance/archives/patch-user_rights.sql
maintenance/archives/patch-userlevels.sql
maintenance/tables.sql
maintenance/updaters.inc

index 3cac609..093a375 100644 (file)
@@ -771,11 +771,12 @@ $wgImageLimits = array (
        array(10000,10000) );
 
 
-# Navigation links for the user sidebar.
-# 'text' is the name of the MediaWiki message that contains the label of this link
-# 'href' is the name of the MediaWiki message that contains the link target of this link.
-#        Link targets starting with http are considered remote links. Ones not starting with
-#        http are considered as names of local wiki pages.
+/** Navigation links for the user sidebar.
+ * 'text' is the name of the MediaWiki message that contains the label of this link
+ * 'href' is the name of the MediaWiki message that contains the link target of this link.
+ *        Link targets starting with http are considered remote links. Ones not starting with
+ *        http are considered as names of local wiki pages.
+ */
 $wgNavigationLinks = array (
        array( 'text'=>'mainpage',      'href'=>'mainpage' ),
        array( 'text'=>'portal',        'href'=>'portal-url' ),
index 42c85ac..52f14f9 100644 (file)
@@ -2460,7 +2460,7 @@ class Parser
                                if( $istemplate )
                                        $headline = $sk->editSectionScriptForOther($templatetitle, $templatesection, $headline);
                                else
-                                       $headline = $sk->editSectionScript($this->title, $sectionCount+1,$headline);
+                                       $headline = $sk->editSectionScript($this->mTitle, $sectionCount+1,$headline);
                        }
 
                        # give headline the correct <h#> tag
index aa617a0..5d05730 100644 (file)
@@ -31,9 +31,9 @@ class ListAdminsPage extends PageQueryPage {
                $user = $dbr->tableName( 'user' );
                $user_rights = $dbr->tableName( 'user_rights' );
                $userspace = Namespace::getUser();
-               return "SELECT r.user_rights as type,{$userspace} as namespace,".
-                      "u.user_name as title, u.user_name as value ".
-                      "FROM {$user} u,{$user_rights} r WHERE r.user_id=u.user_id AND r.user_rights LIKE '%sysop%'";
+               return "SELECT ur_rights as type,{$userspace} as namespace,".
+                      "user_name as title, user_name as value ".
+                      "FROM {$user} ,{$user_rights} WHERE user_id=ur_uid AND ur_rights LIKE '%sysop%'";
        }
 }
 
index c25da6b..6f9f0e2 100644 (file)
@@ -29,8 +29,8 @@ class ListUsersPage extends QueryPage {
                $user = $dbr->tableName( 'user' );
                $user_rights = $dbr->tableName( 'user_rights' );
                $userspace = Namespace::getUser();
-               return "SELECT r.user_rights as type, $userspace as namespace, u.user_name as title, " .
-                       "u.user_name as value FROM $user u LEFT JOIN $user_rights r ON u.user_id = r.user_id";
+               return "SELECT ur_rights as type, $userspace as namespace, user_name as title, " .
+                       "user_name as value FROM $user LEFT JOIN $user_rights ON user_id = ur_uid";
        }
        
        function sortDescending() {
index 48799d1..d1da928 100644 (file)
@@ -160,10 +160,10 @@ class MakesysopForm {
                }
                if ( $username{0} == "#" ) {
                        $id = intval( substr( $username, 1 ) );
-                       $sql = "SELECT user_id,user_rights FROM $user_rights WHERE user_id=$id FOR UPDATE";
+                       $sql = "SELECT ur_uid,ur_rights FROM $user_rights WHERE ur_uid=$id FOR UPDATE";
                } else {
                        $encName = $dbw->strencode( $username );
-                       $sql = "SELECT u.user_id, user_rights FROM $usertable u LEFT JOIN $user_rights r ON u.user_id=r.user_id WHERE user_name = '{$username}' FOR UPDATE";
+                       $sql = "SELECT ur_uid, ur_rights FROM $usertable LEFT JOIN $user_rights ON user_id=ur_uid WHERE user_name = '{$username}' FOR UPDATE";
                }
                
                $prev = $dbw->ignoreErrors( TRUE );
@@ -176,15 +176,15 @@ class MakesysopForm {
                }
 
                $row = $dbw->fetchObject( $res );
-               $id = intval( $row->user_id );
+               $id = intval( $row->ur_uid );
                $rightsNotation = array();
 
                if ( $wgUser->isDeveloper() ) {
                        $newrights = (string)$this->mRights;
                        $rightsNotation[] = "=$this->mRights";
                } else {
-                       if( $row->user_rights ){
-                               $rights = explode(",", $row->user_rights );
+                       if( $row->ur_rights ){
+                               $rights = explode(",", $row->ur_rights );
                                if(! in_array("sysop", $rights ) ){
                                        $rights[] = "sysop";
                                        $rightsNotation[] = "+sysop ";
@@ -209,8 +209,8 @@ class MakesysopForm {
                } else {
                        #$sql = "UPDATE $user_rights SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1";
                        #$dbw->query($sql);
-                       $dbw->replace( $user_rights, array( array( 'user_id', 'user_rights' )),
-                               array( 'user_id' => $id, 'user_rights' => $newrights ) , $fname );
+                       $dbw->replace( $user_rights, array( array( 'ur_uid', 'ur_rights' )),
+                               array( 'ur_uid' => $id, 'ur_rights' => $newrights ) , $fname );
                        $wgMemc->delete( "$dbName:user:id:$id" );
                        
                        $log = new LogPage( 'rights' );
index ec40c09..ee716e6 100644 (file)
@@ -46,7 +46,7 @@ function wfSpecialStatistics() {
        $row = $dbr->fetchObject( $res );
        $total = $row->total;
 
-       $sql = "SELECT COUNT(user_id) AS total FROM $user_rights WHERE user_rights LIKE '%sysop%'";
+       $sql = "SELECT COUNT(ur_uid) AS total FROM $user_rights WHERE ur_rights LIKE '%sysop%'";
        $res = $dbr->query( $sql, $fname );
        $row = $dbr->fetchObject( $res );
        $admins = $row->total;
index 9575481..e6cec31 100644 (file)
@@ -356,11 +356,11 @@ class User {
                        $this->mToken = $s->user_token;
                        
                        $this->mRights = explode( ",", strtolower( 
-                               $dbr->selectField( 'user_rights', 'user_rights', array( 'user_id' => $this->mId ) )
+                               $dbr->selectField( 'user_rights', 'ur_rights', array( 'ur_uid' => $this->mId ) )
                        ) );
                        
                        // Get groups id
-                       $res = $dbr->select( 'user_groups', array( 'group_id' ), array( 'user_id' => $this->mId ) );
+                       $res = $dbr->select( 'user_groups', array( 'ug_gid' ), array( 'ug_uid' => $this->mId ) );
                        while($group = $dbr->fetchRow($res)) {
                                $this->mGroups[] = $group[0];
                        }
@@ -769,19 +769,19 @@ class User {
                                'user_id' => $this->mId
                        ), $fname
                );
-               $dbw->set( 'user_rights', 'user_rights', implode( ',', $this->mRights ),
-                       'user_id='. $this->mId, $fname ); 
+               $dbw->set( 'user_rights', 'ur_rights', implode( ',', $this->mRights ),
+                       'ur_uid='. $this->mId, $fname ); 
                $wgMemc->delete( "$wgDBname:user:id:$this->mId" );
                
                // delete old groups
-               $dbw->delete( 'user_groups', array( 'user_id' => $this->mId), $fname);
+               $dbw->delete( 'user_groups', array( 'ug_uid' => $this->mId), $fname);
                // save new ones
                foreach ($this->mGroups as $group) {
                        $dbw->replace( 'user_groups',
-                               array(array('user_id','group_id')),
+                               array(array('ug_uid','ug_gid')),
                                array(
-                                       'user_id' => $this->mId,
-                                       'group_id' => $group
+                                       'ug_uid' => $this->mId,
+                                       'ug_gid' => $group
                                ), $fname
                        );
                }
@@ -827,16 +827,16 @@ class User {
                $this->mId = $dbw->insertId();
                $dbw->insert( 'user_rights',
                        array(
-                               'user_id' => $this->mId,
-                               'user_rights' => implode( ',', $this->mRights )
+                               'ur_uid' => $this->mId,
+                               'ur_rights' => implode( ',', $this->mRights )
                        ), $fname
                );
                
                foreach ($this->mGroups as $group) {
                        $dbw->insert( 'user_groups',
                                array(
-                                       'user_id' => $this->mId,
-                                       'group_id' => $group
+                                       'ug_uid' => $this->mId,
+                                       'ug_gid' => $group
                                ), $fname
                        );
                }
diff --git a/maintenance/archives/patch-rename-user_groups-and_rights.sql b/maintenance/archives/patch-rename-user_groups-and_rights.sql
new file mode 100644 (file)
index 0000000..288cedf
--- /dev/null
@@ -0,0 +1,9 @@
+
+ALTER TABLE user_groups
+       CHANGE user_id ug_uid INT(5) UNSIGNED NOT NULL DEFAULT '0',
+       CHANGE group_id ug_gid INT(5) UNSIGNED NOT NULL DEFAULT '0';
+
+ALTER TABLE user_rights
+       CHANGE user_id ur_uid INT(5) UNSIGNED NOT NULL,
+       CHANGE user_rights ur_rights TINYBLOB NOT NULL DEFAULT '';
+
index 5d799de..6f4095d 100644 (file)
@@ -6,8 +6,8 @@
 -- database but keep user rights local to the wiki.
 
 CREATE TABLE user_rights (
-       user_id int(5) unsigned NOT NULL,
-       user_rights tinyblob NOT NULL default '',
+       ur_uid int(5) unsigned NOT NULL,
+       ur_rights tinyblob NOT NULL default '',
        UNIQUE KEY user_id (user_id)
 ) PACK_KEYS=1;
 
index c21f78c..1a71900 100644 (file)
@@ -13,7 +13,7 @@ CREATE TABLE `group` (
 
 -- Relation table between user and groups
 CREATE TABLE user_groups (
-       user_id int(5) unsigned NOT NULL default '0',
-       group_id int(5) unsigned NOT NULL default '0',
-       PRIMARY KEY  (user_id,group_id)
+       ug_uid int(5) unsigned NOT NULL default '0',
+       ug_gid int(5) unsigned NOT NULL default '0',
+       PRIMARY KEY  (ug_uid,ug_gid)
 );
index 80780b9..a2c444e 100644 (file)
@@ -20,8 +20,8 @@ CREATE TABLE user (
 
 -- TODO: de-blob this; it should be a property table
 CREATE TABLE user_rights (
-  user_id int(5) unsigned NOT NULL,
-  user_rights tinyblob NOT NULL default '',
+  ur_uid int(5) unsigned NOT NULL,
+  ur_rights tinyblob NOT NULL default '',
   UNIQUE KEY user_id (user_id)
 );
 
@@ -352,7 +352,7 @@ CREATE TABLE `group` (
 
 -- Relation table between user and groups
 CREATE TABLE user_groups (
-       user_id int(5) unsigned NOT NULL default '0',
-       group_id int(5) unsigned NOT NULL default '0',
-       PRIMARY KEY  (user_id,group_id)
+       ug_uid int(5) unsigned NOT NULL default '0',
+       ug_gid int(5) unsigned NOT NULL default '0',
+       PRIMARY KEY  (ug_uid,ug_gid)
 );
index 3a2c6b8..de1ac33 100644 (file)
@@ -31,6 +31,7 @@ $wgNewFields = array(
        array( 'recentchanges', 'rc_patrolled',     'patch-rc-patrol.sql' ),
        array( 'user',          'user_real_name',   'patch-user-realname.sql' ),
        array( 'user',          'user_token',       'patch-user_token.sql' ),
+       array( 'user_rights',   'ur_uid',           'patch-rename-user_groups-and_rights.sql' ),
 );
 
 function add_table( $name, $patch ) {