Fix "PHP Warning: session_write_close(): Failed to write session data (user)" errors

- Changed returning true when there's a session ID but no session data
in ref_session_write()
- Moved session.php requires around
This commit is contained in:
Hypolite Petovan 2017-08-01 21:02:24 -04:00
parent 9633d3393f
commit 4601c4bd8a
6 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,7 @@
<?php
require_once 'include/session.php';
require_once 'vendor/autoload.php';
set_time_limit(0);

View file

@ -15,7 +15,6 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
require_once 'session.php';
require_once 'datetime.php';
if ($argc < 3) {

View file

@ -15,7 +15,6 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
require_once 'session.php';
require_once 'datetime.php';
require_once 'simplepie/simplepie.inc';
require_once 'include/items.php';

View file

@ -14,7 +14,6 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_user, $db_pass, $db_data);
require_once 'session.php';
require_once 'datetime.php';
$a->set_baseurl(get_config('system', 'url'));

View file

@ -30,10 +30,14 @@ function ref_session_write($id, $data)
{
global $session_exists, $session_expire;
if (!$id || !$data) {
if (!$id) {
return false;
}
if (!$data) {
return true;
}
$expire = time() + $session_expire;
$default_expire = time() + 300;
@ -65,7 +69,7 @@ function ref_session_gc($expire)
{
q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time()));
q("OPTIMIZE TABLE `sess_data`");
return true;
}

View file

@ -24,8 +24,6 @@ unset($db_host, $db_user, $db_pass, $db_data);
$a->init_pagehead();
$a->page['aside'] = '<div id="logo"><img src="images/friendica-32.png" alt="friendica logo" /> <a href="http://friendica.com">Friendica</a></div><div id="slogan">Your friends. Your web.</div>';
require_once 'session.php';
session_start();
if ((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {