From 5d4d87e957068b54e2b12abcea5c74bb4f3c012c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 19:58:14 -0700 Subject: Remove the digibug maintenance task. Expired imges will be removed when the print_proxy is run. --- modules/digibug/controllers/digibug.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules/digibug/controllers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 72b57242..25a9912a 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -76,6 +76,8 @@ class Digibug_Controller extends Controller { // We don't need to save the session for this request Session::abort_save(); + $this->_clean_expired(); + // Dump out the image header("Content-Type: $proxy->item->mime_type"); Kohana::close_buffers(false); @@ -92,4 +94,19 @@ class Digibug_Controller extends Controller { public function close_window() { print ""; } + + private function _clean_expired() { + $expired = ORM::factory("digibug_proxy") + ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") + ->find_all(); + + // Delete as many as we can in a second, so as to not slow up the request. + $start = microtime(true); + foreach ($expired as $proxy) { + if (microtime(true) - $start > 1.0) { + break; + } + $proxy->delete(); + } + } } \ No newline at end of file -- cgit v1.2.3