diff options
author | Christian Klinger | 2016-08-22 11:24:03 +0200 |
---|---|---|
committer | Christian Klinger | 2016-08-22 11:24:03 +0200 |
commit | d3c689c6730ca6749c03ffd01c670f7b191e8355 (patch) | |
tree | 9e2d7caa1ed3c45b4757621202087a64e5e87cc9 /inc | |
parent | css fix/hack to get roomplanner to work on medium sized screens. (diff) | |
parent | [dozmod] Expect the client to tell wether it is running in exam mode and comp... (diff) | |
download | slx-admin-d3c689c6730ca6749c03ffd01c670f7b191e8355.tar.gz slx-admin-d3c689c6730ca6749c03ffd01c670f7b191e8355.tar.xz slx-admin-d3c689c6730ca6749c03ffd01c670f7b191e8355.zip |
Merge branch 'modularization' of git.openslx.org:openslx-ng/slx-admin into modularization
Diffstat (limited to 'inc')
-rw-r--r-- | inc/dictionary.inc.php | 12 | ||||
-rw-r--r-- | inc/event.inc.php | 2 | ||||
-rw-r--r-- | inc/render.inc.php | 3 | ||||
-rw-r--r-- | inc/taskmanagercallback.inc.php | 6 | ||||
-rw-r--r-- | inc/util.inc.php | 35 |
5 files changed, 46 insertions, 12 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php index cb23d0b2..634b1c3c 100644 --- a/inc/dictionary.inc.php +++ b/inc/dictionary.inc.php @@ -69,10 +69,13 @@ class Dictionary return self::$stringCache[$file] = $json; } - public static function translateFileModule($moduleId, $path, $tag) + public static function translateFileModule($moduleId, $path, $tag, $returnTagOnMissing = false) { $strings = self::getArray($moduleId, $path); if (!isset($strings[$tag])) { + if ($returnTagOnMissing) { + return '{{' . $tag . '}}'; + } return false; } return $strings[$tag]; @@ -85,12 +88,15 @@ class Dictionary return self::translateFileModule(Page::getModule()->getIdentifier(), $path, $tag); } - public static function translate($tag) + public static function translate($tag, $returnTagOnMissing = false) { $string = self::translateFile('module', $tag); if ($string !== false) return $string; - return self::translateFileModule('main', 'global-tags', $tag); + $string = self::translateFileModule('main', 'global-tags', $tag); + if ($string !== false || !$returnTagOnMissing) + return $string; + return '{{' . $tag . '}}'; } public static function getMessage($module, $id) diff --git a/inc/event.inc.php b/inc/event.inc.php index dee435a8..8a69ec95 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -20,8 +20,6 @@ class Event EventLog::info('System boot...'); $everythingFine = true; - DefaultData::populate(); - // Tasks: fire away $mountId = Trigger::mount(); $autoIp = Trigger::autoUpdateServerIp(); diff --git a/inc/render.inc.php b/inc/render.inc.php index 1f311868..d870768e 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -270,9 +270,6 @@ class Render } // Load from disk $data = @file_get_contents('modules/' . $module . '/templates/' . $template . '.html'); - if ($data === false) { - $data = '<b>Non-existent/unreadable template ' . $template . ' requested!</b>'; - } self::$templateCache[$id] =& $data; return $data; } diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php index c2a05609..bc959f03 100644 --- a/inc/taskmanagercallback.inc.php +++ b/inc/taskmanagercallback.inc.php @@ -38,7 +38,11 @@ class TaskmanagerCallback . " VALUES (:task, UNIX_TIMESTAMP(), :callback, :args)", $data, true) !== false) { return; } - Database::exec("INSERT INTO callback (taskid, dateline, cbfunction) VALUES (:task, UNIX_TIMESTAMP(), :callback)", $data); + // Most likely the args column is missing - try to add it on-the-fly so the update routine can properly + // use it (confmod updates - otherwise the status of modules is not updated properly) + Database::exec("ALTER TABLE `callback` ADD `args` TEXT NOT NULL DEFAULT ''", array(), true); + Database::exec("INSERT INTO callback (taskid, dateline, cbfunction, args)" + . " VALUES (:task, UNIX_TIMESTAMP(), :callback, :args)", $data); } /** diff --git a/inc/util.inc.php b/inc/util.inc.php index 14621a5a..a9ae384c 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -14,6 +14,11 @@ class Util { if (defined('API') && API) { error_log('API ERROR: ' . $message); + error_log(self::formatBacktracePlain(debug_backtrace())); + } + if (php_sapi_name() === 'cli') { + // Don't spam HTML when invoked via cli, above error_log should have gone to stdout/stderr + exit(1); } Header('HTTP/1.1 500 Internal Server Error'); Header('Content-Type: text/html; charset=utf-8'); @@ -37,9 +42,9 @@ class Util echo '</pre>'; } echo "<h2>Stack Trace</h2>"; - echo '<pre>', self::formatBacktrace(debug_backtrace()), '</pre>'; + echo '<pre>', self::formatBacktraceHtml(debug_backtrace()), '</pre>'; echo "<h2>Globals</h2><pre>"; - echo print_r($GLOBALS, true); + echo htmlspecialchars(print_r($GLOBALS, true)); echo '</pre>'; } else { echo <<<SADFACE @@ -74,7 +79,7 @@ SADFACE; exit(0); } - public static function formatBacktrace($trace, $escape = true) + public static function formatBacktraceHtml($trace, $escape = true) { $output = ''; foreach ($trace as $idx => $line) { @@ -100,6 +105,30 @@ SADFACE; return $output; } + public static function formatBacktracePlain($trace) + { + $output = ''; + foreach ($trace as $idx => $line) { + $args = array(); + foreach ($line['args'] as $arg) { + if (is_string($arg)) { + $arg = "'$arg'"; + } elseif (is_object($arg)) { + $arg = 'instanceof ' . get_class($arg); + } elseif (is_array($arg)) { + $arg = 'Array(' . count($arg) . ')'; + } + $args[] = $arg; + } + $frame = str_pad('#' . $idx, 3, ' ', STR_PAD_LEFT); + $args = implode(', ', $args); + // Add line + $output .= "\n" . $frame . ' ' . $line['function'] . '(' + . $args . ')' . ' @ ' . $line['file'] . ':' . $line['line']; + } + return $output; + } + /** * Redirects the user via a '302 Moved' header. * An active session will be saved, any messages that haven't |