jenkins-bot has submitted this change and it was merged.

Change subject: Fix some stupid mistakes in cleanupSkinPrefs
......................................................................


Fix some stupid mistakes in cleanupSkinPrefs

- Need '' to ignore default settings
- Silly variable typos
- Don't check for int-style skins in bogus check, it
  causes false counts and is already handled above

Change-Id: I69e34b0fd1e3fb81054dddfa8085701ba3dc1bc7
---
M cleanupSkinPrefs.php
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/cleanupSkinPrefs.php b/cleanupSkinPrefs.php
index 3fe5122..453d312 100644
--- a/cleanupSkinPrefs.php
+++ b/cleanupSkinPrefs.php
@@ -50,6 +50,8 @@
 
                # Current skins
                $currentSkins = array_keys( Skin::getSkinNames() );
+               # Plus an empty string for "default"
+               $currentSkins[] = '';
 
                $dbr = wfGetDB( DB_SLAVE );
                $dbw = wfGetDB( DB_MASTER );
@@ -59,7 +61,7 @@
                $res = (int)$dbr->selectField( 'user_properties', 'COUNT(*) as 
count',
                        array( 'up_property' => 'skin', 'up_value' => 
array_keys( $cleanupMap ) ), __METHOD__ );
                $this->output( "$res users with old integer-style skin 
preferences\n" );
-               if( !$countOnly && $count > 0 ) {
+               if( !$countOnly && $res > 0 ) {
                        $this->output( "Updating..." );
                        foreach( $cleanupMap as $old => $new ) {
                                $dbw->update( 'user_properties', array( 
'up_value' => $new ),
@@ -69,13 +71,14 @@
                        $this->output( "done.\n" );
                }
 
+               $dontChange = array_merge( $currentSkins, array_keys( 
$cleanupMap ) );
                $res = (int)$dbr->selectField( 'user_properties', 'COUNT(*) as 
count',
-                       array( 'up_property' => 'skin', 'up_value NOT IN (' . 
$dbr->makeList( $currentSkins ) . ')' ), __METHOD__ );
+                       array( 'up_property' => 'skin', 'up_value NOT IN (' . 
$dbr->makeList( $dontChange ) . ')' ), __METHOD__ );
                $this->output( "$res users with bogus skin properties\n" );
-               if( !$countOnly && $count > 0 ) {
+               if( !$countOnly && $res > 0 ) {
                        $this->output( "Updating..." );
                        $dbw->delete( 'user_properties',
-                               array( 'up_property' => 'skin', 'up_value NOT 
IN (' . $dbw->makeList( $currentSkins ) . ')' ), __METHOD__ );
+                               array( 'up_property' => 'skin', 'up_value NOT 
IN (' . $dbw->makeList( $dontChange ) . ')' ), __METHOD__ );
                        $this->output( "done.\n" );
                }
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/53176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I69e34b0fd1e3fb81054dddfa8085701ba3dc1bc7
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikimediaMaintenance
Gerrit-Branch: master
Gerrit-Owner: Demon <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: OliverKeyes <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to