From efca89ebbe7ac625a1d49db0015fc9d80e06ac93 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 3 Jun 2003 08:44:50 +0000 Subject: [PATCH] Refactor some common code for offsets/limits; some preliminary stuff for upload license notes and mysql4 fulltext support (not ready yet) --- includes/DefaultSettings.php | 2 ++ includes/GlobalFunctions.php | 20 +++++++++++ includes/SearchEngine.php | 44 ++++++++++++++++--------- includes/SpecialAncientpages.php | 7 +--- includes/SpecialContributions.php | 11 ++----- includes/SpecialImagelist.php | 9 +++-- includes/SpecialListusers.php | 8 ++--- includes/SpecialLonelypages.php | 7 +--- includes/SpecialLongpages.php | 7 +--- includes/SpecialMaintenance.php | 42 ++++------------------- includes/SpecialNewpages.php | 11 +------ includes/SpecialPopularpages.php | 9 ++--- includes/SpecialRecentchanges.php | 27 ++++++--------- includes/SpecialRecentchangeslinked.php | 11 +++---- includes/SpecialShortpages.php | 7 +--- includes/SpecialUnusedimages.php | 6 +--- includes/SpecialWantedpages.php | 7 +--- includes/SpecialWatchlist.php | 18 +++------- maintenance/archives/patch-list.txt | 5 +++ 19 files changed, 98 insertions(+), 160 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d3128abcfc..dccc36a351 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 05d4ea5b68..1b99cee95b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 ); +} + ?> diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 5276ed3941..7c66a2577e 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -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 { "

" . 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 ) { diff --git a/includes/SpecialAncientpages.php b/includes/SpecialAncientpages.php index c06f8c8bf5..dbdc5eb148 100644 --- a/includes/SpecialAncientpages.php +++ b/includes/SpecialAncientpages.php @@ -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) " . diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 4c0e64029b..1b5fdbb432 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -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( "
{$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

" . wfMsg( "nocontribs" ) . "

\n" ); return; } diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index 459b362d61..4c02240cb0 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -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( "

" . wfMsg( "imglegend" ) . "\n" ); - $text = str_replace( "$1", "{$lt}", - wfMsg( "imagelisttext" ) ); - $text = str_replace( "$2", "{$st}", $text ); + $text = wfMsg( "imagelisttext", + "{$lt}", "{$st}" ); $wgOut->addHTML( "

{$text}\n

" ); $sk = $wgUser->getSkin(); diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 3d9c098d85..7fb1bf0d12 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -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( "

{$top}\n" ); diff --git a/includes/SpecialLonelypages.php b/includes/SpecialLonelypages.php index ab7f937cb0..35db75360a 100644 --- a/includes/SpecialLonelypages.php +++ b/includes/SpecialLonelypages.php @@ -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 " . diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php index e45e22c79a..e1996138ad 100644 --- a/includes/SpecialLongpages.php +++ b/includes/SpecialLongpages.php @@ -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 " . diff --git a/includes/SpecialMaintenance.php b/includes/SpecialMaintenance.php index 9a830e4fba..fefc96b5eb 100644 --- a/includes/SpecialMaintenance.php +++ b/includes/SpecialMaintenance.php @@ -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}"; diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index dd7d5caf30..d6268e391c 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -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%' " . diff --git a/includes/SpecialPopularpages.php b/includes/SpecialPopularpages.php index 387ecbe6a7..628a528e45 100644 --- a/includes/SpecialPopularpages.php +++ b/includes/SpecialPopularpages.php @@ -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 = "

    "; 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 .= "
  1. {$link} ({$nv})
  2. \n"; } diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 1412193bc7..7b6daec188 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -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
    \n{$note}\n
    " ); $note = rcDayLimitLinks( $days, $limit ); $now = date( "YmdHis" ); - $note .= "
    \n" . str_replace( "$1", + $note .= "
    \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; } diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index 6625173a84..6f3f8dfff2 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -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( "
    \n{$note}\n
    " ); $tu = "target=" . $nt->getPrefixedURL(); diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index 76e18ed5e7..ffdd65fb0f 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -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 " . diff --git a/includes/SpecialUnusedimages.php b/includes/SpecialUnusedimages.php index 9157073acd..284394c9c7 100644 --- a/includes/SpecialUnusedimages.php +++ b/includes/SpecialUnusedimages.php @@ -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 " . diff --git a/includes/SpecialWantedpages.php b/includes/SpecialWantedpages.php index 7f125f8bb8..3dab5de760 100644 --- a/includes/SpecialWantedpages.php +++ b/includes/SpecialWantedpages.php @@ -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 diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index e9df9ef344..940a45a7e5 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -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
    \n{$note}\n
    " ); $note = rcDayLimitlinks( $days, $limit, "Watchlist", "", true ); $wgOut->addHTML( "{$note}\n" ); diff --git a/maintenance/archives/patch-list.txt b/maintenance/archives/patch-list.txt index a5f18540da..c16ec35b8b 100644 --- a/maintenance/archives/patch-list.txt +++ b/maintenance/archives/patch-list.txt @@ -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. -- 2.20.1