Last modified: 2014-08-23 17:32:40 UTC
This bug tracks the request to write and run a maintenance script on Wikimedia wikis to clean up the skin user preferences. Many skins no longer exist. Many users are storing unneeded values, causing the table to be bloated (cf. bug 52777). As noted at bug 45179 comment 15, [[Wikipedia:Database reports/User preferences#Skin]] has been messy since it was created. It'd be great to see it cleaned up. The database report currently looks something like this: Skin Users MediaWiki:Skinname- 7190151 MediaWiki:Skinname-0 54155 MediaWiki:Skinname-1 1763 MediaWiki:Skinname-2 3075 MediaWiki:Skinname-amethyst 1292 MediaWiki:Skinname-chick 32061 Cologne Blue 80642 Modern 69010 MonoBook 2185224 MediaWiki:Skinname-myskin 16285 Nostalgia 21256 MediaWiki:Skinname-on 16 MediaWiki:Skinname-simple 14245 MediaWiki:Skinname-standard 34502 Vector 166182
effectively: DELETE FROM user_preferences WHERE up_property = 'skin' AND up_value NOT IN Skin::getSkinNames() > var_dump( Skin::getSkinNames() ); array(4) { ["monobook"]=> string(8) "MonoBook" ["vector"]=> string(6) "Vector" ["modern"]=> string(6) "Modern" ["cologneblue"]=> string(11) "CologneBlue" } But the up_values need lowercasing to match Wouldn't take too much to write a script to do something like that...
What about the Skinname- (is this just 'no preference'?), Skinname-0, Skinname-1, and Skinname-2? Are the numeric ones interpreted as actual skins? If so, they should be converted over to the names.
(In reply to comment #2) > What about the Skinname- (is this just 'no preference'?), Skinname-0, > Skinname-1, and Skinname-2? Are the numeric ones interpreted as actual > skins? > If so, they should be converted over to the names. Skinname- was possibly "default" a long time ago. Or a database artifact. In any case, it's invalid and these users are currently getting Vector. Skinname-[0-2] used to refer to specific skins, they do have a 1:1 mapping. The ones that point to skins that are still around can be converted, others are using Vector and can be removed. I wrote a script that does all of this...someone should just run it across all wikis :)
Thank you for volunteering, Chad ;).
(In reply to comment #3) > I wrote a script that does all of this...someone should just run it across > all wikis :) Can you post or link to this?
(In reply to comment #4) > Thank you for volunteering, Chad ;). Get me a window and I'll be more than happy to. (In reply to comment #5) > (In reply to comment #3) > > I wrote a script that does all of this...someone should just run it across > > all wikis :) > > Can you post or link to this? That would be the "cleanupSkinPrefs" script in the WikimediaMaintenance extension. Here you go: https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FWikimediaMaintenance.git/HEAD/cleanupSkinPrefs.php
(In reply to comment #6) > (In reply to comment #5) > > (In reply to comment #3) > > > I wrote a script that does all of this...someone should just run it across > > > all wikis :) > > > > Can you post or link to this? > > That would be the "cleanupSkinPrefs" script in the WikimediaMaintenance > extension. Here you go: > https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FWikimediaMaintenance. > git/HEAD/cleanupSkinPrefs.php That's not batched though...
(In reply to comment #7) > (In reply to comment #6) > > (In reply to comment #5) > > > (In reply to comment #3) > > > > I wrote a script that does all of this...someone should just run it across > > > > all wikis :) > > > > > > Can you post or link to this? > > > > That would be the "cleanupSkinPrefs" script in the WikimediaMaintenance > > extension. Here you go: > > https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FWikimediaMaintenance. > > git/HEAD/cleanupSkinPrefs.php > > That's not batched though... Really the only wiki that maybe needs batching is enwiki. The rest have a minuscule number of rows to update.
There's the DELETE part too.. Both should be easily updated to use batched queries Our delete wrapper in it's current form doesn't take options... Ideally do { $res = $dbw->delete( 'user_properties', array( 'up_property' => 'skin', 'up_value NOT IN (' . $dbw->makeList( $dontChange ) . ')' ), __METHOD__, array( 'LIMIT' => 50 ) ); wfWaitForSlaves(); } while ( $res->numRows() === 50 ); but in the current state... Ugh. do { $res = $dbw->query( "DELETE FROM user_properties WHERE up_property='skin' AND up_value NOT IN ({$dbw->makeList( $dontChange )}) LIMIT 50", __METHOD__ ); wfWaitForSlaves(); } while ( $res->numRows() === 50 ); Logging a bug for it!
(In reply to comment #9) > There's the DELETE part too.. Both should be easily updated to use batched > queries > > Our delete wrapper in it's current form doesn't take options... > "DELETE ...LIMIT" isn't part of the standard, and it's only supported in MySQL and Sqlite :)
(In reply to comment #6) > That would be the "cleanupSkinPrefs" script in the WikimediaMaintenance > extension. Here you go: > https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FWikimediaMaintenance.git/HEAD/cleanupSkinPrefs.php Nice to see that there's a script for this (or a start to one). :-) It's in the wrong place, though. The most natural place to find such a script would be in the maintenance directory of MediaWiki core (this is where I looked after Matt posted his question in comment 6). Other wikis will want to clean out their skin preferences as well, presumably. There's nothing Wikimedia-specific about this, as far as I can tell, so the WikimediaMaintenance extension is simply the wrong place for this script.