diff --git a/.travis.yml b/.travis.yml index 402dc8ce2..04ec79659 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ before_script: - if [[ $TRAVIS_PHP_VERSION == "5.4" ]]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi - if [[ ! -f codecept.phar ]]; then wget http://codeception.com/releases/2.1.6/codecept.phar; fi script: -- if [[ -f codecept.phar ]]; then php codecept.phar build; fi -- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi -- if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi +- if [[ -s codecept.phar ]]; then php codecept.phar build; fi +- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi +- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi - grunt lint notifications: email: false diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index cc21eef86..3058d3a3c 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1063,7 +1063,11 @@ class Context */ public static function convertEncodingStr($str) { - if(!$str) return null; + if (!$str || utf8_check($str)) + { + return $str; + } + $obj = new stdClass; $obj->str = $str; $obj = self::convertEncoding($obj); diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index 1b5264ed8..a8f321c64 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -67,7 +67,8 @@ class DBMysql extends DB $result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']); if(!$result) { - exit('Unable to connect to DB.'); + $this->setError(-1, 'Unable to connect to DB.'); + return; } if(mysql_error()) @@ -164,7 +165,8 @@ class DBMysql extends DB { if(!$connection) { - exit('Rhymix cannot handle DB connection.'); + $this->setError(-1, 'Unable to connect to DB.'); + return false; } // Run the query statement $result = @mysql_query($query, $connection); diff --git a/classes/db/DBMysqli.class.php b/classes/db/DBMysqli.class.php index 8c425be45..ef8f845ba 100644 --- a/classes/db/DBMysqli.class.php +++ b/classes/db/DBMysqli.class.php @@ -80,8 +80,8 @@ class DBMysqli extends DBMysql { if ($connection === null) { - debug_print_backtrace(); - exit; + $this->setError(-1, 'Unable to connect to DB.'); + return false; } if($this->use_prepared_statements == 'Y') { diff --git a/common/framework/password.php b/common/framework/password.php index bac5e284f..caf9ef49a 100644 --- a/common/framework/password.php +++ b/common/framework/password.php @@ -218,7 +218,7 @@ class Password { $salt = Security::getRandom(12, 'alnum'); $hash_algorithm = 'sha512'; - $iterations = pow(2, self::getWorkFactor() + 5); + $iterations = intval(pow(2, self::getWorkFactor() + 5)) ?: 16384; $key_length = 24; } else @@ -226,7 +226,7 @@ class Password $parts = explode(':', $salt); $salt = $parts[2]; $hash_algorithm = $parts[0]; - $iterations = $parts[1]; + $iterations = intval($parts[1], 10); $key_length = strlen(base64_decode($parts[3])); } return self::pbkdf2($hashchain, $salt, $hash_algorithm, $iterations, $key_length); diff --git a/common/framework/storage.php b/common/framework/storage.php index e8de90d7b..5e8d5e475 100644 --- a/common/framework/storage.php +++ b/common/framework/storage.php @@ -339,7 +339,7 @@ class Storage try { - $iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME); + $iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS); } catch (\UnexpectedValueException $e) { diff --git a/tests/unit/framework/TimerTest.php b/tests/unit/framework/TimerTest.php index 1c9783c0d..c5c4bc2ea 100644 --- a/tests/unit/framework/TimerTest.php +++ b/tests/unit/framework/TimerTest.php @@ -38,11 +38,9 @@ class TimerTest extends \Codeception\TestCase\Test function testMultipleTimers() { $t1 = Rhymix\Framework\Timer::start('timer1'); - usleep(5000); + usleep(10000); $t2 = Rhymix\Framework\Timer::start('timer2'); - usleep(1000); $t3 = Rhymix\Framework\Timer::stop('timer1'); - usleep(2000); $t4 = Rhymix\Framework\Timer::stop('timer2'); $this->assertGreaterThanOrEqual($t1, $t2); @@ -52,7 +50,7 @@ class TimerTest extends \Codeception\TestCase\Test function testTimerFormat() { $t1 = Rhymix\Framework\Timer::start(); - usleep(1000); + usleep(10000); $t2 = Rhymix\Framework\Timer::stopFormat(); $this->assertRegexp('/^[0-9\.,]+ms$/', $t2); diff --git a/tests/unit/functions/LegacyTest.php b/tests/unit/functions/LegacyTest.php index 5bb693d56..48ffe6c7f 100644 --- a/tests/unit/functions/LegacyTest.php +++ b/tests/unit/functions/LegacyTest.php @@ -22,7 +22,7 @@ class LegacyTest extends \Codeception\TestCase\Test public function testGetNextSequence() { - if (!file_exists(\RX_BASEDIR . 'files/config/config.php')) + if (!DB::getInstance()->isConnected()) { return; }