Commit 9c0e85d5 authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(core) Cleaned up error handling in session

Removed unused session entry, made sure all error reset goes through the
 appropriate function.

issue #5854
parent 896ce72c
......@@ -26,7 +26,7 @@
session_cache_limiter("private");
session::start();
session::global_set('errorsAlreadyPosted', array());
reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
......
......@@ -27,7 +27,7 @@
error_reporting (0);
session_cache_limiter('private');
session::start();
session::global_set('errorsAlreadyPosted', array());
reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
......
......@@ -25,7 +25,7 @@
session_cache_limiter("private");
session::start();
session::global_set('errorsAlreadyPosted', array());
reset_errors();
$theme = '';
if (session::global_is_set('config')) {
......
......@@ -63,9 +63,7 @@ if (isset($_REQUEST['signout']) && $_REQUEST['signout']) {
}
/* Reset errors */
session::set('errors', '');
session::set('errorsAlreadyPosted', '');
session::set('LastError', '');
reset_errors();
/* Check if we need to run setup */
if (!file_exists(CONFIG_DIR.'/'.CONFIG_FILE)) {
......
......@@ -37,7 +37,7 @@ textdomain($domain);
/* Remember everything we did after the last click */
session::start();
session::set('errorsAlreadyPosted', array());
reset_errors();
session::global_set('runtime_cache', array());
session::set('limit_exceeded', FALSE);
......@@ -280,23 +280,12 @@ if (isset($_POST) && count($_POST) && !isset($_POST['php_c_check'])) {
}
/* Assign errors to smarty */
if (session::is_set('errors')) {
$smarty->assign("errors", session::get('errors'));
}
if ($error_collector != "") {
$smarty->assign("php_errors", preg_replace("/%BUGBODY%/", $error_collector_mailto, $error_collector)."</div>");
} else {
$smarty->assign("php_errors", "");
}
/* Set focus to the error button if we've an error message */
$focus = "";
if (session::is_set('errors') && session::get('errors') != "") {
$focus = '<script type="text/javascript">';
$focus .= 'document.forms[0].error_accept.focus();';
$focus .= '</script>';
}
$focus = '<script type="text/javascript">';
$focus .= 'next_msg_dialog();';
$focus .= '</script>';
......@@ -336,6 +325,4 @@ echo $display;
/* Save plist and config */
session::global_set('plist', $plist);
session::global_set('config', $config);
session::set('errorsAlreadyPosted', array());
?>
reset_errors();
......@@ -50,7 +50,6 @@ ini_set("session.gc_maxlifetime", 24 * 60 * 60);
/* Start session */
session::start();
session::global_set('DEBUGLEVEL', 0);
session::set('errorsAlreadyPosted', array());
CSRFProtection::check();
......@@ -107,16 +106,6 @@ require_once("../setup/main.inc");
$smarty->assign("date", date("l, dS F Y H:i:s O"));
$header = $smarty->fetch(get_template_path('headers.tpl'));
/* Set focus to the error button if we've an error message */
$focus = "";
if (session::is_set('errors') && session::get('errors') != "") {
$focus = '<script type="text/javascript">';
$focus .= 'document.forms[0].error_accept.focus();';
$focus .= '</script>';
}
$focus = '<script type="text/javascript">';
$focus .= 'next_msg_dialog();';
$focus .= '</script>';
......
......@@ -52,7 +52,6 @@
</tbody>
</table>
{$errors}
{$focus}
<input type="hidden" name="php_c_check" value="1"/>
<input type="hidden" name="CSRFtoken" value="{$CSRFtoken}"/>
......
......@@ -72,8 +72,6 @@
</form>
</div>
{$errors}
</div>
{include file={filePath file="copynotice.tpl"}}
......
......@@ -72,8 +72,6 @@
</form>
</div>
{$errors}
</div>
{include file={filePath file="copynotice.tpl"}}
......
......@@ -163,9 +163,6 @@ class standAlonePage {
$smarty = get_smarty();
$smarty->assign('PHPSESSID', session_id());
if (session::is_set('errors')) {
$smarty->assign('errors', session::get('errors'));
}
if ($error_collector != '') {
$smarty->assign('php_errors', preg_replace('/%BUGBODY%/', $error_collector_mailto, $error_collector).'</div>');
} else {
......
......@@ -411,7 +411,7 @@ function ldap_get_user ($username)
$ldap = $config->get_ldap_link();
if (!$ldap->success()) {
msg_dialog::display(_('LDAP error'),
msgPool::ldaperror($ldap->get_error(), '', LDAP_AUTH).'<br/><br/>'.session::get('errors'),
msgPool::ldaperror($ldap->get_error(), '', LDAP_AUTH),
FATAL_ERROR_DIALOG);
exit();
}
......@@ -2215,9 +2215,7 @@ function mark($needle, $haystack)
function reset_errors()
{
session::set('errors', '');
session::set('errorsAlreadyPosted', array());
session::set('LastError', '');
}
function load_all_classes()
......
......@@ -63,15 +63,6 @@ class LoginPost extends LoginMethod
/* Translation of cookie-warning. Whether to display it, is determined by JavaScript */
$smarty->assign('cookies', '<b>'._('Warning').':</b> '._('Your browser has cookies disabled. Please enable cookies and reload this page before logging in!'));
/* Set focus to the error button if we've an error message */
$focus = '';
if (session::is_set('errors') && session::get('errors') != '') {
$focus = '<script type="text/javascript">';
$focus .= 'document.forms[0].error_accept.focus();';
$focus .= '</script>';
}
$smarty->assign('focus', $focus);
static::displayLogin();
}
......@@ -127,9 +118,6 @@ class LoginPost extends LoginMethod
/* show login screen */
$smarty->assign('PHPSESSID', session_id());
if (session::is_set('errors')) {
$smarty->assign('errors', session::get('errors'));
}
if ($error_collector != '') {
$smarty->assign('php_errors', preg_replace('/%BUGBODY%/', $error_collector_mailto, $error_collector).'</div>');
} else {
......
......@@ -36,7 +36,6 @@
</tbody>
</table>
{$errors}
{$focus}
<input type="hidden" name="setup_goto_step" value=""/>
<input type="hidden" name="CSRFtoken" value="{$CSRFtoken}"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment