From 1ccbb165f386aa827ad90acbb85194066994a520 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 7 Aug 2014 17:04:11 -0500 Subject: [PATCH] Fix a few initial bugs with the merge --- include/class.cron.php | 3 ++- include/class.i18n.php | 1 + include/class.search.php | 14 ++++++++++++-- include/class.sequence.php | 6 ++++++ .../staff/templates/list-item-properties.tmpl.php | 1 - scp/autocron.php | 3 +++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/class.cron.php b/include/class.cron.php index 06d992cdc..af5a14768 100644 --- a/include/class.cron.php +++ b/include/class.cron.php @@ -102,7 +102,8 @@ class Cron { self::PurgeDrafts(); self::MaybeOptimizeTables(); - Signal::send('cron', null); + $data = array('autocron'=>false); + Signal::send('cron', $data); } } ?> diff --git a/include/class.i18n.php b/include/class.i18n.php index 2878dd628..f0be4e6a3 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -65,6 +65,7 @@ class Internationalization { // Note that group requires department 'group.yaml' => 'Group::create', 'file.yaml' => 'AttachmentFile::create', + 'sequence.yaml' => 'Sequence::__create', ); $errors = array(); diff --git a/include/class.search.php b/include/class.search.php index 7bac3d1fb..86957a764 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -33,7 +33,7 @@ abstract class SearchBackend { abstract function update($model, $id, $content, $new=false, $attrs=array()); abstract function find($query, $criteria, $model=false, $sort=array()); - function register($backend=false) { + static function register($backend=false) { $backend = $backend ?: get_called_class(); if ($backend::$id == false) @@ -362,7 +362,17 @@ class MysqlSearchBackend extends SearchBackend { . ' LIMIT 500'; } - $res = db_query($sql); + $class = get_class(); + $auto_create = function($db_error) use ($class) { + + if ($db_error != 1146) + // Perform the standard error handling + return true; + + // Create the search table automatically + $class::createSearchTable(); + }; + $res = db_query($sql, $auto_create); $object_ids = array(); while ($row = db_fetch_row($res)) diff --git a/include/class.sequence.php b/include/class.sequence.php index 62b9c3956..ebd4fe862 100644 --- a/include/class.sequence.php +++ b/include/class.sequence.php @@ -192,6 +192,12 @@ class Sequence extends VerySimpleModel { return $this->current(); return parent::__get($what); } + + function __create($data) { + $instance = parent::create($data); + $instance->save(); + return $instance; + } } class RandomSequence extends Sequence { diff --git a/include/staff/templates/list-item-properties.tmpl.php b/include/staff/templates/list-item-properties.tmpl.php index cb4b7c378..e105bea4f 100644 --- a/include/staff/templates/list-item-properties.tmpl.php +++ b/include/staff/templates/list-item-properties.tmpl.php @@ -38,7 +38,6 @@ } ?> </div><div> <?php - $f->render(); if ($internal && !$f->isEditable()) $f->render('view'); else { diff --git a/scp/autocron.php b/scp/autocron.php index 611cbbc4d..b6016399e 100644 --- a/scp/autocron.php +++ b/scp/autocron.php @@ -49,6 +49,9 @@ if($cfg && $cfg->isAutoCronEnabled()) { //ONLY fetch tickets if autocron is enab $ost->logDebug(_S('Auto Cron'), sprintf(_S('Mail fetcher cron call [%s]'), $caller)); } +$data = array('autocron'=>true); +Signal::send('cron', $data); + $_SESSION['lastcroncall']=time(); endif; ob_end_clean(); -- GitLab