ported refreshLinks.php improvements (and associated change to commandLine.inc and...
[lhc/web/wiklou.git] / maintenance / refreshLinks.php
index 6177de6..f37c8e8 100644 (file)
@@ -1,54 +1,26 @@
 <?php
-define( "REPORTING_INTERVAL", 50 );
-define( "PAUSE_INTERVAL", 50 );
+/**
+ * @todo document
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
 
-include_once( "commandLine.inc" );
-error_reporting( E_ALL & (~E_NOTICE) );
-
-
-if ($argv[2]) {
-       $start = (int)$argv[2];
-} else {
-       $start = 1;
-}
-
-$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);
+/** */
+$optionsWithArgs = array( 'm' );
+require_once( "commandLine.inc" );
+require_once( "refreshLinks.inc" );
 
-for ($id = $start; $id <= $end; $id++) {
-       if ( !($id % REPORTING_INTERVAL) ) {
-               print "$id\n";
-       }
-
-       if ( !($id % PAUSE_INTERVAL) ) {
-               sleep(1);
-       }
-       
-       $wgTitle = Title::newFromID( $id );
-       if ( is_null( $wgTitle ) ) {
-               continue;
-       }
-       
-       $wgArticle = new Article( $wgTitle );
-       $text = $wgArticle->getContent( true );
-       $wgLinkCache = new LinkCache;
-       @$wgOut->addWikiText( $text );
+error_reporting( E_ALL & (~E_NOTICE) );
 
-       if ( $wgEnablePersistentLC ) {
-               $wgLinkCache->saveToLinkscc( $id, wfStrencode( $wgTitle->getPrefixedDBkey() ) );
+if ( !$options['dfn-only'] ) {
+       if ($args[0]) {
+               $start = (int)$args[0];
+       } else {
+               $start = 1;
        }
 
-       $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() );
-       $linksUpdate->doDumbUpdate();
-       $linksUpdate->fixBrokenLinks();
+       refreshLinks( $start, $options['new-only'], $options['m'] );
 }
-
-exit();
+deleteLinksFromNonexistent();
 
 ?>