Example #1
0
 /**
  * Unregisters the logger instance as php-error/exception handler.
  */
 public static function unregister()
 {
     if (!self::$registered) {
         return;
     }
     self::$registered = false;
     restore_error_handler();
     restore_exception_handler();
     // unregister of shutdown function is not possible
 }
Example #2
0
 public function run(rex_test_locator $locator, $colors = false)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     // disable backup of globals, since we have some rex_sql objectes referenced from variables in global space.
     // PDOStatements are not allowed to be serialized
     $suite->setBackupGlobals(false);
     $suite->addTestFiles($locator->getIterator());
     rex_error_handler::unregister();
     $runner = new PHPUnit_TextUI_TestRunner();
     $backtrace = debug_backtrace(false);
     array_unshift($backtrace, ['file' => __FILE__, 'line' => __LINE__ + 3]);
     $runner->setPrinter(new rex_tests_result_printer($backtrace, $colors));
     $result = $runner->doRun($suite);
     rex_error_handler::register();
     return $result;
 }
Example #3
0
 /**
  * Shorthand: Logs a error message.
  *
  * @param int    $errno   The error code to log
  * @param string $errstr  The error message
  * @param string $errfile The file in which the error occured
  * @param int    $errline The line of the file in which the error occured
  *
  * @throws InvalidArgumentException
  */
 public static function logError($errno, $errstr, $errfile, $errline)
 {
     if (!is_int($errno)) {
         throw new InvalidArgumentException('Expecting $errno to be integer, but ' . gettype($errno) . ' given!');
     }
     if (!is_string($errstr)) {
         throw new InvalidArgumentException('Expecting $errstr to be string, but ' . gettype($errstr) . ' given!');
     }
     if (!is_string($errfile)) {
         throw new InvalidArgumentException('Expecting $errfile to be string, but ' . gettype($errfile) . ' given!');
     }
     if (!is_int($errline)) {
         throw new InvalidArgumentException('Expecting $errline to be integer, but ' . gettype($errline) . ' given!');
     }
     $logger = self::factory();
     $logger->log(rex_error_handler::getErrorType($errno), $errstr, [], $errfile, $errline);
 }
Example #4
0
require_once rex_path::core('functions/function_rex_other.php');
// ----------------- VERSION
rex::setProperty('version', '5.0.0-alpha7');
$cacheFile = rex_path::cache('config.yml.cache');
$configFile = rex_path::data('config.yml');
if (file_exists($cacheFile) && file_exists($configFile) && filemtime($cacheFile) >= filemtime($configFile)) {
    $config = rex_file::getCache($cacheFile);
} else {
    $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile));
    rex_file::putCache($cacheFile, $config);
}
foreach ($config as $key => $value) {
    if (in_array($key, ['fileperm', 'dirperm'])) {
        $value = octdec($value);
    }
    rex::setProperty($key, $value);
}
date_default_timezone_set(rex::getProperty('timezone', 'Europe/Berlin'));
if (!rex::isSetup()) {
    rex_error_handler::register();
}
// ----------------- REX PERMS
rex_complex_perm::register('clang', 'rex_clang_perm');
// ----- SET CLANG
if (!rex::isSetup()) {
    rex_clang::setCurrentId(rex_request('clang', 'int', rex_clang::getStartId()));
}
if (isset($REX['LOAD_PAGE']) && $REX['LOAD_PAGE']) {
    unset($REX);
    require rex_path::core(rex::isBackend() ? 'backend.php' : 'frontend.php');
}
Example #5
0
 /**
  * starts a http-session if not already started.
  */
 public static function startSession()
 {
     if (session_id() == '') {
         if (!@session_start()) {
             $error = error_get_last();
             if ($error) {
                 rex_error_handler::handleError($error['type'], $error['message'], $error['file'], $error['line']);
             } else {
                 throw new rex_exception('Unable to start session!');
             }
         }
     }
 }