[SESSION] Log messages were a bit confusing

Reported by XRevan86
This commit is contained in:
Diogo Cordeiro 2019-05-22 23:39:34 +01:00
parent 6b4beb90e1
commit 4ca32628f7

View File

@ -73,17 +73,17 @@ class InternalSessionHandler implements SessionHandlerInterface
*/ */
public function read($id) public function read($id)
{ {
self::logdeb("Fetching session '$id'"); self::logdeb("Fetching session '$id'.");
$session = Session::getKV('id', $id); $session = Session::getKV('id', $id);
if (empty($session)) { if (empty($session)) {
self::logdeb("Couldn't find '$id'"); self::logdeb("Couldn't find '$id'.");
return ''; return '';
} else { } else {
self::logdeb("Found '$id', returning " . self::logdeb("Found '$id', returning " .
strlen($session->session_data) . strlen($session->session_data) .
" chars of data"); " chars of data.");
return (string)$session->session_data; return (string)$session->session_data;
} }
} }
@ -97,7 +97,7 @@ class InternalSessionHandler implements SessionHandlerInterface
*/ */
public function write($id, $session_data) public function write($id, $session_data)
{ {
self::logdeb("Writing session '$id'"); self::logdeb("Writing session '$id'.");
$session = Session::getKV('id', $id); $session = Session::getKV('id', $id);
@ -121,15 +121,14 @@ class InternalSessionHandler implements SessionHandlerInterface
} else { } else {
self::logdeb("'$id' already exists; updating."); self::logdeb("'$id' already exists; updating.");
if (strcmp($session->session_data, $session_data) == 0) { if (strcmp($session->session_data, $session_data) == 0) {
self::logdeb("Not writing session '$id'; unchanged"); self::logdeb("Not writing session '$id' - unchanged.");
return true; return true;
} else { } else {
self::logdeb("Session '$id' data changed; updating"); self::logdeb("Session '$id' data changed - updating.");
// Only update the required field
$orig = clone($session); $orig = clone($session);
$session->session_data = $session_data; $session->session_data = $session_data;
$result = $session->update($orig); $result = $session->update($orig);
if (!$result) { if (!$result) {
@ -154,7 +153,7 @@ class InternalSessionHandler implements SessionHandlerInterface
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {
self::logdeb("garbage collection (maxlifetime = $maxlifetime)"); self::logdeb("Garbage Collector has now started with maxlifetime = '$maxlifetime'.");
$epoch = common_sql_date(time() - $maxlifetime); $epoch = common_sql_date(time() - $maxlifetime);
@ -180,10 +179,10 @@ class InternalSessionHandler implements SessionHandlerInterface
$session->free(); $session->free();
self::logdeb("Found " . count($ids) . " ids to delete."); self::logdeb("Garbage Collector found " . count($ids) . " ids to delete.");
foreach ($ids as $id) { foreach ($ids as $id) {
self::logdeb("Destroying session '$id'."); self::logdeb("Garbage Collector will now delete session '$id'.");
self::destroy($id); self::destroy($id);
} }
@ -198,20 +197,20 @@ class InternalSessionHandler implements SessionHandlerInterface
*/ */
public function destroy($id) public function destroy($id)
{ {
self::logdeb("Deleting session $id"); self::logdeb("Destroying session '$id'.");
$session = Session::getKV('id', $id); $session = Session::getKV('id', $id);
if (empty($session)) { if (empty($session)) {
self::logdeb("Can't find '$id' to delete."); self::logdeb("Can't find '$id' to destroy.");
return false; return false;
} else { } else {
$result = $session->delete(); $result = $session->delete();
if (!$result) { if (!$result) {
common_log_db_error($session, 'DELETE', __FILE__); common_log_db_error($session, 'DELETE', __FILE__);
self::logdeb("Failed to delete '$id'."); self::logdeb("Failed to destroy '$id'.");
} else { } else {
self::logdeb("Successfully deleted '$id' (result = $result)."); self::logdeb("Successfully destroyed '$id' (result = $result).");
} }
return (bool) $result; return (bool) $result;
} }