Skip to content

Commit

Permalink
Replace serialize usages
Browse files Browse the repository at this point in the history
refs #1744
  • Loading branch information
trasher committed Feb 3, 2024
1 parent 3309c19 commit e10613e
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions lib/GalettePaypal/PaypalHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Analog\Analog;
use Galette\Core\Db;
use Galette\Core\Galette;
use Galette\Core\Login;
use Galette\Core\History;
use Galette\Core\Preferences;
Expand Down Expand Up @@ -79,7 +80,7 @@ public function add(array|string $action, string $argument = '', string $query =
'history_date' => date('Y-m-d H:i:s'),
'amount' => $request['mc_gross'],
'comments' => $request['item_name'],
'request' => serialize($request),
'request' => Galette::jsonEncode($request),
'signature' => $request['verify_sign'],
'state' => self::STATE_NONE
);
Expand Down Expand Up @@ -143,24 +144,11 @@ public function getPaypalHistory(): array
if (count($orig) > 0) {
foreach ($orig as $o) {
try {
$oa = unserialize($o['request']);
} catch (\ErrorException $err) {
Analog::log(
'Error loading Paypal history entry #' . $o[$this->getPk()] .
' ' . $err->getMessage(),
Analog::WARNING
);

//maybe an unserialization issue, try to fix
$data = preg_replace_callback(
'!s:(\d+):"(.*?)";!',
function ($match) {
return ($match[1] == strlen($match[2])) ?
$match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
},
$o['request']
);
$oa = unserialize($data);
if (Galette::isSerialized($o['request'])) {
$oa = unserialize($o['request']);
} else {
$oa = Galette::jsonDecode($o['request']);
}
} catch (\Exception $e) {
Analog::log(
'Error loading Paypal history entry #' . $o[$this->getPk()] .
Expand Down

0 comments on commit e10613e

Please sign in to comment.