Back out r41001 for the moment ("Add log_user_text. Useful for log dumps, which are...
[lhc/web/wiklou.git] / maintenance / refreshLinks.php
index e25b09b..4893d58 100644 (file)
@@ -1,46 +1,53 @@
 <?php
-define( "REPORTING_INTERVAL", 500 );
+/**
+ * @file
+ * @ingroup Maintenance
+ */
+
+/** */
+$optionsWithArgs = array( 'm', 'e' );
+
+require_once( "commandLine.inc" );
+require_once( "refreshLinks.inc" );
+
+if( isset( $options['help'] ) ) {
+       echo <<<TEXT
+Usage:
+    php refreshLinks.php --help
+    php refreshLinks.php [<start>] [-e <end>] [-m <maxlag>] [--dfn-only]
+                         [--new-only] [--redirects-only]
+    php refreshLinks.php [<start>] [-e <end>] [-m <maxlag>] --old-redirects-only
+
+    --help               : This help message
+    --dfn-only           : Delete links from nonexistent articles only
+    --new-only           : Only affect articles with just a single edit
+    --redirects-only     : Only fix redirects, not all links
+    --old-redirects-only : Only fix redirects with no redirect table entry
+    -m <number>          : Maximum replication lag
+    <start>              : First page id to refresh
+    -e <number>          : Last page id to refresh
+
+TEXT;
+       exit(0);
+}
 
-include_once( "commandLine.inc" );
 error_reporting( E_ALL & (~E_NOTICE) );
 
+if ( !$options['dfn-only'] ) {
+       if ( isset( $args[0] ) ) {
+               $start = (int)$args[0];
+       } else {
+               $start = 1;
+       }
 
-if ($argv[2]) {
-       $start = (int)$argv[2];
-} else {
-       $start = 1;
+       refreshLinks( $start, $options['new-only'], $options['m'], $options['e'], $options['redirects-only'], $options['old-redirects-only'] );
 }
+// this bit's bad for replication: disabling temporarily
+// --brion 2005-07-16
+//deleteLinksFromNonexistent();
 
-$res = wfQuery("SELECT max(cur_id) as m FROM cur", DB_READ);
-$row = wfFetchObject( $res );
-$end = $row->m;
-
-print("Refreshing link table. Starting from cur_id $start of $end.\n");
-
-# Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
-$wgUser->setOption("math", 3);
-
-for ($id = $start; $id <= $end; $id++) {
-       if ( !($id % REPORTING_INTERVAL) ) {
-               print "$id\n";
-       }
-       
-       $wgTitle = Title::newFromID( $id );
-       if ( is_null( $wgTitle ) ) {
-               continue;
-       }
-       
-       $wgLinkCache = new LinkCache;
-       $wgArticle = new Article( $wgTitle );
-       $text = $wgArticle->getContent( true );
-       @$wgOut->addWikiText( $text );
-       
-       $wgLinkCache->saveToLinkscc();
-       $linksUpdate = new LinksUpdate( $id, $wgTitle );
-       $linksUpdate->doDumbUpdate();
-       $linksUpdate->fixBrokenLinks();
+if ( $options['globals'] ) {
+       print_r( $GLOBALS );
 }
 
-exit();
 
-?>