Index: trunk/extensions/WikimediaMaintenance/cleanupBug31576.php |
— | — | @@ -30,12 +30,19 @@ |
31 | 31 | $pCount = 0; |
32 | 32 | $vCount = 0; |
33 | 33 | $this->output( "Fixing pages with template links to $synonym ...\n" ); |
| 34 | + $from = null; |
34 | 35 | while ( true ) { |
| 36 | + $where = array( |
| 37 | + 'tl_namespace' => NS_TEMPLATE, |
| 38 | + 'tl_title ' . $dbr->buildLike( $synonym, $dbr->anyString() ) |
| 39 | + ); |
| 40 | + if ( $from !== null ) { |
| 41 | + $where[] = 'tl_from > ' . $dbr->addQuotes( $from ); |
| 42 | + $from = null; |
| 43 | + } |
35 | 44 | $res = $dbr->select( 'templatelinks', array( 'tl_title', 'tl_from' ), |
36 | | - array( |
37 | | - 'tl_namespace' => NS_TEMPLATE, |
38 | | - 'tl_title' => $synonym |
39 | | - ), __METHOD__, |
| 45 | + $where, |
| 46 | + __METHOD__, |
40 | 47 | array( 'ORDER BY' => array( 'tl_title', 'tl_from' ), 'LIMIT' => $this->batchsize ) |
41 | 48 | ); |
42 | 49 | if ( $dbr->numRows( $res ) == 0 ) { |
— | — | @@ -53,6 +60,9 @@ |
54 | 61 | $this->processed[$row->tl_from] = true; |
55 | 62 | $pCount++; |
56 | 63 | } |
| 64 | + if ( isset( $row ) ) { |
| 65 | + $from = $row->tl_from; |
| 66 | + } |
57 | 67 | $this->output( "{$pCount}/{$vCount} pages processed\n" ); |
58 | 68 | wfWaitForSlaves(); |
59 | 69 | } |