X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fplatal.inc.php;h=900220c2a770795ed7c59fd4fa6f1ef4f0dbac48;hb=c4bcb1697481d3a6549f228739f17dc081641491;hp=b9e42fd4c0282e3ee15a64c2084bedddc8230494;hpb=7299bfcef8ccaffa52ecd0ca3adf92c84f79c248;p=platal.git
diff --git a/include/platal.inc.php b/include/platal.inc.php
index b9e42fd..900220c 100644
--- a/include/platal.inc.php
+++ b/include/platal.inc.php
@@ -1,6 +1,6 @@
".
- "{$type} $errstr
".
- "$errfile : $errline".
- "";
- }
-}
+ $error = strpos($type, 'Warning') !== false || strpos($type, 'Error') !==false;
-function pl_clear_errors()
-{
- unset($GLOBALS['pl_errors']);
+ pl_autoload('PlBacktrace');
+ if (!isset(PlBacktrace::$bt['PHP Errors'])) {
+ new PlBacktrace('PHP Errors');
+ }
+ PlBacktrace::$bt['PHP Errors']->newEvent("$type: $errstr",
+ 0, $error ? $errstr : null,
+ array(array('file' => $errfile,
+ 'line' => $errline)));
}
function pl_dump_env()
@@ -122,15 +127,34 @@ function pl_dump_env()
echo "";
}
-function pl_print_errors()
+function pl_print_errors($html = false)
{
- if (!empty($GLOBALS['pl_errors'])) {
- print join("\n", $GLOBALS['pl_errors']);
+ if (!isset(PlBacktrace::$bt['PHP Errors'])) {
+ return;
}
+ foreach (PlBacktrace::$bt['PHP Errors']->traces as $trace) {
+ if ($html) {
+ echo "
"; + } + print "{$trace['action']}\n"; + print " {$trace['data'][0]['file']}: {$trace['data'][0]['line']}\n"; + if ($html) { + echo ""; + } + } +} + +function pl_assert_cb($file, $line, $message) +{ + Platal::assert(false, "Assertion failed at $file:$line with message: $message"); } set_error_handler('pl_error_handler', E_ALL | E_STRICT); -register_shutdown_function('pl_print_errors'); +assert_options(ASSERT_CALLBACK, 'pl_assert_cb'); +assert_options(ASSERT_WARNING, false); +if (php_sapi_name() == 'cli') { + register_shutdown_function('pl_print_errors'); +} //register_shutdown_function('pl_dump_env'); /** Check if the string is utf8 @@ -155,9 +179,6 @@ function pl_url($path, $query = null, $fragment = null) { global $platal; - if (Env::has('__embedded')) { - $path = 'embedded/' . Env::s('__embedded') . '/' . $path; - } $base = $platal->ns . $path . ($query ? '?'.$query : ''); return $fragment ? $base.'#'.$fragment : $base; }