* Add functionality of extension LinkSearch to core
[lhc/web/wiklou.git] / maintenance / userDupes.inc
index efe0118..86b70e3 100644 (file)
 #
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 # http://www.gnu.org/copyleft/gpl.html
 
+/**
+ * @file
+ * @ingroup Maintenance
+ */
+
 /**
  * Look for duplicate user table entries and optionally prune them.
+ * @ingroup Maintenance
  */
 class UserDupes {
        var $db;
@@ -46,7 +52,7 @@ class UserDupes {
                # Confusingly, 'Non_unique' is 0 for *unique* indexes,
                # and 1 for *non-unique* indexes. Pass the crack, MySQL,
                # it's obviously some good stuff!
-               return ( $info->Non_unique == 0 );
+               return ( $info[0]->Non_unique == 0 );
        }
 
        /**
@@ -74,15 +80,13 @@ class UserDupes {
         * not requested. (If doing resolution, edits may be reassigned.)
         * Status information will be echo'd to stdout.
         *
-        * @param bool $doDelete pass true to actually remove things
-        *                       from the database; false to just check.
+        * @param $doDelete bool: pass true to actually remove things
+        *                  from the database; false to just check.
         * @return bool
         */
        function checkDupes( $doDelete = false ) {
-               global $wgDBname;
-
                if( $this->hasUniqueIndex() ) {
-                       echo "$wgDBname already has a unique index on its user table.\n";
+                       echo wfWikiID()." already has a unique index on its user table.\n";
                        return true;
                }
 
@@ -92,7 +96,7 @@ class UserDupes {
                $dupes = $this->getDupes();
                $count = count( $dupes );
 
-               echo "Found $count accounts with duplicate records on $wgDBname.\n";
+               echo "Found $count accounts with duplicate records on ".wfWikiID().".\n";
                $this->trimmed    = 0;
                $this->reassigned = 0;
                $this->failed     = 0;
@@ -114,9 +118,9 @@ class UserDupes {
 
                if( $this->trimmed > 0 ) {
                        if( $doDelete ) {
-                               echo "$this->trimmed duplicate user records were deleted from $wgDBname.\n";
+                               echo "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n";
                        } else {
-                               echo "$this->trimmed duplicate user accounts were found on $wgDBname which can be removed safely.\n";
+                               echo "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n";
                        }
                }
 
@@ -148,7 +152,7 @@ class UserDupes {
                $names = array_map( array( $this, 'lockTable' ), $set );
                $tables = implode( ',', $names );
 
-               $result = $this->db->query( "LOCK TABLES $tables", $fname );
+               $this->db->query( "LOCK TABLES $tables", $fname );
        }
 
        function lockTable( $table ) {
@@ -168,7 +172,7 @@ class UserDupes {
         */
        function unlock() {
                $fname = 'UserDupes::unlock';
-               $result = $this->db->query( "UNLOCK TABLES", $fname );
+               $this->db->query( "UNLOCK TABLES", $fname );
        }
 
        /**
@@ -198,8 +202,8 @@ class UserDupes {
         * Examine user records for the given name. Try to see which record
         * will be the one that actually gets used, then check remaining records
         * for edits. If the dupes have no edits, we can safely remove them.
-        * @param string $name
-        * @param bool $doDelete
+        * @param $name string
+        * @param $doDelete bool
         * @access private
         */
        function examine( $name, $doDelete ) {
@@ -249,7 +253,7 @@ class UserDupes {
         * Count the number of edits attributed to this user.
         * Does not currently check log table or other things
         * where it might show up...
-        * @param int $userid
+        * @param $userid int
         * @return int
         * @access private
         */
@@ -264,9 +268,9 @@ class UserDupes {
 
        /**
         * Count the number of hits on a given table for this account.
-        * @param string $table
-        * @param string $field
-        * @param int $userid
+        * @param $table string
+        * @param $field string
+        * @param $userid int
         * @return int
         * @access private
         */
@@ -280,8 +284,8 @@ class UserDupes {
        }
 
        /**
-        * @param int $from
-        * @param int $to
+        * @param $from int
+        * @param $to int
         * @access private
         */
        function reassignEdits( $from, $to ) {
@@ -294,16 +298,16 @@ class UserDupes {
        }
 
        /**
-        * @param string $table
-        * @param string $field
-        * @param int $from
-        * @param int $to
+        * @param $table string
+        * @param $field string
+        * @param $from int
+        * @param $to int
         * @access private
         */
        function reassignEditsOn( $table, $field, $from, $to ) {
                $fname = 'UserDupes::reassignEditsOn';
                echo "reassigning on $table... ";
-               $result = $this->db->update( $table,
+               $this->db->update( $table,
                        array( $field => $to ),
                        array( $field => $from ),
                        $fname );
@@ -312,7 +316,7 @@ class UserDupes {
 
        /**
         * Remove a user account line.
-        * @param int $userid
+        * @param $userid int
         * @access private
         */
        function trimAccount( $userid ) {
@@ -323,6 +327,3 @@ class UserDupes {
        }
 
 }
-
-
-?>
\ No newline at end of file