From 32d4210c68e92695dabdd5b3f6b2b400436ece70 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Fri, 29 Aug 2014 21:11:20 +0000
Subject: [PATCH] Sanity check for callable check

Make sure the check is callable
Use call_user_func_array when calling user defined function
---
 include/class.sequence.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/class.sequence.php b/include/class.sequence.php
index ebd4fe862..1b3fc3182 100644
--- a/include/class.sequence.php
+++ b/include/class.sequence.php
@@ -42,11 +42,17 @@ class Sequence extends VerySimpleModel {
      */
     function next($format=false, $check=false) {
         $digits = $format ? $this->getDigitCount($format) : false;
+
+        if ($check && !is_callable($check))
+            $check = false;
+
         do {
             $next = $this->__next($digits);
             $formatted = $format ? $this->format($format, $next) : $next;
         }
-        while ($check && !$check($formatted, $next));
+        while ($check
+                && !call_user_func_array($check, array($formatted, $next)));
+
         return $formatted;
     }
 
-- 
GitLab