Bug 12041 - improve Koha::Cache
[koha_fer] / svc / report
index 0cff7dc..818e6a0 100755 (executable)
@@ -46,11 +46,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $cache_active = Koha::Cache->is_cache_active;
-my ($cache_key, $cache, $json_text);
+my $cache = Koha::Cache->get_instance();
+my $cache_active = $cache->is_cache_active;
+my ($cache_key, $json_text);
 if ($cache_active) {
     $cache_key = "intranet:report:".($report_name ? "name:$report_name" : "id:$report_id");
-    $cache = Koha::Cache->new();
     $json_text = $cache->get_from_cache($cache_key);
 }
 
@@ -66,14 +66,14 @@ unless ($json_text) {
         else {
             $lines = $sth->fetchall_arrayref;
         }
-        $json_text = to_json($lines);
+        $json_text = encode_json($lines);
 
         if ($cache_active) {
             $cache->set_in_cache( $cache_key, $json_text, $report_rec->{cache_expiry} );
         }
     }
     else {
-        $json_text = to_json($errors);
+        $json_text = encode_json($errors);
     }
 }