FIX: Clear DataObject cache when loading each page (Fixes #10)

Include performance figures in the export log for reference.
This commit is contained in:
Will Rossiter 2013-06-08 13:57:57 +12:00
parent 20e3e5f019
commit 48e3ed9d35
2 changed files with 12 additions and 1 deletions

View File

@ -53,6 +53,7 @@ class StaticExporter extends Controller {
public function export() {
if(isset($_REQUEST['baseurl'])) {
$base = $_REQUEST['baseurl'];
if(substr($base,-1) != '/') $base .= '/';
@ -137,6 +138,8 @@ class StaticExporter extends Controller {
// Run the page
Requirements::clear();
$link = Director::makeRelative($obj->Link());
DataObject::flush_and_destroy_cache();
$response = Director::test($link);
// Write to file

View File

@ -5,6 +5,7 @@
class StaticExporterTask extends BuildTask {
public function run($request) {
$now = microtime(true);
$export = new StaticExporter();
$url = $request->getVar('baseurl');
@ -21,6 +22,13 @@ class StaticExporterTask extends BuildTask {
if(!$quiet) printf("Exporting website with %s base URL... %s", $url, PHP_EOL);
$path = $export->doExport($url, $folder, $symlink, $quiet);
if(!$quiet) printf("Completed. Website exported to %s. %s", $path, PHP_EOL);
if(!$quiet) {
printf("\nWebsite exported to %s\nTotal time %s\nMemory used %s. %s",
$path,
number_format(microtime(true) - $now, 2) . 's',
number_format(memory_get_peak_usage() / 1024 / 1024, 2) .'mb',
PHP_EOL
);
}
}
}