r23928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23927‎ | r23928 | r23929 >
Date:23:38, 9 July 2007
Author:rainman
Status:old
Tags:
Comment:
Add --redirects-only switch to refreshLinks.php, which refreshes the redirect table, maybe this should be done by default as well.
Modified paths:
  • /trunk/phase3/maintenance/refreshLinks.inc (modified) (history)
  • /trunk/phase3/maintenance/refreshLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/refreshLinks.inc
@@ -8,7 +8,7 @@
99 define( "REPORTING_INTERVAL", 100 );
1010 #define( "REPORTING_INTERVAL", 1 );
1111
12 -function refreshLinks( $start, $newOnly = false, $maxLag = false, $end = 0 ) {
 12+function refreshLinks( $start, $newOnly = false, $maxLag = false, $end = 0, $redirectsOnly = false ) {
1313 global $wgUser, $wgParser, $wgUseImageResize, $wgUseTidy;
1414
1515 $fname = 'refreshLinks';
@@ -25,8 +25,10 @@
2626 $wgUseImageResize = false;
2727 $wgUseTidy = false;
2828
 29+ $what = ($redirectsOnly)? "redirects" : "links";
 30+
2931 if ( $newOnly ) {
30 - print "Refreshing links from ";
 32+ print "Refreshing $what from ";
3133 $res = $dbr->select( 'page',
3234 array( 'page_id' ),
3335 array(
@@ -43,11 +45,13 @@
4446 print "$i\n";
4547 wfWaitForSlaves( $maxLag );
4648 }
47 -
48 - fixLinksFromArticle( $row->page_id );
 49+ if($redirectsOnly)
 50+ fixRedirect( $row->page_id );
 51+ else
 52+ fixLinksFromArticle( $row->page_id );
4953 }
5054 } else {
51 - print "Refreshing link table.\n";
 55+ print "Refreshing $what table.\n";
5256 if ( !$end ) {
5357 $end = $dbr->selectField( 'page', 'max(page_id)', false );
5458 }
@@ -59,11 +63,33 @@
6064 print "$id\n";
6165 wfWaitForSlaves( $maxLag );
6266 }
63 - fixLinksFromArticle( $id );
 67+ if($redirectsOnly)
 68+ fixRedirect( $id );
 69+ else
 70+ fixLinksFromArticle( $id );
6471 }
6572 }
6673 }
6774
 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+
6894 function fixLinksFromArticle( $id ) {
6995 global $wgTitle, $wgParser;
7096
Index: trunk/phase3/maintenance/refreshLinks.php
@@ -18,7 +18,7 @@
1919 $start = 1;
2020 }
2121
22 - refreshLinks( $start, $options['new-only'], $options['m'], $options['e'] );
 22+ refreshLinks( $start, $options['new-only'], $options['m'], $options['e'], $options['redirects-only'] );
2323 }
2424 // this bit's bad for replication: disabling temporarily
2525 // --brion 2005-07-16

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log