summaryrefslogtreecommitdiff
path: root/inc/parserutils.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2011-01-10 23:41:43 +0100
committerMichael Hamann <michael@content-space.de>2011-01-10 23:41:43 +0100
commitff725173bf45c47b1ed9778524710cce72b1d42d (patch)
treea322f070790173653b7abe69812677b925d7586b /inc/parserutils.php
parent517a47eca3a26afd3aedfd47eb372596af4029ae (diff)
downloadrpg-ff725173bf45c47b1ed9778524710cce72b1d42d.tar.gz
rpg-ff725173bf45c47b1ed9778524710cce72b1d42d.tar.bz2
Add define for metadata usage limit in p_get_first_heading
This commit introduces a new define P_GET_FIRST_HEADING_METADATA_LIMIT that can be set in preload.php in order to change the limit for how many pages the first heading shall be loaded from metadata in p_get_first_heading. Changing this is probably most interesting for Wikis with a lot of pages where loading the title index costs a significant amount of time and memory.
Diffstat (limited to 'inc/parserutils.php')
-rw-r--r--inc/parserutils.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/inc/parserutils.php b/inc/parserutils.php
index b7359d7ef..6e349e984 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -10,6 +10,13 @@
if(!defined('DOKU_INC')) die('meh.');
/**
+ * For how many different pages shall the first heading be loaded from the
+ * metadata? When this limit is reached the title index is loaded and used for
+ * all following requests.
+ */
+if (!defined('P_GET_FIRST_HEADING_METADATA_LIMIT')) define('P_GET_FIRST_HEADING_METADATA_LIMIT', 10);
+
+/**
* Returns the parsed Wikitext in XHTML for the given id and revision.
*
* If $excuse is true an explanation is returned if the file
@@ -629,7 +636,7 @@ function & p_get_renderer($mode) {
*/
function p_get_first_heading($id, $render=true){
// counter how many titles have been requested using p_get_metadata
- static $count = 0;
+ static $count = 1;
// the index of all titles, only loaded when many titles are requested
static $title_index = null;
// cache for titles requested using p_get_metadata
@@ -643,7 +650,7 @@ function p_get_first_heading($id, $render=true){
// check if already too many titles have been requested and probably
// using the title index is better
- if ($count > 10) {
+ if ($count > P_GET_FIRST_HEADING_METADATA_LIMIT) {
if (is_null($title_index)) {
$pages = array_map('rtrim', idx_getIndex('page', ''));
$titles = array_map('rtrim', idx_getIndex('title', ''));