Merge "Fix TOC display for printing"
[lhc/web/wiklou.git] / includes / revisiondelete / RevisionDeleteUser.php
index 8de7485..4505ee1 100644 (file)
@@ -1,9 +1,6 @@
 <?php
 /**
- * Backend functions for suppressing and unsuppressing all references to a given user,
- * used when blocking with HideUser enabled.  This was spun out of SpecialBlockip.php
- * in 1.18; at some point it needs to be rewritten to either use RevisionDelete abstraction,
- * or at least schema abstraction.
+ * Backend functions for suppressing and unsuppressing all references to a given user.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * @file
  * @ingroup RevisionDelete
  */
+
+/**
+ * Backend functions for suppressing and unsuppressing all references to a given user,
+ * used when blocking with HideUser enabled.  This was spun out of SpecialBlockip.php
+ * in 1.18; at some point it needs to be rewritten to either use RevisionDelete abstraction,
+ * or at least schema abstraction.
+ *
+ * @ingroup RevisionDelete
+ */
 class RevisionDeleteUser {
 
        /**
@@ -30,14 +36,14 @@ class RevisionDeleteUser {
         * @param  $name String username
         * @param  $userId Int user id
         * @param  $op String operator '|' or '&'
-        * @param  $dbw null|Database, if you happen to have one lying around
+        * @param  $dbw null|DatabaseBase, if you happen to have one lying around
         * @return bool
         */
        private static function setUsernameBitfields( $name, $userId, $op, $dbw ) {
-               if( $op !== '|' && $op !== '&' ){
+               if ( !$userId || ( $op !== '|' && $op !== '&' ) ) {
                        return false; // sanity check
                }
-               if( !$dbw instanceof DatabaseBase ){
+               if ( !$dbw instanceof DatabaseBase ) {
                        $dbw = wfGetDB( DB_MASTER );
                }
 
@@ -48,7 +54,7 @@ class RevisionDeleteUser {
                # The same goes for the sysop-restricted *_deleted bit.
                $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
                $delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED;
-               if( $op == '&' ) {
+               if ( $op == '&' ) {
                        $delUser = "~{$delUser}";
                        $delAction = "~{$delAction}";
                }
@@ -110,9 +116,12 @@ class RevisionDeleteUser {
                );
 
                # Hide name from deleted images
-               # WMF - schema change pending
-               # $dbw->update( 'filearchive', array( "fa_deleted = fa_deleted $op $delUser" ),
-               #       array( 'fa_user_text' => $name ), __METHOD__ );
+               $dbw->update(
+                       'filearchive',
+                       array( "fa_deleted = fa_deleted $op $delUser" ),
+                       array( 'fa_user_text' => $name ),
+                       __METHOD__
+               );
                # Done!
                return true;
        }
@@ -124,4 +133,4 @@ class RevisionDeleteUser {
        public static function unsuppressUserName( $name, $userId, $dbw = null ) {
                return self::setUsernameBitfields( $name, $userId, '&', $dbw );
        }
-}
\ No newline at end of file
+}