r41712 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41711‎ | r41712 | r41713 >
Date:23:28, 5 October 2008
Author:aaron
Status:old
Tags:
Comment:
Fix empty protection row check to avoid adding dead rows; remove any existing ones (bug 15832)
Modified paths:
  • /trunk/phase3/maintenance/updateRestrictions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updateRestrictions.php
@@ -37,18 +37,19 @@
3838 $encodedExpiry = 'infinity';
3939 while ( $blockEnd <= $end ) {
4040 echo "...doing page_id from $blockStart to $blockEnd\n";
41 - $cond = "page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !='' AND page_restrictions !='edit=:move='";
 41+ $cond = "page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !=''";
4242 $res = $db->select( 'page', array('page_id', 'page_restrictions'), $cond, __FUNCTION__ );
4343 $batch = array();
4444 while ( $row = $db->fetchObject( $res ) ) {
4545 $oldRestrictions = array();
4646 foreach( explode( ':', trim( $row->page_restrictions ) ) as $restrict ) {
4747 $temp = explode( '=', trim( $restrict ) );
48 - if(count($temp) == 1) {
 48+ // Make sure we are not settings restrictions to ""
 49+ if( count($temp) == 1 && $temp[0] ) {
4950 // old old format should be treated as edit/move restriction
5051 $oldRestrictions["edit"] = trim( $temp[0] );
5152 $oldRestrictions["move"] = trim( $temp[0] );
52 - } else {
 53+ } else if( $temp[1] ) {
5354 $oldRestrictions[$temp[0]] = trim( $temp[1] );
5455 }
5556 }
@@ -77,6 +78,10 @@
7879 $blockEnd += BATCH_SIZE - 1;
7980 wfWaitForSlaves( 5 );
8081 }
 82+ echo "...removing dead rows from page_restrictions\n";
 83+ // Kill any broken rows from previous imports
 84+ $db->delete( 'page_restrictions', array( 'pr_level' => '' ) );
 85+ echo "...Done!\n";
8186 }
8287
8388

Status & tagging log