[Mediawiki-l] wfStrencode & wfQuery

John Moorhouse john.moorhouse at 3jays.me.uk
Mon Jan 22 18:51:13 UTC 2007

I'm working on moving a number of Wiki's to V1.9 and have hit a problem 
with the kWBreadCrumbs extension, which is complaining about both 
wfStrencode & wfQuery functions, I've tried the various suggestions 
about replacing wfStrencode with addQuotes() but I'm rather out of my 
depth. The rest of the extension works with 1.9  (I've dot it running 
without the kwBreadCrumbsNoCache function, any help would be 
appreciated, as I'm out of my depth here, I've added the function code 
to this email. If I can get it working I'll add it back into the 
extensions list if this is felt appropriate.



function kwBreadCrumbsNoCache()
  global $wgTitle, $wgOut;
  if (!isset($wgTitle) || !isset($wgOut))

    Let's 'touch' the page to invalidate its cache.
    The code below is slightly identical to Title::invalidateCache().
    Even though invalidateCache() sets cur_touched to 'now', we are still
    in the process of creating and rendering the page itself and the
    page will be cached only once it is done. At the end of the day the
    cache would always end up newer than cur_touched, defeating the whole
    purpose of calling invalidateCache().
    The trick here is to set cur_touched in the future, something not too
    intrusive, say 'now' + 120 seconds, provided that we expect the cached
    page to be created within 120 secs after this extension code has been
    executed. That way, cur_touched remains 'fresher' than the cache, and
    the page is always re-created dynamically.

  $ts = mktime();
  $now = gmdate("YmdHis", $ts + 120);
  $ns = $wgTitle->getNamespace();
  $ti = wfStrencode($wgTitle->getDBkey());
  $sql = "UPDATE pett_page SET page_touched='$now' WHERE 
page_namespace=$ns AND page_title='$ti'";
  wfQuery($sql, DB_WRITE, "kwBreadCrumbsNoCache");
  // This does not seem to do anything. I assume once it's called here
  // in the extension, it's already too late.


  // The followings should prevent browsers to cache too long

  $wgOut->addMeta("http:Pragma", "no-cache");
  $wgOut->addMeta("http:no-cache", NULL);
  $wgOut->addMeta("http:EXPIRES", "TUES, 31 DEC 1996 12:00:00 GMT");

  // HTTP_IF_MODIFIED_SINCE ? // see OutputPage: checkLastModified

More information about the MediaWiki-l mailing list