Skip to content

Commit 26166eb

Browse files
author
Pascal MARTINEZ
committed
BUG FIXING: E_WARNING - unserialize(): Extra data starting at offset 406 of 1042 bytes - ./engine/modules/z4m_usersessions/mod/UserSessionFile.php(78)
1 parent 9110d52 commit 26166eb

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGE LOG: User sessions (z4m_usersessions)
22

3+
## Version 1.3, 2025-06-27
4+
- BUG FIXING: E_WARNING - unserialize(): Extra data starting at offset 406 of 1042 bytes - ./engine/modules/z4m_usersessions/mod/UserSessionFile.php(78)
5+
36
## Version 1.2, 2025-06-15
47
- CHANGE: the module's PHP constant `MOD_Z4M_USERSESSIONS_APPLICATION_URI` now accepts the 'ALL' value to display all existing user sessions in the session directory (see PHP 'session.save_path' configuration).
58
- CHANGE: the value set for the module's PHP constant `MOD_Z4M_USERSESSIONS_APPLICATION_URI` is now displayed in the session configuration modal dialog.

mod/UserSessionFile.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* --------------------------------------------------------------------
2020
* ZnetDK 4 Mobile User sessions module PHP class
2121
*
22-
* File version: 1.0
23-
* Last update: 04/24/2025
22+
* File version: 1.1
23+
* Last update: 06/27/2025
2424
*/
2525

2626
namespace z4m_usersessions\mod;
@@ -72,10 +72,15 @@ protected function decodeSessionData() {
7272
throw new \Exception("Session file '{$this->filePath}' is empty.");
7373
}
7474
$decodedData = [];
75-
while ($i = strpos($sessionData, '|'))
76-
{
75+
while ($i = strpos($sessionData, '|')) {
7776
$key = substr($sessionData, 0, $i);
78-
$value = unserialize(substr($sessionData, 1 + $i));
77+
$serializedVal = substr($sessionData, 1 + $i);
78+
\ErrorHandler::suspend(); // Avoid E_WARNING - unserialize(): Extra data starting at offset...
79+
$value = unserialize($serializedVal);
80+
\ErrorHandler::restart();
81+
if ($value === FALSE) {
82+
throw new \Exception("Unserialization failed for the session file '{$this->filePath}': {$serializedVal}");
83+
}
7984
$sessionData = substr($sessionData, 1 + $i + strlen(serialize($value)));
8085
$decodedData[$key] = $value;
8186
}

mod/config.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
* --------------------------------------------------------------------
1919
* Parameters of the ZnetDK 4 Mobile User sessions module
2020
*
21-
* File version: 1.2
22-
* Last update: 06/15/2025
21+
* File version: 1.3
22+
* Last update: 07/29/2025
2323
*/
2424

2525

@@ -47,9 +47,9 @@
4747
* Module version number
4848
* @return string Version
4949
*/
50-
define('MOD_Z4M_USERSESSIONS_VERSION_NUMBER','1.2');
50+
define('MOD_Z4M_USERSESSIONS_VERSION_NUMBER','1.3');
5151
/**
5252
* Module version date
5353
* @return string Date in W3C format
5454
*/
55-
define('MOD_Z4M_USERSESSIONS_VERSION_DATE','2025-06-15');
55+
define('MOD_Z4M_USERSESSIONS_VERSION_DATE','2025-07-29');

0 commit comments

Comments
 (0)