https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103382

Revision: 103382
Author:   bawolff
Date:     2011-11-16 21:00:54 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
(bug 11685) - Make DynamicPageList limit parser cache to 24 hours by default 
(configurable) on pages using it's tag.

I think 24 hours is sane, but this should definitly be reviewed by someone 
familar with performance-y stuff before it gets deployed to make sure it won't 
blow things up.

(The reason for doing this is DPL does queries of categories, but doesn't check 
if those categories change, so in extreme cases it could have outdated dpl 
results on a page for several weeks. In practise this is rarely an issue (on 
enwikinews anyways), but does cause problems in certain circumstances.)

Modified Paths:
--------------
    trunk/extensions/intersection/DynamicPageList.php

Modified: trunk/extensions/intersection/DynamicPageList.php
===================================================================
--- trunk/extensions/intersection/DynamicPageList.php   2011-11-16 20:59:38 UTC 
(rev 103381)
+++ trunk/extensions/intersection/DynamicPageList.php   2011-11-16 21:00:54 UTC 
(rev 103382)
@@ -54,11 +54,16 @@
 // Parser tests
 $wgParserTestFiles[] = $dir . 'DynamicPageList.tests.txt';
 
-# Configuration variables
+# Configuration variables. Warning: These use DLP instead of DPL
+# for historical reasons (pretend Dynamic list of pages)
 $wgDLPmaxCategories = 6;                // Maximum number of categories to 
look for
 $wgDLPMaxResultCount = 200;             // Maximum number of results to allow
 $wgDLPAllowUnlimitedResults = false;    // Allow unlimited results
 $wgDLPAllowUnlimitedCategories = false; // Allow unlimited categories
+// How long to cache pages using DPL's in seconds. Default to 1 day. Set to
+// false to not decrease cache time (most efficient), Set to 0 to disable
+// cache altogether (inefficient, but results will never be outdated)
+$wgDLPMaxCacheTime = 60*60*24;          // How long to cache pages
 
 $wgHooks['ParserFirstCallInit'][] = 'wfDynamicPageList';
 /**
@@ -73,12 +78,16 @@
 }
 
 // The callback function for converting the input text to HTML output
-function renderDynamicPageList( $input ) {
+function renderDynamicPageList( $input, $args, $mwParser ) {
        global $wgUser, $wgContLang;
        global $wgDisableCounters; // to determine if to allow sorting by #hits.
-       global $wgDLPmaxCategories, $wgDLPMaxResultCount;
+       global $wgDLPmaxCategories, $wgDLPMaxResultCount, $wgDLPMaxCacheTime;
        global $wgDLPAllowUnlimitedResults, $wgDLPAllowUnlimitedCategories;
 
+       if ( $wgDLPMaxCacheTime !== false ) {
+               $mwParser->getOutput()->updateCacheExpiry( $wgDLPMaxCacheTime );
+       }
+
        $countSet = false;
 
        $startList = '<ul>';


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to