Index: branches/wmf/1.17wmf1/maintenance/wmf/fixUsabilityPrefs.php |
— | — | @@ -0,0 +1,91 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require( dirname( __FILE__ ) . '/../Maintenance.php' ); |
| 5 | + |
| 6 | +class FixUsabilityPrefs extends Maintenance { |
| 7 | + function __construct() { |
| 8 | + parent::__construct(); |
| 9 | + } |
| 10 | + |
| 11 | + function execute() { |
| 12 | + $dbw = wfGetDB( DB_MASTER ); |
| 13 | + |
| 14 | + echo "Fixing usebetatoolbar\n"; |
| 15 | + |
| 16 | + $batchSize = 100; |
| 17 | + $allIds = array(); |
| 18 | + while ( true ) { |
| 19 | + $dbw->begin(); |
| 20 | + $res = $dbw->select( 'user_properties', array( 'up_user' ), |
| 21 | + array( 'up_property' => 'usebetatoolbar', 'up_value' => '' ), |
| 22 | + __METHOD__, |
| 23 | + array( 'LIMIT' => $batchSize, 'FOR UPDATE' ) ); |
| 24 | + if ( !$res->numRows() ) { |
| 25 | + $dbw->commit(); |
| 26 | + break; |
| 27 | + } |
| 28 | + |
| 29 | + $ids = array(); |
| 30 | + foreach ( $res as $row ) { |
| 31 | + $ids[] = $row->up_user; |
| 32 | + } |
| 33 | + $dbw->delete( 'user_properties', |
| 34 | + array( 'up_property' => 'usebetatoolbar', 'up_user' => $ids ), |
| 35 | + __METHOD__ ); |
| 36 | + $dbw->commit(); |
| 37 | + $allIds = array_merge( $allIds, $ids ); |
| 38 | + wfWaitForSlaves( 10 ); |
| 39 | + } |
| 40 | + |
| 41 | + echo "Fixing wikieditor-*\n"; |
| 42 | + |
| 43 | + $likeWikieditor = $dbw->buildLike( 'wikieditor-', $dbw->anyString() ); |
| 44 | + while ( true ) { |
| 45 | + $dbw->begin(); |
| 46 | + $res = $dbw->select( 'user_properties', array( 'DISTINCT up_user' ), |
| 47 | + array( "up_property $likeWikieditor" ), |
| 48 | + __METHOD__, |
| 49 | + array( 'LIMIT' => $batchSize, 'FOR UPDATE' ) ); |
| 50 | + if ( !$res->numRows() ) { |
| 51 | + $dbw->commit(); |
| 52 | + break; |
| 53 | + } |
| 54 | + |
| 55 | + $ids = array(); |
| 56 | + foreach ( $res as $row ) { |
| 57 | + $ids[] = $row->up_user; |
| 58 | + } |
| 59 | + $dbw->delete( 'user_properties', |
| 60 | + array( "up_property $likeWikieditor", 'up_user' => $ids ), |
| 61 | + __METHOD__ ); |
| 62 | + $dbw->commit(); |
| 63 | + $allIds = array_merge( $allIds, $ids ); |
| 64 | + wfWaitForSlaves( 10 ); |
| 65 | + } |
| 66 | + |
| 67 | + $allIds = array_unique( $allIds ); |
| 68 | + |
| 69 | + echo "Invalidating user cache\n"; |
| 70 | + $i = 0; |
| 71 | + foreach ( $allIds as $id ) { |
| 72 | + $user = User::newFromId( $id ); |
| 73 | + if ( !$user->isLoggedIn() ) { |
| 74 | + continue; |
| 75 | + } |
| 76 | + $dbw->begin(); |
| 77 | + $user->invalidateCache(); |
| 78 | + $dbw->commit(); |
| 79 | + $i++; |
| 80 | + if ( $i % 1000 == 0 ) { |
| 81 | + wfWaitForSlaves( 10 ); |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + echo "Done\n"; |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +$maintClass = 'FixUsabilityPrefs'; |
| 90 | +require_once( DO_MAINTENANCE ); |
| 91 | + |
| 92 | + |
Property changes on: branches/wmf/1.17wmf1/maintenance/wmf/fixUsabilityPrefs.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 93 | + native |