-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] E_WARNING unserialize() when running cron job #7
Comments
can confirm those log entries. Its caused here: (/app/Session/File.php) around line 106 while ($offset < \strlen($session)) {
if (!strstr(substr($session, $offset), '|')) {
throw new \App\Exceptions\IllegalValue('invalid data, remaining: ' . substr($session, $offset));
}
$pos = strpos($session, '|', $offset);
$num = $pos - $offset;
$varName = substr($session, $offset, $num);
$offset += $num + 1;
$data = unserialize(substr($session, $offset), ['allowed_classes' => false]);
$return[$varName] = $data;
$offset += \strlen(serialize($data));
} It uses the complete string from $offset position to be de-serialzed. Since only the very next item could be de-serialized it causes that warnings. Replace those "while" block with (it also does some serialize fixing if parts where missing): $matches = [];
if(preg_match_all('/(\w+)\|(.*?)(?=(\w+)\||$)/', $session, $matches)) {
foreach($matches[1] as $i=>$k) {
$v = $matches[2][$i];
if(preg_match_all('/s:(\d+):"([^"]*?)"/', $v, $matches2)) {
foreach($matches2[1] as $i=>$len) {
if(($newlen=strlen($matches2[2][$i]))!=$len) {
$v=str_replace("s:{$len}:\"{$matches2[2][$i]}\"","s:{$newlen}:\"{$matches2[2][$i]}\"",$v);
}
}
}
if(substr_count($v, "{")>substr_count($v, "}")) {
$v .= str_repeat("}", substr_count($v, "{")-substr_count($v, "}"));
}
if(!in_array(substr($v,-1), [";","}"])){
$v .= ";";
}
$return[$k] = unserialize($v);
}
} |
This worked, thank you |
this doesn't allow the user to stay in the portal |
I put this in the "while" blocks
& it allows the user to stay logged in |
🐞 bug report
When running the cron job, I get the following warning messages:
The error log file contains a lot of the following type of errors (only a subset is reproduced here):
🔥 How to trigger the error
Steps to reproduce the behavior:
php cron.php
👎 Actual Behavior
👍 Expected Behavior
Error messages are saved in
errors.log
andcron/xxxx.log
👷 Testing
No errors occur.
📷 Screenshot of configuration
📝 PHP/Apache/Nginx/Browser/CRM Logs
🌍 Your Environment
❓ Additional context
Add any other context about the problem here.
❗️ Inform the community if you solve the problem
The text was updated successfully, but these errors were encountered: