diff --git a/bootstrap.php b/bootstrap.php index b8971116fecb896cebe915240ce4c047fd5e983e..47f617b62aeb63317b897aa2e95ebf91755460f2 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -57,7 +57,7 @@ class Bootstrap { && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'); } - function defineTables($prefix) { + static function defineTables($prefix) { #Tables being used sytem wide define('SYSLOG_TABLE',$prefix.'syslog'); define('SESSION_TABLE',$prefix.'session'); diff --git a/include/class.draft.php b/include/class.draft.php index 8af88335e7a4412dd81d2c49b2182a3097df84ba..5b2d8462bc5515eec588df3fed2c05aa8fe7294d 100644 --- a/include/class.draft.php +++ b/include/class.draft.php @@ -137,7 +137,7 @@ class Draft extends VerySimpleModel { return parent::save($refetch); } - static function create($vars) { + static function create($vars=false) { $attachments = @$vars['attachments']; unset($vars['attachments']); diff --git a/include/class.list.php b/include/class.list.php index 782bfebaf302069be61e8854e9af61b2775f731c..841ff3ea5960b4c2394b2fcd595d61026c2d697f 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -1299,7 +1299,9 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { return $this->getName(); } - static function create($ht) { + static function create($ht=false) { + if (!is_array($ht)) + return null; if (!isset($ht['mode'])) $ht['mode'] = 1; diff --git a/include/class.orm.php b/include/class.orm.php index 43795a8e75d3788a6c35082d3d260889806e379b..6a823273fc85b00e595499fe8b5fdbb4693ffa89 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -357,7 +357,7 @@ class VerySimpleModel { } } - function delete($pk=false) { + function delete() { $ex = DbEngine::delete($this); try { $ex->execute(); diff --git a/include/class.sequence.php b/include/class.sequence.php index cc27801c596a8dd17acac088286e15bc7de6b4aa..cf75701fb3849333159fe1e4fd1721b8dd240444 100644 --- a/include/class.sequence.php +++ b/include/class.sequence.php @@ -215,7 +215,7 @@ class RandomSequence extends Sequence { var $padding = '0'; // Override the ORM constructor and do nothing - function __construct() {} + function __construct($ht=false) {} function __next($digits=6) { if ($digits < 6) @@ -228,7 +228,7 @@ class RandomSequence extends Sequence { return $this->next($format); } - function save() { + function save($refetch=false) { throw new RuntimeException('RandomSequence is not database-backed'); } } diff --git a/include/class.task.php b/include/class.task.php index eaf7ffcb9a00fae180b392fb6b42a535d8863494..a39c28a00ceecbc306086a94bf0afe3dba85c4df 100644 --- a/include/class.task.php +++ b/include/class.task.php @@ -416,9 +416,12 @@ class Task extends TaskModel { return !self::lookupIdByNumber($number); } - static function create($vars) { + static function create($vars=false) { global $cfg; + if (!is_array($vars)) + return null; + $task = parent::create(array( 'flags' => self::ISOPEN, 'object_id' => $vars['object_id'], diff --git a/include/class.thread.php b/include/class.thread.php index 03fe49fb523b9ddb5405f07dd4dbd0db3bde3c74..7e97f9fe299c421508b173abb621bc7e4027b7b9 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1035,7 +1035,7 @@ class ThreadEntry extends VerySimpleModel { } //new entry ... we're trusting the caller to check validity of the data. - static function create($vars) { + static function create($vars, &$errors=array()) { global $cfg; //Must have... @@ -1159,7 +1159,7 @@ class ThreadEntry extends VerySimpleModel { return $entry; } - static function add($vars) { + static function add($vars, &$errors=array()) { return self::create($vars); } @@ -1443,11 +1443,11 @@ class MessageThreadEntry extends ThreadEntry { return $this->getTitle(); } - static function create($vars, &$errors) { + static function create($vars, &$errors=array()) { return static::add($vars, $errors); } - static function add($vars, &$errors) { + static function add($vars, &$errors=array()) { if (!$vars || !is_array($vars) || !$vars['threadId']) $errors['err'] = __('Missing or invalid data'); @@ -1481,11 +1481,11 @@ class ResponseThreadEntry extends ThreadEntry { return $this->getStaff(); } - static function create($vars, &$errors) { + static function create($vars, &$errors=array()) { return static::add($vars, $errors); } - static function add($vars, &$errors) { + static function add($vars, &$errors=array()) { if (!$vars || !is_array($vars) || !$vars['threadId']) $errors['err'] = __('Missing or invalid data'); @@ -1520,7 +1520,7 @@ class NoteThreadEntry extends ThreadEntry { return self::add($vars, $errors); } - static function add($vars, &$errors) { + static function add($vars, &$errors=array()) { //Check required params. if (!$vars || !is_array($vars) || !$vars['threadId']) diff --git a/include/class.translation.php b/include/class.translation.php index cb8bcee9a3996bce4b494a870cc097690522c0ce..7bea8c466966942d70fef349fbd064f0eab14f3e 100644 --- a/include/class.translation.php +++ b/include/class.translation.php @@ -1009,7 +1009,10 @@ class CustomDataTranslation extends VerySimpleModel { return parent::save($refetch); } - static function create(array $ht=array()) { + static function create($ht=false) { + if (!is_array($ht)) + return null; + if (is_array($ht['text'])) { // The parent constructor does not honor arrays $ht['text'] = static::encodeComplex($ht['text']); diff --git a/setup/test/run-tests.php b/setup/test/run-tests.php index 2cf780068159380012cb28331b1a65c6b8aa0126..f42c121d7e48b345bf6407b2cde0ea25dc2454c3 100644 --- a/setup/test/run-tests.php +++ b/setup/test/run-tests.php @@ -5,13 +5,9 @@ if (php_sapi_name() != 'cli') exit(); //Allow user to select suite $selected_test = (isset($argv[1])) ? $argv[1] : false; +require_once 'bootstrap.php'; require_once "tests/class.test.php"; -$root = get_osticket_root_path(); -define('INCLUDE_DIR', "$root/include/"); -define('PEAR_DIR', INCLUDE_DIR."pear/"); -ini_set('include_path', './'.PATH_SEPARATOR.INCLUDE_DIR.PATH_SEPARATOR.PEAR_DIR); - $fails = array(); require_once INCLUDE_DIR . 'class.i18n.php'; diff --git a/setup/test/tests/mockdb.php b/setup/test/tests/mockdb.php index b6bc348cf0ddf50be84cd9fe24e4237c74f9ec90..848ccd353f5b5f6111c25aa29f4309f7fe2008ae 100644 --- a/setup/test/tests/mockdb.php +++ b/setup/test/tests/mockdb.php @@ -1,5 +1,9 @@ <?php +define('TABLE_PREFIX', '%'); + +Bootstrap::defineTables(TABLE_PREFIX); + function db_connect($source) { global $__db; $__db = $source; diff --git a/setup/test/tests/test.header_functions.php b/setup/test/tests/test.header_functions.php index 0b2328ce4f30cd42ea6ee09a3e51fd138ffffb91..852241b1b0af5e1da92a237fbc2899d892f11296 100644 --- a/setup/test/tests/test.header_functions.php +++ b/setup/test/tests/test.header_functions.php @@ -1,7 +1,5 @@ <?php require_once "class.test.php"; -define('INCLUDE_DIR', realpath(dirname(__file__).'/../../../include').'/'); -define('PEAR_DIR', INCLUDE_DIR.'/pear/'); require_once INCLUDE_DIR."class.mailparse.php"; abstract class Priorities { diff --git a/setup/test/tests/test.mail-parse.php b/setup/test/tests/test.mail-parse.php index d1d80c225bc2ac846e62aa17b71d2a2f93128130..8d1350f0f178cc4d9d81f73b5561e25a4075f66a 100644 --- a/setup/test/tests/test.mail-parse.php +++ b/setup/test/tests/test.mail-parse.php @@ -1,5 +1,7 @@ <?php +require_once 'mockdb.php'; + require_once INCLUDE_DIR.'class.validator.php'; require_once INCLUDE_DIR.'class.auth.php'; require_once INCLUDE_DIR.'class.staff.php'; @@ -7,8 +9,6 @@ require_once INCLUDE_DIR.'class.email.php'; require_once INCLUDE_DIR.'class.format.php'; require_once INCLUDE_DIR.'class.thread.php'; -require_once 'mockdb.php'; - class TestMailParsing extends Test { var $name = "Mail parsing library tests";