Refactor some common code for offsets/limits; some preliminary stuff for upload licen...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 3 Jun 2003 08:44:50 +0000 (08:44 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 3 Jun 2003 08:44:50 +0000 (08:44 +0000)
19 files changed:
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/SearchEngine.php
includes/SpecialAncientpages.php
includes/SpecialContributions.php
includes/SpecialImagelist.php
includes/SpecialListusers.php
includes/SpecialLonelypages.php
includes/SpecialLongpages.php
includes/SpecialMaintenance.php
includes/SpecialNewpages.php
includes/SpecialPopularpages.php
includes/SpecialRecentchanges.php
includes/SpecialRecentchangeslinked.php
includes/SpecialShortpages.php
includes/SpecialUnusedimages.php
includes/SpecialWantedpages.php
includes/SpecialWatchlist.php
maintenance/archives/patch-list.txt

index d3128ab..dccc36a 100644 (file)
@@ -33,6 +33,7 @@ $wgDBsqluser          = "sqluser";
 $wgDBsqlpassword       = "sqlpass";
 $wgDBminWordLen     = 4;
 $wgDBtransactions      = false; # Set to true if using InnoDB tables
+$wgDBmysql4                    = false; # Set to true to use enhanced fulltext search
 
 # Language settings
 #
@@ -44,6 +45,7 @@ $wgOutputEncoding     = "ISO-8859-1";
 $wgEditEncoding                = "";
 $wgDocType          = "-//W3C//DTD HTML 4.01 Transitional//EN";
 $wgAmericanDates = false;      # Enable for English module to print dates
+                                                       # as eg 'May 12' instead of '12 May'
 $wgLocalInterwiki   = "w";
 $wgShowIPinHeader      = true; # For non-logged in users
 
index 05d4ea5..1b99cee 100644 (file)
@@ -515,4 +515,24 @@ function wfClientAcceptsGzip() {
        return false;
 }
 
+# Yay, more global functions!
+function wfCheckLimits( $deflimit = 50, $optionname = "rclimit" ) {
+       global $wgUser;
+       
+       $limit = (int)$_REQUEST['limit'];
+       if( $limit < 0 ) $limit = 0;
+       if( ( $limit == 0 ) && ( $optionname != "" ) ) {
+               $limit = (int)$wgUser->getOption( $optionname );
+       }
+       if( $limit <= 0 ) $limit = $deflimit;
+       if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
+       
+       $offset = (int)$_REQUEST['offset'];
+       $offset = (int)$offset;
+       if( $offset < 0 ) $offset = 0;
+       if( $offset > 65000 ) $offset = 65000; # do we need a max? what?
+       
+       return array( $limit, $offset );
+}
+
 ?>
index 5276ed3..7c66a25 100644 (file)
@@ -14,7 +14,9 @@ class SearchEngine {
        {
                # We display the query, so let's strip it for safety
                #
+               global $wgDBmysql4;
                $lc = SearchEngine::legalSearchChars() . "()";
+               if( $wgDBmysql4 ) $lc .= "\"~<>*+-";
                $this->mUsertext = trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
                $this->mSearchterms = array();
        }
@@ -112,23 +114,19 @@ class SearchEngine {
                global $wgUser, $wgTitle, $wgOut, $wgLang, $wgDisableTextSearch;
                $fname = "SearchEngine::showResults";
 
-               $offset         = $_REQUEST['offset'];
-               $limit          = $_REQUEST['limit'];
                $search         = $_REQUEST['search'];
 
                $powersearch = $this->powersearch(); /* Need side-effects here? */
 
                $wgOut->setPageTitle( wfMsg( "searchresults" ) );
-               $q = str_replace( "$1", $this->mUsertext,
-                 wfMsg( "searchquery" ) );
+               $q = wfMsg( "searchquery", htmlspecialchars( $this->mUsertext ) );
                $wgOut->setSubtitle( $q );
                $wgOut->setArticleFlag( false );
                $wgOut->setRobotpolicy( "noindex,nofollow" );
 
                $sk = $wgUser->getSkin();
-               $text = str_replace( "$1", $sk->makeKnownLink(
-                 wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ),
-                 wfMsg( "searchresulttext" ) );
+               $text = wfMsg( "searchresulttext", $sk->makeKnownLink(
+                 wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ) );
                $wgOut->addHTML( $text );
 
                $this->parseQuery();
@@ -137,11 +135,7 @@ class SearchEngine {
                          "<p>" . wfMsg( "badquerytext" ) );
                        return;
                }
-               if ( ! isset( $limit ) ) {
-                       $limit = $wgUser->getOption( "searchlimit" );
-                       if ( ! $limit ) { $limit = 20; }
-               }
-               if ( ! $offset ) { $offset = 0; }
+               list( $limit, $offset ) = wfCheckLimits( 20, "searchlimit" );
 
                $searchnamespaces = $this->queryNamespaces();
                $redircond = $this->searchRedirects();
@@ -237,7 +231,12 @@ class SearchEngine {
 
        function parseQuery()
        {
-               global $wgDBminWordLen, $wgLang;
+               global $wgDBminWordLen, $wgLang, $wgDBmysql4;
+
+               if( $wgDBmysql4 ) {
+                       # Use cleaner boolean search if available
+                       return $this->parseQuery4();
+               }
 
                $lc = SearchEngine::legalSearchChars() . "()";
                $q = preg_replace( "/([()])/", " \\1 ", $this->mUsertext );
@@ -265,15 +264,28 @@ class SearchEngine {
                }
                if ( 0 == count( $this->mSearchterms ) ) { return; }
 
-               # To disable boolean:
-               # $cond = "MATCH (##field##) AGAINST('" . wfStrencode( $q ) . "')";
-
                $this->mTitlecond = "(" . str_replace( "##field##",
                  "si_title", $cond ) . " )";
 
                $this->mTextcond = "(" . str_replace( "##field##",
                  "si_text", $cond ) . " AND (cur_is_redirect=0) )";
        }
+       
+       function parseQuery4()
+       {
+               # FIXME: not ready yet! Do not use.
+               
+               global $wgLang;
+               $lc = SearchEngine::legalSearchChars();
+               #$q = preg_replace( "/([+-]?)([$lc]+)/e",
+               #       "\"$1\" . \$wgLang->stripForSearch(\"$2\")",
+               #       $this->mUsertext );
+               
+               $q = $this->mUsertext;
+               $qq = wfStrencode( $q );
+               $this->mTitlecond = " MATCH(si_title) AGAINST('$qq' IN BOOLEAN MODE)";
+               $this->mTextcond = " (MATCH(si_text) AGAINST('$qq' IN BOOLEAN MODE) AND cur_is_redirect=0)";
+       }
 
        function showHit( $row )
        {
index c06f8c8..dbdc5eb 100644 (file)
@@ -3,14 +3,9 @@
 function wfSpecialAncientpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialAncientpages";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title,cur_user,cur_user_text,cur_comment," .
          "cur_timestamp FROM cur USE INDEX (namespace_redirect_timestamp) " .
index 4c0e640..1b5fdbb 100644 (file)
@@ -2,7 +2,7 @@
 
 function wfSpecialContributions()
 {
-       global $wgUser, $wgOut, $wgLang, $target, $offset, $limit, $hideminor;
+       global $wgUser, $wgOut, $wgLang, $target, $hideminor;
        $fname = "wfSpecialContributions";
        $sysop = $wgUser->isSysop();
 
@@ -10,10 +10,7 @@ function wfSpecialContributions()
                $wgOut->errorpage( "notargettitle", "notargettext" );
                return;
        }
-       $offset = (int)$offset;
-       $limit = (int)$limit;
-       if( $offset < 0 ) { $offset = 0; }
-       if( $limit < 1 ) { $limit = 50; }
+       list( $limit, $offset ) = wfCheckLimits( 50, "" );
 
        $target = wfCleanQueryVar( $target );
        $nt = Title::newFromURL( $target );
@@ -44,8 +41,6 @@ function wfSpecialContributions()
          $wgLang->specialpage( "Contributions" ), "target=" . wfUrlEncode( $target ) );
        $wgOut->addHTML( "<br>{$sl}\n" );
        
-       # Sorting slowness on cur and especially old
-       # forces us to check RC table first
        if ( 0 == $id ) {
                $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment FROM cur " .
                  "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
@@ -69,7 +64,7 @@ function wfSpecialContributions()
        $nOld = wfNumRows( $res2 );
 
 
-       if ( 0 == $nCur && 0 == $nOld && 0 == $rcrows ) {
+       if ( 0 == $nCur && 0 == $nOld ) {
                $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
                return;
        }
index 459b362..4c02240 100644 (file)
@@ -2,7 +2,7 @@
 
 function wfSpecialImagelist()
 {
-       global $wgUser, $wgOut, $wgLang, $sort, $limit;
+       global $wgUser, $wgOut, $wgLang, $sort;
        global $wpIlMatch, $wpIlSubmit;
 
        $fields = array( 'wpIlMatch' );
@@ -32,7 +32,7 @@ function wfSpecialImagelist()
                $sql .= " ORDER BY img_timestamp DESC";
                $st = $bydate;
        }
-       if ( ! isset( $limit ) ) { $limit = 50; }
+       list( $limit, $offset ) = wfCheckLimits( 50 );
        if ( 0 == $limit ) {
                $lt = wfMsg( "all" );
        } else {
@@ -41,9 +41,8 @@ function wfSpecialImagelist()
        }
        $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "\n" );
 
-       $text = str_replace( "$1", "<strong>{$lt}</strong>",
-         wfMsg( "imagelisttext" ) );
-       $text = str_replace( "$2", "<strong>{$st}</strong>", $text );
+       $text = wfMsg( "imagelisttext",
+               "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
        $wgOut->addHTML( "<p>{$text}\n<p>" );
 
        $sk = $wgUser->getSkin();
index 3d9c098..7fb1bf0 100644 (file)
@@ -2,13 +2,9 @@
 
 function wfSpecialListusers()
 {
-       global $wgUser, $wgOut, $wgLang, $offset, $limit;
+       global $wgUser, $wgOut, $wgLang;
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $top = wfShowingResults( $offset, $limit );
        $wgOut->addHTML( "<p>{$top}\n" );
index ab7f937..35db753 100644 (file)
@@ -3,7 +3,6 @@
 function wfSpecialLonelypages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialLonelypages";
 
        # Cache
@@ -17,11 +16,7 @@ function wfSpecialLonelypages()
                return;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title FROM cur LEFT JOIN links ON " .
          "cur_id=l_to WHERE l_to IS NULL AND cur_namespace=0 AND " .
index e45e22c..e199613 100644 (file)
@@ -3,7 +3,6 @@
 function wfSpecialLongpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialLongpages";
 
        # Cache
@@ -17,11 +16,7 @@ function wfSpecialLongpages()
                return;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
          "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
index 9a830e4..fefc96b 100644 (file)
@@ -85,14 +85,9 @@ function getMaintenancePageBacklink()
 function wfSpecialDisambiguations()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialDisambiguations";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $dp = wfStrencode( wfMsg("disambiguationspage") );
 
@@ -139,14 +134,9 @@ function wfSpecialDisambiguations()
 function wfSpecialDoubleRedirects()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialDoubleRedirects";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT l_from,l_to,cb.cur_text AS rt,cb.cur_title AS ti FROM links,cur AS ca, cur AS cb WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id AND l_from=ca.cur_title AND ca.cur_namespace=0 LIMIT {$offset}, {$limit}" ;
 
@@ -180,14 +170,9 @@ function wfSpecialDoubleRedirects()
 function wfSpecialBrokenRedirects()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialBrokenRedirects";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT bl_to,cur_title FROM brokenlinks,cur WHERE cur_is_redirect=1 AND cur_namespace=0 AND bl_from=cur_id LIMIT {$offset}, {$limit}" ;
 
@@ -219,14 +204,9 @@ function wfSpecialBrokenRedirects()
 function wfSpecialSelfLinks()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialSelfLinks";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title FROM cur,links WHERE cur_is_redirect=0 AND cur_namespace=0 AND l_from=cur_title AND l_to=cur_id LIMIT {$offset}, {$limit}";
 
@@ -254,15 +234,10 @@ function wfSpecialSelfLinks()
 function wfSpecialMispeelings ()
 {
         global $wgUser, $wgOut, $wgLang, $wgTitle;
-        global $limit, $offset; # From query string
         $sk = $wgUser->getSkin();
         $fname = "wfSpecialMispeelings";
 
-        if ( ! $limit ) {
-                $limit = $wgUser->getOption( "rclimit" );
-                if ( ! $limit ) { $limit = 50; }
-        }
-        if ( ! $offset ) { $offset = 0; }
+               list( $limit, $offset ) = wfCheckLimits();
 
         # Determine page name
         $ms = wfMsg ( "mispeelingspage" ) ;
@@ -327,16 +302,11 @@ function wfSpecialMispeelings ()
 function wfSpecialMissingLanguageLinks()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle, $thelang, $subfunction;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialMissingLanguageLinks";
        $subfunction = "missinglanguagelinks" ;
        if ( $thelang == "w" ) $thelang = "en" ; # Fix for international wikis
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' LIMIT {$offset}, {$limit}";
 
index dd7d5ca..d6268e3 100644 (file)
@@ -3,19 +3,10 @@
 function wfSpecialNewpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialNewpages";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
-#      $sql = "SELECT cur_title,cur_user,cur_user_text,cur_comment," .
-#        "cur_timestamp FROM cur " .
-#        "WHERE cur_is_new=1 AND cur_namespace=0 AND cur_is_redirect=0 " .
-#        " ORDER BY cur_timestamp DESC LIMIT {$offset}, {$limit}";
        $sql = "SELECT rc_title AS cur_title,rc_user AS cur_user,rc_user_text AS cur_user_text,cur_comment," .
          "rc_timestamp AS cur_timestamp,length(cur_text) as cur_length FROM recentchanges,cur " .
          "WHERE rc_cur_id=cur_id AND rc_new=1 AND rc_namespace=0 AND cur_text NOT LIKE '#REDIRECT%' " .
index 387ecbe..628a528 100644 (file)
@@ -3,7 +3,6 @@
 function wfSpecialPopularpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialPopularpages";
 
        global $wgMiserMode;
@@ -12,11 +11,7 @@ function wfSpecialPopularpages()
                return;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT DISTINCT cur_title, cur_counter FROM cur " .
          "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
@@ -34,7 +29,7 @@ function wfSpecialPopularpages()
 
        $s = "<ol start=" . ( $offset + 1 ) . ">";
        while ( $obj = wfFetchObject( $res ) ) {
-               $nv = str_replace( "$1", $obj->cur_counter, wfMsg( "nviews" ) );
+               $nv = wfMsg( "nviews", $obj->cur_counter );
                $link = $sk->makeKnownLink( $obj->cur_title, "" );
                $s .= "<li>{$link} ({$nv})</li>\n";
        }
index 1412193..7b6daec 100644 (file)
@@ -3,7 +3,7 @@
 function wfSpecialRecentchanges()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $days, $limit, $hideminor, $from, $hidebots; # From query string
+       global $days, $hideminor, $from, $hidebots; # From query string
        $fname = "wfSpecialRecentchanges";
 
        $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
@@ -23,10 +23,8 @@ function wfSpecialRecentchanges()
                $days = $wgUser->getOption( "rcdays" );
                if ( ! $days ) { $days = 3; }
        }
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 100; }
-       }
+       $days = (int)$days;
+       list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
        $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
        if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
                $cutoff = $from;
@@ -65,21 +63,19 @@ function wfSpecialRecentchanges()
        $res = wfQuery( $sql2, $fname );
 
        if(isset($from)) {
-               $note = str_replace( "$1", $limit, wfMsg( "rcnotefrom" ) );
-               $note = str_replace( "$2", $wgLang->timeanddate( $from, true ), $note );
+               $note = wfMsg( "rcnotefrom", $limit,
+                       $wgLang->timeanddate( $from, true ) );
        } else {
-               $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
-               $note = str_replace( "$2", $days, $note );
+               $note = wfMsg( "rcnote", $limit, $days );
        }
        $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
 
        $note = rcDayLimitLinks( $days, $limit );
 
        $now = date( "YmdHis" );
-       $note .= "<br>\n" . str_replace( "$1",
+       $note .= "<br>\n" . wfMsg( "rclistfrom",
          $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
-         $wgLang->timeanddate( $now, true ), "from=$now" ),
-         wfMsg( "rclistfrom" ) );
+         $wgLang->timeanddate( $now, true ), "from=$now" ) );
 
        $wgOut->addHTML( "{$note}\n" );
 
@@ -150,9 +146,7 @@ function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall
          rcDaysLink( $limit, 14, $page, $more  ) . " | " .
          rcDaysLink( $limit, 30, $page, $more  ) .
          ( $doall ? ( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
-       $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
-       $note = str_replace( "$2", $dl, $note );
-       $note = str_replace( "$3", $mlink, $note );
+       $note = wfMsg( "rclinks", $cl, $dl, $mlink );
        return $note;
 }
 
@@ -164,8 +158,7 @@ function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
          rcCountLink( 250, 0, $page, $more  ) . " | " .
          rcCountLink( 500, 0, $page, $more  ) .
          ( $doall ? ( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
-       $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
-       $note = str_replace( "$3", $mlink, $note );
+       $note = wfMsg( "rclinks", $cl, "", $mlink );
        return $note;
 }
 
index 6625173..6f3f8df 100644 (file)
@@ -5,7 +5,7 @@ include_once( "$IP/SpecialRecentchanges.php" );
 function wfSpecialRecentchangeslinked()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $days, $limit, $target, $hideminor; # From query string
+       global $days, $target, $hideminor; # From query string
        $fname = "wfSpecialRecentchangeslinked";
 
        $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
@@ -23,10 +23,8 @@ function wfSpecialRecentchangeslinked()
                $days = $wgUser->getOption( "rcdays" );
                if ( ! $days ) { $days = 7; }
        }
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 100; }
-       }
+       $days = (int)$days;
+       list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
        $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
 
        if ( ! isset( $hideminor ) ) {
@@ -52,8 +50,7 @@ function wfSpecialRecentchangeslinked()
          "ORDER BY inverse_timestamp LIMIT {$limit}";
        $res = wfQuery( $sql, $fname );
 
-       $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
-       $note = str_replace( "$2", $days, $note );
+       $note = wfMsg( "rcnote", $limit, $days );
        $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
 
        $tu = "target=" . $nt->getPrefixedURL();
index 76e18ed..ffdd65f 100644 (file)
@@ -3,7 +3,6 @@
 function wfSpecialShortpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialShortpages";
 
        # Cache
@@ -17,11 +16,7 @@ function wfSpecialShortpages()
                return;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
          "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
index 9157073..284394c 100644 (file)
@@ -6,11 +6,7 @@ function wfSpecialUnusedimages()
        global $limit, $offset; # From query string
        $fname = "wfSpecialUnusedimages";
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $sql = "SELECT img_name,img_user,img_user_text,img_timestamp,img_description " .
          "FROM image LEFT JOIN imagelinks ON img_name=il_to WHERE il_to IS NULL " .
index 7f125f8..3dab5de 100644 (file)
@@ -5,7 +5,6 @@ include_once ( "LogPage.php" ) ;
 function wfSpecialWantedpages()
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialWantedpages";
 
        # Cache
@@ -20,11 +19,7 @@ function wfSpecialWantedpages()
                return;
        }
 
-       if ( ! $limit ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 50; }
-       }
-       if ( ! $offset ) { $offset = 0; }
+       list( $limit, $offset ) = wfCheckLimits();
 
        $cache = "" ; # To be saved, eventually
 
index e9df9ef..940a45a 100644 (file)
@@ -17,11 +17,10 @@ function wfSpecialWatchlist()
                $days = $wgUser->getOption( "rcdays" );
                if ( ! $days ) { $days = 3; }
        }
-       if ( ! isset( $limit ) ) {
-               $limit = $wgUser->getOption( "rclimit" );
-               if ( ! $limit ) { $limit = 100; }
-       }
-       if ( $days == 0 ) {
+       $days = (int)$days;
+       list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
+       
+       if ( $days <= 0 ) {
                $docutoff = '';
        } else {
                $docutoff = "cur_timestamp > '" .
@@ -40,12 +39,6 @@ function wfSpecialWatchlist()
                return;
        }
 
-#      $sql = "SELECT DISTINCT
-#  cur_id,cur_namespace,cur_title,cur_comment,
-#  cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
-#  FROM cur,watchlist
-#  WHERE wl_user={$uid} AND wl_namespace=cur_namespace & (~1) AND wl_title=cur_title
-#  ORDER BY cur_timestamp DESC {$dolimit}";
        $sql = "SELECT DISTINCT
   cur_id,cur_namespace,cur_title,cur_comment,
   cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
@@ -59,8 +52,7 @@ function wfSpecialWatchlist()
                return;
        }
 
-       $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
-       $note = str_replace( "$2", $days, $note );
+       $note = wfMsg( "rcnote", $limit, $days );
        $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
        $note = rcDayLimitlinks( $days, $limit, "Watchlist", "", true );
        $wgOut->addHTML( "{$note}\n" );
index a5f1854..c16ec35 100644 (file)
@@ -104,8 +104,13 @@ Run patch-cache.sql on the database to set these fields up. This is
 required for changes to OutputPage.php and elsewhere to continue
 working on an older database.
 
+
 * 2003-05-23: Index for "Oldest articles"
 "Oldest articles" needs an index on namespace, redirect and timestamp
 to be reasonably fast. (patch-oldestindex.sql)
 
 OutputPage.php User.php maintenance/buildTables.inc maintenance/patch-cache.sql maintenance/patch-list.txt
+
+
+* 2003-05-30: File upload license fields
+Adds fields to 'image' table.