From ad6ea0e86a02e42bbcf1dd07de63e1368d105330 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Thu, 13 Dec 2018 12:47:43 -0600
Subject: [PATCH] This commit fixes several PHP 7.2 compatibility issues

---
 include/class.dept.php                         |  2 +-
 include/class.dynamic_forms.php                |  3 ++-
 include/class.role.php                         |  2 +-
 include/class.search.php                       |  3 ++-
 include/class.staff.php                        |  6 +++---
 include/class.translation.php                  |  2 +-
 include/staff/templates/queue-tickets.tmpl.php | 12 ------------
 7 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/include/class.dept.php b/include/class.dept.php
index fe8ded86e..102e87030 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -962,7 +962,7 @@ extends Form {
         );
     }
 
-    function getClean() {
+    function getClean($validate = true) {
         $clean = parent::getClean();
 
         $clean['ispublic'] = !$clean['private'];
diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 6b6212c6a..75c3e9904 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -1183,7 +1183,8 @@ class DynamicFormEntry extends VerySimpleModel {
     }
 
     function render($options=array()) {
-        $options += array('staff' => true);
+        if (is_array($options))
+            $options += array('staff' => true);
         return $this->getForm()->render($options);
     }
 
diff --git a/include/class.role.php b/include/class.role.php
index 7898bb9b6..710c78da7 100644
--- a/include/class.role.php
+++ b/include/class.role.php
@@ -387,7 +387,7 @@ extends AbstractForm {
         );
     }
 
-    function getClean() {
+    function getClean($validate = true) {
         $clean = parent::getClean();
         // Index permissions as ['ticket.edit' => 1]
         $clean['perms'] = array_keys($clean['perms']);
diff --git a/include/class.search.php b/include/class.search.php
index e701a3f09..f2a77955b 100755
--- a/include/class.search.php
+++ b/include/class.search.php
@@ -700,7 +700,8 @@ class SavedQueue extends CustomQueue {
         return $this->_columns;
     }
 
-    static function getHierarchicalQueues(Staff $staff) {
+    static function getHierarchicalQueues(Staff $staff, $pid=0,
+            $primary=true) {
         return CustomQueue::getHierarchicalQueues($staff, 0, false);
     }
 
diff --git a/include/class.staff.php b/include/class.staff.php
index 3833c6353..c02bdb342 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -1389,7 +1389,7 @@ extends AbstractForm {
         );
     }
 
-    function getClean() {
+    function getClean($validate = true) {
         $clean = parent::getClean();
         // Index permissions as ['ticket.edit' => 1]
         $clean['perms'] = array_keys($clean['perms']);
@@ -1441,7 +1441,7 @@ extends AbstractForm {
         return __('Change the primary department and primary role of the selected agents');
     }
 
-    function getClean() {
+    function getClean($validate = true) {
         $clean = parent::getClean();
         $clean['eavesdrop'] = $clean['eavesdrop'] ? 1 : 0;
         return $clean;
@@ -1536,7 +1536,7 @@ extends AbstractForm {
         );
     }
 
-    function getClean() {
+    function getClean($validate = true) {
         $clean = parent::getClean();
         list($clean['username'],) = preg_split('/[^\w.-]/u', $clean['email'], 2);
         if (mb_strlen($clean['username']) < 3 || Staff::lookup($clean['username']))
diff --git a/include/class.translation.php b/include/class.translation.php
index 2e864b393..6a60b0acf 100644
--- a/include/class.translation.php
+++ b/include/class.translation.php
@@ -671,7 +671,7 @@ class Translation extends gettext_reader implements Serializable {
         list($this->charset, $this->encode, $this->cache_translations)
             = unserialize($what);
         $this->short_circuit = ! $this->enable_cache
-            = 0 < count($this->cache_translations);
+            = 0 < $this->cache_translations ? count($this->cache_translations) : 1;
     }
 }
 
diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php
index 41ffef2a6..699b28a35 100644
--- a/include/staff/templates/queue-tickets.tmpl.php
+++ b/include/staff/templates/queue-tickets.tmpl.php
@@ -76,18 +76,6 @@ if (!$sorted && isset($sort['queuesort'])) {
 $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
 $pageNav = new Pagenate(PHP_INT_MAX, $page, PAGE_LIMIT);
 $tickets = $pageNav->paginateSimple($tickets);
-
-// Creative twist here. Create a new query copying the query criteria, sort, limit,
-// and offset. Then join this new query to the $tickets query and clear the
-// criteria, sort, limit, and offset from the outer query.
-$criteria = clone $tickets;
-$criteria->annotations = $criteria->related = $criteria->aggregated = [];
-$tickets->constraints = $tickets->extra = [];
-$tickets = $tickets->filter(['ticket_id__in' => $criteria->values_flat('ticket_id')])
-    ->limit(false)->offset(false)->order_by(false);
-# Index hint should be used on the $criteria query only
-$tickets->clearOption(QuerySet::OPT_INDEX_HINT);
-
 $count = $queue->getCount($thisstaff) ?: (PAGE_LIMIT*3);
 $pageNav->setTotal($count, true);
 $pageNav->setURL('tickets.php', $args);
-- 
GitLab