From 73ab75b3e0b5da26203e275c6641eacef0531729 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 13 Aug 2013 00:00:58 +0200 Subject: remove caching code from history Simply enabling it again would cause breakage (json handling). Just get rid of it. Signed-off-by: Florian Pritz --- application/controllers/file.php | 113 ++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 61 deletions(-) (limited to 'application/controllers/file.php') diff --git a/application/controllers/file.php b/application/controllers/file.php index 7629b809b..e931e4078 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -448,77 +448,68 @@ class File extends CI_Controller { $user = $this->muser->get_userid(); - $this->load->library("MemcacheLibrary"); - if (! $cached = $this->memcachelibrary->get("history_".$this->var->view_dir."_".$user)) { - $query = array(); - $lengths = array(); - - // key: database field name; value: display name - $fields = array( - "id" => "ID", - "filename" => "Filename", - "mimetype" => "Mimetype", - "date" => "Date", - "hash" => "Hash", - "filesize" => "Size" - ); - - $this->data['title'] .= ' - Upload history'; - foreach($fields as $length_key => $value) { - $lengths[$length_key] = mb_strlen($value); - } + $query = array(); + $lengths = array(); + + // key: database field name; value: display name + $fields = array( + "id" => "ID", + "filename" => "Filename", + "mimetype" => "Mimetype", + "date" => "Date", + "hash" => "Hash", + "filesize" => "Size" + ); - $order = is_cli_client() ? "ASC" : "DESC"; + $this->data['title'] .= ' - Upload history'; + foreach($fields as $length_key => $value) { + $lengths[$length_key] = mb_strlen($value); + } - $query = $this->db->query(" - SELECT ".implode(",", array_keys($fields))." - FROM files - WHERE user = ? - ORDER BY date $order - ", array($user))->result_array(); + $order = is_cli_client() ? "ASC" : "DESC"; - if ($this->input->get("json") !== false) { - return send_json_reply($query); - } + $query = $this->db->query(" + SELECT ".implode(",", array_keys($fields))." + FROM files + WHERE user = ? + ORDER BY date $order + ", array($user))->result_array(); - foreach($query as $key => $item) { - $query[$key]["filesize"] = format_bytes($item["filesize"]); - if (is_cli_client()) { - // Keep track of longest string to pad plaintext output correctly - foreach($fields as $length_key => $value) { - $len = mb_strlen($query[$key][$length_key]); - if ($len > $lengths[$length_key]) { - $lengths[$length_key] = $len; - } + if ($this->input->get("json") !== false) { + return send_json_reply($query); + } + + foreach($query as $key => $item) { + $query[$key]["filesize"] = format_bytes($item["filesize"]); + if (is_cli_client()) { + // Keep track of longest string to pad plaintext output correctly + foreach($fields as $length_key => $value) { + $len = mb_strlen($query[$key][$length_key]); + if ($len > $lengths[$length_key]) { + $lengths[$length_key] = $len; } } } + } - $total_size = $this->db->query(" - SELECT sum(filesize) sum - FROM ( - SELECT filesize - FROM files - WHERE user = ? - GROUP BY hash - ) sub - ", array($user))->row_array(); - - $this->data["query"] = $query; - $this->data["lengths"] = $lengths; - $this->data["fields"] = $fields; - $this->data["total_size"] = format_bytes($total_size["sum"]); - - $cached = ""; - $cached .= $this->load->view('header', $this->data, true); - $cached .= $this->load->view($this->var->view_dir.'/upload_history', $this->data, true); - $cached .= $this->load->view('footer', $this->data, true); + $total_size = $this->db->query(" + SELECT sum(filesize) sum + FROM ( + SELECT filesize + FROM files + WHERE user = ? + GROUP BY hash + ) sub + ", array($user))->row_array(); - // disable for now. reenable if it causes too much load - //$this->memcachelibrary->set('history_'.$this->var->view_dir."_".$user, $cached, 42); - } + $this->data["query"] = $query; + $this->data["lengths"] = $lengths; + $this->data["fields"] = $fields; + $this->data["total_size"] = format_bytes($total_size["sum"]); - echo $cached; + $this->load->view('header', $this->data); + $this->load->view($this->var->view_dir.'/upload_history', $this->data); + $this->load->view('footer', $this->data); } function do_delete() -- cgit v1.2.3-24-g4f1b