View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 04568 | Bug reports | Other | public | 2010-08-29 19:34 | 2010-09-07 14:29 |
| Reporter | werner | Assigned To | c_schmitz | ||
| Priority | normal | Severity | partial_block | ||
| Status | closed | Resolution | unable to reproduce | ||
| Product Version | 1.90+ | ||||
| Summary | 04568: $sessionhandler='db'; Fatal error: session_start() when previewing inactive servey. | ||||
| Description | I've run into a problem when i set $sessionhandler to db. At first everything seems fine but then i tried to preview Sample Survey for v1.80 (all questions plus most options)and got this error; Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: user (path: /var/lib/php5) in /var/www/formulier/index.php on line 199 | ||||
| Steps To Reproduce | set $sessionhandler='db'; | ||||
| Additional Information | I tracked the problem down to the destroy() calls to regenerate sessions. Instead of trying to fix your adodb solution created my own. called it right there first time on line (109)of the included startup.php to set the session save handler. Then called it tree more times to fix the problem not being able to preview inactive surveys cause of destroy(). index.php just before session_start on line (78, 199, 239). Hope this will help. Kind regards, | ||||
| Tags | No tags attached. | ||||
| Attached Files | startup.php (5,169 bytes)
<?php
/*========================================================================================================*/
/*CREATE TABLE formulier_sessions (
id VARCHAR(32) NOT NULL,
access int(10) unsigned,
data longtext,
PRIMARY KEY (id)
);
*/
/* 1. open sessie data store niet nodig
2. sluit de sessie data store / sluit verbinding
3. lees sessie data
4. schrijf sessie data
5. vernietig alle sessie data
6. schoon de sessie tabel op
*/
/*========================================================================================================*/
function open()
{
}
function close()
{
include('verb.php');/*db_conn*/
mysqli_close($link);
}
/*========================================================================================================*/
function read($id)
{
include('verb.php');
$id = mysqli_real_escape_string($link, $id);
$sql = "SELECT data
FROM formulier_sessions
WHERE id = '$id'";
if ($result = mysqli_query($link, $sql)) {
if (mysqli_num_rows($result)) {
$record = mysqli_fetch_assoc($result);
return $record['data'];
}
}
return '';
}
/*========================================================================================================*/
function write($id, $data)
{
include('verb.php');
/*debug*/
/*echo $id."<br />";
echo $data;*/
$access = time();
$id = mysqli_real_escape_string($link, $id);
$access = mysqli_real_escape_string($link, $access);
$data = mysqli_real_escape_string($link, $data);
$sql = "REPLACE
INTO formulier_sessions(id,access,data)
VALUES ('$id', '$access', '$data')";
return mysqli_query($link, $sql);
}
/*========================================================================================================*/
function destroy($id)
{
include('verb.php');
$id = mysqli_real_escape_string($link, $id);
$sql = "DELETE
FROM formulier_sessions
WHERE id = '".$id."'";
return mysqli_query($link, $sql);
}
/*========================================================================================================*/
function gc($max)
{
include('verb.php');
$oud = time() - $max;
$oud = mysqli_real_escape_string($link, $oud);
$sql = "DELETE
FROM formulier_sessions
WHERE access < ".$oud;
return mysqli_query($link, $sql);
}
session_set_save_handler('open',
'close',
'read',
'write',
'destroy',
'gc');/*First call*/
/*========================================================================================================*/
@ini_set("session.bug_compat_warn", 0); //Turn this off until first "Next" warning is worked out
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
deregister_globals();
}
/*
* Remove variables created by register_globals from the global scope
* Thanks to Matt Kavanagh
*/
function deregister_globals()
{
$not_unset = array(
'GLOBALS' => true,
'_GET' => true,
'_POST' => true,
'_COOKIE' => true,
'_REQUEST' => true,
'_SERVER' => true,
'_SESSION' => true,
'_ENV' => true,
'_FILES' => true
);
// Not only will array_merge and array_keys give a warning if
// a parameter is not an array, array_merge will actually fail.
// So we check if _SESSION has been initialised.
if (!isset($_SESSION) || !is_array($_SESSION))
{
$_SESSION = array();
}
// Merge all into one extremely huge array; unset this later
$input = array_merge(
array_keys($_GET),
array_keys($_POST),
array_keys($_COOKIE),
array_keys($_SERVER),
array_keys($_SESSION),
array_keys($_ENV),
array_keys($_FILES)
);
foreach ($input as $varname)
{
if (isset($not_unset[$varname]))
{
// Hacking attempt. No point in continuing.
exit;
}
unset($GLOBALS[$varname]);
}
unset($input);
}
/**
* This function converts a standard # array to a PHP array without having to resort to JSON_decode which is available from 5.2x and up only
*
* @param string $json String with JSON data
* @return array
*/
if ( !function_exists('json_decode') ){
function json_decode($content, $assoc=false){
global $homedir;
require_once($homedir."/classes/json/JSON.php");
if ( $assoc ){
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON;
}
return $json->decode($content);
}
}
?>
| ||||
| Bug heat | 6 | ||||
| Complete LimeSurvey version number (& build) | +9089 | ||||
| I will donate to the project if issue is resolved | |||||
| Browser | |||||
| Database type & version | MySQL client version: 5.0.51a | ||||
| Server OS (if known) | linux | ||||
| Webserver software & version (if known) | apache2.0 | ||||
| PHP Version | PHP Version 5.2.4-2 | ||||
| Git branch / Pull Request URL | |||||
|
I cannot reproduce the problem here. Works just fine - tested on Linux with the same PHP version. |
|
|
Hi Thank you for your time, and sorry for the late reply been very busy. For now i don't think there is an issue got things working on my end with the changes i made. But one of these days i'll get back into it some more trying to findout why i have a fail config. If i do find out i'll get back to you. Thanks again for your time |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-08-29 19:34 | werner | New Issue | |
| 2010-08-29 19:34 | werner | File Added: startup.php | |
| 2010-08-29 19:49 | werner | Issue Monitored: werner | |
| 2010-09-04 14:38 | c_schmitz | Assigned To | => c_schmitz |
| 2010-09-04 14:38 | c_schmitz | Status | new => assigned |
| 2010-09-04 14:40 | c_schmitz | Note Added: 12749 | |
| 2010-09-04 14:51 | c_schmitz | Note Edited: 12749 | |
| 2010-09-04 14:51 | c_schmitz | Status | assigned => feedback |
| 2010-09-07 03:36 | werner | Note Added: 12771 | |
| 2010-09-07 03:36 | werner | Status | feedback => assigned |
| 2010-09-07 14:29 | c_schmitz | Status | assigned => closed |
| 2010-09-07 14:29 | c_schmitz | Resolution | open => unable to reproduce |
| 2021-08-22 21:03 | guest | Bug heat | 4 => 6 |