Skip to content

Commit f5bc256

Browse files
committed
check GET values and other array elements are set before using, fixes issue #16
1 parent f01d811 commit f5bc256

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

upload/catalog/model/tool/piwik.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private function setEcommerceView() {
7070
/* Get the Category info */
7171
// First, check the GET variable 'path' is set
7272
// Set to false - category reporting not fully supported in this version
73-
if (false) {
73+
if (isset($this->request->get['path']) and false) {
7474
//Initialise variables etc
7575
$piwik_category = '';
7676

@@ -215,7 +215,7 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU
215215
if ($this->piwik_enable) {
216216
if (version_compare(VERSION, '1.5.5.0', '>=')) {
217217
// >= 1.5.5 so use javascript method (when called from the PHP page this is then unusued)
218-
if ($this->request->get['route'] == "product/search") {
218+
if (isset($this->request->get['route']) and isset($this->session->data['last_search_total']) and $this->request->get['route'] == "product/search") {
219219
// If on a search page, return a bit of javascript to set the number of results on piwik.
220220
return "_paq.push(['setCustomUrl', document.URL + '&search_count=" . $this->session->data['last_search_total'] . "']);";
221221
} else {
@@ -224,8 +224,7 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU
224224

225225
} else {
226226
// < 1.5.5 so use PHP method (only if called with correct arguments, so won't run when called from javascript).
227-
if (isset($search_keyword) && isset($search_results_total)) {
228-
227+
if (isset($search_keyword) and isset($search_results_total)) {
229228

230229
// If the visitors piwik ID has been stored in the session data,
231230
// Then use this info to force the visitor ID used for the piwik API call.
@@ -234,12 +233,18 @@ public function trackSiteSearch($search_keyword = NULL, $search_category_id = NU
234233
$this->t->setVisitorId($this->session->data['piwik_visitorid']);
235234
}
236235

236+
//Set the default category title
237+
$category_title = '';
238+
237239
// Get the search category, if it was specified
238240
if (isset($search_category_id)) {
241+
// Get the category info from the ID
239242
$category_info = $this->model_catalog_category->getCategory($search_category_id);
240-
$category_title = urldecode($category_info['name']);
241-
} else {
242-
$category_title = '';
243+
244+
if (isset($category_info['name'])) {
245+
// If the name is specified then use this as for search tracking
246+
$category_title = urldecode($category_info['name']);
247+
}
243248
}
244249

245250
// Track the site search

0 commit comments

Comments
 (0)