--- a/includes/paths.php Mon Jul 07 02:50:17 2008 -0400
+++ b/includes/paths.php Mon Jul 07 18:12:30 2008 -0400
@@ -157,6 +157,7 @@
{
global $db, $session, $paths, $template, $plugins; // Common objects
global $lang;
+ global $cache;
$code = $plugins->setHook('paths_init_before');
foreach ( $code as $cmd )
@@ -164,16 +165,9 @@
eval($cmd);
}
- $cache_enable = ( getConfig('cache_thumbs') == '1' );
- $cache_file = ENANO_ROOT . '/cache/cache_page_meta.php';
- $cache_fresh = ( file_exists($cache_file) ) ? filemtime($cache_file) + 1800 >= time() : false;
- if ( $cache_enable && $cache_fresh )
+ if ( $page_cache = $cache->fetch('page_meta') )
{
- require($cache_file);
- if ( isset($page_cache) && is_array($page_cache) )
- {
- $this->pages = array_merge($this->pages, $page_cache);
- }
+ $this->pages = array_merge($this->pages, $page_cache);
}
else
{
@@ -192,10 +186,7 @@
$this->pages[] =& $this->pages[$r['urlname']];
}
- if ( $cache_enable )
- {
- $this->update_metadata_cache();
- }
+ $this->update_metadata_cache();
}
$db->free_result();
if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_UPGRADE') )
@@ -585,36 +576,27 @@
{
global $db, $session, $paths, $template, $plugins; // Common objects
- $cache_output = <<<EOF
-<?php
-
-/**
- * Automatically generated cache of page metadata. Do not edit this file as it is updated every 20 minutes.
- */
-
-\$page_cache = array(
-EOF;
+ if ( getConfig('cache_thumbs') != '1' )
+ return false;
+
$e = $db->sql_unbuffered_query('SELECT name,urlname,namespace,special,visible,comments_on,protected,delvotes,' . "\n"
. ' delvote_ips,wiki_mode,password FROM '.table_prefix.'pages ORDER BY name;');
if ( !$e )
$db->_die();
+ $md_array = array();
+
while ( $row = $db->fetchrow() )
{
$row = $this->calculate_metadata_from_row($row);
- $key = addslashes($row['urlname']);
- $row = substr(preg_replace('/^/m', ' ', Language::var_export_string($row)), 2);
- $cache_output .= "\n '$key' => $row,";
+ $md_array[$row['urlname']] = $row;
}
- $cache_output .= "\n);\n";
- $cache_file = ENANO_ROOT . '/cache/cache_page_meta.php';
+ // import cache functions
+ global $cache;
- $fh = @fopen($cache_file, 'w');
- if ( !$fh )
- return false;
- fwrite($fh, $cache_output);
- fclose($fh);
+ // store data (TTL 20 minutes)
+ $cache->store('page_meta', $md_array, 20);
return true;
}