01177: Add a mechanism to disable internal $acache

Summary: Add a mechanism to disable internal $acache
Created: 2010-03-08 18:21
Status: Open
Category: CoreCandidate
From: DaveG
Assigned:
Priority: 4
Version: 2.2.8
OS:

Description: Provide a mechanism to turn internal $acache off.

Problem

There are instances where users or recipes make early calls which populate internal caching mechanisms (like the $acache). Subsequent calls which would normally populate additional data do not alter the content of the cache, and cause problems for users and recipes.

The suggestion is for functions which cache operations to accept a parameter disabling the caching operation for that call, or to use a global flag to turn caching on and off.

Suggestion 1

The following code snippet by Peter Bowers provides a flag EnableAuthCache which turns the $achache off. Code has been tested by DaveG and appears to work, but additional investigation is needed to ensure no further reaching effects.

function PmWikiAuth($pagename, $level, $authprompt=true, $since=0) {
  global $DefaultPasswords, $GroupAttributesFmt, $AllowPassword,
    $AuthCascade, $FmtV, $AuthPromptFmt, $PageStartFmt, $PageEndFmt,
    $AuthId, $AuthList, $NoHTMLCache;

  // START changes
  global $EnableAuthCache; // included in the line above - put here for clarity
  static $bcache; // probably ought to be a more sensible name :-)
  #static $acache;
  SDV($EnableAuthCache, true);
  if ($EnableAuthCache) $acache = &$bcache;
  else $acache = $bcache;
  // END changes

  SDV($GroupAttributesFmt,'$Group/GroupAttributes');

and:

  if (!$authprompt) return false;
  $GLOBALS['AuthNeeded'] = (@$_POST['authpw'])
    ? $page['=pwsource'][$level] . ' ' . $level : '';

  // START changes
  if ($EnableAuthCache)
    PCache($pagename, $page);
  // END changes

  $postvars = '';
  foreach($_POST as $k=>$v) {
    if ($k == 'authpw' || $k == 'authid') continue;