5 function get( &$article, &$user ){
6 $hash = $user->getPageRenderingHash();
7 $pageid = intval( $id );
8 $res = wfQuery("SELECT pc_data FROM parsercache WHERE pc_pageid = {$pageid} ".
9 " AND pc_prefhash = '{$hash}' AND pc_expire > NOW()", DB_WRITE
);
10 $row = wfFetchObject ( $res );
12 $retVal = unserialize( gzuncompress($row->pc_data
) );
13 wfProfileOut( $fname );
20 function save( $parserOutput, &$article, &$user ){
21 $hash = $user->getPageRenderingHash();
22 $pageid = intval( $article->getID() );
23 $title = wfStrencode( $article->mTitle
->getPrefixedDBKey() );
24 $ser = addslashes( gzcompress( serialize( $parserOutput ) ) );
25 if( $parserOutput->containsOldMagic() ){
31 wfQuery("REPLACE INTO parsercache (pc_prefhash,pc_pageid,pc_title,pc_data, pc_expire) ".
32 "VALUES('{$hash}', {$pageid}, '{$title}', '{$ser}', ".
33 "DATE_ADD(NOW(), INTERVAL {$expire}))", DB_WRITE
);
35 if( rand() %
50 == 0 ){ // more efficient to just do it sometimes
41 wfQuery("DELETE FROM parsercache WHERE pc_expire < NOW() LIMIT 250", DB_WRITE
);
44 function clearLinksTo( $pid ){
45 $pid = intval( $pid );
46 wfQuery("DELETE parsercache FROM parsercache,links ".
47 "WHERE pc_pageid=links.l_from AND l_to={$pid}", DB_WRITE
);
48 wfQuery("DELETE FROM parsercache WHERE pc_pageid='{$pid}'", DB_WRITE
);
51 # $title is a prefixed db title, for example like Title->getPrefixedDBkey() returns.
52 function clearBrokenLinksTo( $title ){
53 $title = wfStrencode( $title );
54 wfQuery("DELETE parsercache FROM parsercache,brokenlinks ".
55 "WHERE pc_pageid=bl_from AND bl_to='{$title}'", DB_WRITE
);
59 function clearPage( $pid, $namespace ){
60 $pid = intval( $pid );
61 if( $namespace == NS_MEDIAWIKI
){
62 $this->clearLinksTo( $pid );
64 wfQuery("DELETE FROM parsercache WHERE pc_pageid='{$pid}'", DB_WRITE
);