Index: trunk/phase3/maintenance/refreshLinks.inc |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | define( "REPORTING_INTERVAL", 100 ); |
10 | 10 | #define( "REPORTING_INTERVAL", 1 ); |
11 | 11 | |
12 | | -function refreshLinks( $start, $newOnly = false, $maxLag = false, $end = 0 ) { |
| 12 | +function refreshLinks( $start, $newOnly = false, $maxLag = false, $end = 0, $redirectsOnly = false ) { |
13 | 13 | global $wgUser, $wgParser, $wgUseImageResize, $wgUseTidy; |
14 | 14 | |
15 | 15 | $fname = 'refreshLinks'; |
— | — | @@ -25,8 +25,10 @@ |
26 | 26 | $wgUseImageResize = false; |
27 | 27 | $wgUseTidy = false; |
28 | 28 | |
| 29 | + $what = ($redirectsOnly)? "redirects" : "links"; |
| 30 | + |
29 | 31 | if ( $newOnly ) { |
30 | | - print "Refreshing links from "; |
| 32 | + print "Refreshing $what from "; |
31 | 33 | $res = $dbr->select( 'page', |
32 | 34 | array( 'page_id' ), |
33 | 35 | array( |
— | — | @@ -43,11 +45,13 @@ |
44 | 46 | print "$i\n"; |
45 | 47 | wfWaitForSlaves( $maxLag ); |
46 | 48 | } |
47 | | - |
48 | | - fixLinksFromArticle( $row->page_id ); |
| 49 | + if($redirectsOnly) |
| 50 | + fixRedirect( $row->page_id ); |
| 51 | + else |
| 52 | + fixLinksFromArticle( $row->page_id ); |
49 | 53 | } |
50 | 54 | } else { |
51 | | - print "Refreshing link table.\n"; |
| 55 | + print "Refreshing $what table.\n"; |
52 | 56 | if ( !$end ) { |
53 | 57 | $end = $dbr->selectField( 'page', 'max(page_id)', false ); |
54 | 58 | } |
— | — | @@ -59,11 +63,33 @@ |
60 | 64 | print "$id\n"; |
61 | 65 | wfWaitForSlaves( $maxLag ); |
62 | 66 | } |
63 | | - fixLinksFromArticle( $id ); |
| 67 | + if($redirectsOnly) |
| 68 | + fixRedirect( $id ); |
| 69 | + else |
| 70 | + fixLinksFromArticle( $id ); |
64 | 71 | } |
65 | 72 | } |
66 | 73 | } |
67 | 74 | |
| 75 | +function fixRedirect( $id ){ |
| 76 | + global $wgTitle, $wgArticle; |
| 77 | + |
| 78 | + $wgTitle = Title::newFromID( $id ); |
| 79 | + $dbw = wfGetDB( DB_MASTER ); |
| 80 | + |
| 81 | + if ( is_null( $wgTitle ) ) { |
| 82 | + return; |
| 83 | + } |
| 84 | + $wgArticle = new Article($wgTitle); |
| 85 | + |
| 86 | + $rt = $wgArticle->followRedirect(); |
| 87 | + |
| 88 | + if($rt == false || !is_object($rt)) |
| 89 | + return; |
| 90 | + |
| 91 | + $wgArticle->updateRedirectOn($dbw,$rt); |
| 92 | +} |
| 93 | + |
68 | 94 | function fixLinksFromArticle( $id ) { |
69 | 95 | global $wgTitle, $wgParser; |
70 | 96 | |
Index: trunk/phase3/maintenance/refreshLinks.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | $start = 1; |
20 | 20 | } |
21 | 21 | |
22 | | - refreshLinks( $start, $options['new-only'], $options['m'], $options['e'] ); |
| 22 | + refreshLinks( $start, $options['new-only'], $options['m'], $options['e'], $options['redirects-only'] ); |
23 | 23 | } |
24 | 24 | // this bit's bad for replication: disabling temporarily |
25 | 25 | // --brion 2005-07-16 |