diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-03-03 14:56:33 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-03-03 14:56:33 +0000 |
commit | e527bc6f4cf7ad81ee9344d271336ab106a27c28 (patch) | |
tree | d523bfa4546376ba55141e1b888ff2813be159ca /phpBB/includes/acm/acm_file.php | |
parent | cfd02dedee4dcd7e7ddad8ae16c659614149e7cb (diff) | |
download | forums-e527bc6f4cf7ad81ee9344d271336ab106a27c28.tar forums-e527bc6f4cf7ad81ee9344d271336ab106a27c28.tar.gz forums-e527bc6f4cf7ad81ee9344d271336ab106a27c28.tar.bz2 forums-e527bc6f4cf7ad81ee9344d271336ab106a27c28.tar.xz forums-e527bc6f4cf7ad81ee9344d271336ab106a27c28.zip |
this change should be a performance boost on destroying the sql cache... took several seconds before. This is especially noticeable on updating groups and permissions and may also fix the "blank screen" bugs.
git-svn-id: file:///svn/phpbb/trunk@7111 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/acm/acm_file.php')
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index e5ffe16d72..9e53b5af59 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -231,7 +231,10 @@ class acm if ($var_name == 'sql' && !empty($table)) { - $regex = '(' . ((is_array($table)) ? implode('|', $table) : $table) . ')'; + if (!is_array($table)) + { + $table = array($table); + } $dir = @opendir($this->cache_dir); @@ -247,11 +250,25 @@ class acm continue; } - $fp = fopen($this->cache_dir . $entry, 'rb'); - $file = fread($fp, filesize($this->cache_dir . $entry)); - @fclose($fp); + // The following method is more failproof than simply assuming the query is on line 3 (which it should be) + + // Get 1 KiB, we do not expect a query string to be any larger... + $check_line = file_get_contents($this->cache_dir . $entry, false, NULL, 5, 1024); + + // Now get the contents between /* and */ + $check_line = substr($check_line, strpos($check_line, '/* ') + 3, strpos($check_line, ' */') - strpos($check_line, '/* ') - 3); + + $found = false; + foreach ($table as $check_table) + { + if (strpos($check_line, $check_table . ' ') !== false) + { + $found = true; + break; + } + } - if (preg_match('#/\*.*?\W' . $regex . '\W.*?\*/#s', $file, $m)) + if ($found) { @unlink($this->cache_dir . $entry); } @@ -364,7 +381,7 @@ class acm } $db->sql_freeresult($query_result); - $file = "<?php\n\n/*\n" . str_replace('*/', '*\/', $query) . "\n*/\n"; + $file = "<?php\n\n/* " . str_replace('*/', '*\/', $query) . " */\n"; $file .= "\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n"; fwrite($fp, $file . "\n\$this->sql_rowset[\$query_id] = " . var_export($this->sql_rowset[$query_id], true) . ";\n?>"); |