From c39f6a392014baf884dbc2fd4aa08c837126e8d7 Mon Sep 17 00:00:00 2001 From: tomolimo Date: Mon, 18 Jul 2016 11:47:31 +0200 Subject: [PATCH] To fix #801 (#806) * To fix #801 Added a test to be sure that we are going to view an existing class. When not viewing a class, then will pass an array to the show_item hooks. * Simplified code Added '&' to permit modification of passed parameter to hooks --- inc/ticket.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 06483211ac7..8ff405fb43a 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -6288,11 +6288,18 @@ function showTimeline($rand) { $options = array( 'parent' => $this, 'rand' => $rand ) ; - $obj = new $item['type'] ; - $obj->fields = $item['item'] ; - Plugin::doHook('pre_show_item', array('item' => $obj, 'options' => &$options)); + if( $obj = getItemForItemtype($item['type']) ){ + $obj->fields = $item['item'] ; + } else { + $obj = $item ; + } + Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options)); - $item_i = $obj->fields; + if( is_array( $obj ) ){ + $item_i = $obj['item']; + } else { + $item_i = $obj->fields; + } $date = ""; if (isset($item_i['date'])) {